[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using an xsl:variable within an xsl:apply-templates se
Hello, I am calling the following template with an Xpath expression to limit the number of element nodes that are processed from an input document. While processing these nodes, I want to process the current node and each element that the context node refers to (and nothing more). For example, let thing 1 be the node set that this template is applied to. This template will process thing 1 and thing 2, but not thing 3 because it is not referred to by thing 1. Sample input: <thing rdf:ID="1"> <likes rdf:resource="2"/> </thing> <thing rdf:ID="2"> <likes rdf:resource="3"/> </thing> <thing rdf:ID="3"> <likes rdf:resource="4"/> </thing> My question: Is it permitted to use an xsl:variable within the xsl:apply-templates select attribute as I do below? The value-of count is returning 0 when there exists a thing with an rdf:ID that matches the contents of the myIDREF variable. Could my Xpath expression be incorrect? Also: I am not using the id() or key functions because I would think that my described technique should work. If the either technique is applicable and cleaner, I would appreciate the advice. <xsl:template match="thing" mode="gather"> <!-- Process current node --> <xsl:apply-templates select="." mode="process"/> <!-- Process nodes that I refer to --> <xsl:for-each select="*/@resource"> <xsl:variable name="myIDREF" select="."/> <xsl:value-of select="$myIDREF"/> <xsl:value-of select="count(//thing[@rdf:ID=$myIDREF])"/> <xsl:apply-templates select="//thing[@rdf:ID=$myIDREF]" mode="process"/> <!-- HERE --> </xsl:for-each> </xsl:template> <xsl:template match="thing" mode="process"> <!-- Do stuff, but don't apply-templates to things I refer to --> </xsl:template> The rdf namespace is defined and matches that of the input namespace declaration. Regards, Timothy M. Lebo Research Associate Smart Information Flow Technologies 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
|