Hi Michael,
Thank you for your reply.
My objective is to add attributes and attribute values to an XML source document that will specify pre-defined typographic styles to apply when the modified source is submitted to a high-end page composition system.
I can add the necessary attributes and attribute values directly in the template as follows:
Code:
<xsl:template match="act-name">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="BaseFormat" select="string('6201')"/>
<xsl:attribute name="Style" select="string('40')"/>
<xsl:attribute name="Typeface" select="string('32')"/>
<xsl:attribute name="Variant" select="string('1')"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
However, for the sake of readability, and ease of maintenance, I would rather perform the same operation through a function call. Also, rather than specify the names of the attributes each time, I would rather have the function supply the attribute names (they are always the same) and simply pass in the values (which change).
So my function call would look something like:
Code:
<xsl:value-of select="myfunction:add-attributes('6201','40','32','1'))"/>
Except I haven't been able to get this to work.
The reason for this madness, by way of background, is to move the intelligence out of the composition system up into the web server that is receiving and submitting jobs to the system. We will use the Saxon .Net component to perform the transform. Each typographic style is encoded in XML and maintained in a database under revision control. When a job is submitted, the source will be transformed, the appropriate styles fetched from the database, and the entire package submitted for composition.
I hope this helps clarify things.
(I am reading your XSLT 2.0 and XPath 2.0 4th ed. book and find it most helpful.)
Thanks,
Martin