SGMLXML.net A place for SGML and XML application developers.

July 22, 2005

Looking up keys in a separate xml file

Filed under: XSLT — cangione @ 2:26 pm







Was recently working on an XSLT filter that extracted the text portion of SVG graphics into another file for translation. Once translated I needed a mechanism to merge the text back into the graphic. The document function did nicely.

Example:

<xsl:key name="descriptionlookup" 
match="Descriptions/Description" use="@name"/>
<xsl:variable name="desc" select="document('desc.xml')"/>

Later....

<xsl:template match="InsertDescription">
	<xsl:variable name="key_value" select="@lookup"/>
	<xsl:for-each select="$desc">
	<xsl:copy-of 
        select="key('descriptionlookup',$key_value)/Para"/>
	</xsl:for-each>
</xsl:template>


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress