Re: Not grokking keys...
Guy_Murphy@xxxxxxxxxx wrote: > > Hi. > > Anyone care to explain, or give an example of the usage of keys? You can think of it as a generalized form of id/idref. It doesn't require you to declare things as IDs in your doucment. It allows IDs to be specified in subelements as well as in attributes. It doesn't restrict IDs to be name tokens. It allows multiple independent namespaces (*not* in the XML namespaces sense) of IDs. Imagine you have a document like this: <div> <title>Introduction</title> <p>...</p> <p>For more information see <divref>Expressions</divref>.</p> </div> ... <div> <title>Expressions</title> <p>...</p> </div> Suppose you want to transform this to HTML and you want to number the sections and also number the cross references to sections. Then you could use something like: <xsl:key name="titles" match="div" use="title"/> <xsl:template match="divref"> <xsl:for-each select="keyref('titles', .)"> <xsl:number level="multi" match="div" format="1.1. "/> </xsl:for-each> <xsl:value-of select="."/> </xsl:template> James XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format