[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Passing tree fragment as a tunneled param to be access
All,
The input and output formats that I am working with both use IDs. Unfortunately, the mapping between the IDs is rather complex. Fortunately, I can dymanically determine the mapping. This is done by creating elements within the transform (and in its own namespace) that pair the ids. All of these pairings sit in a variable in the / template. My problem: While I'm processing the input structure with apply-templates, when the input refers to an id, I need to dip into my pairings variable to look up the appropriate output id. I use a key for this and use the pairings variable to define the tree fragment scope for the key. It appears that when I pass the pairing variable into the apply-templates, it becomes a string and is not recognized as a tree fragment. Hopefully any ambiguity of my description will be absolved with the following domain-independent code. The Input, current xsl, and desired output follow.The xsl includes comments describing current problem in code. Kindest thanks and highest regards, Tim current xsl throws two errors: Error on line 34 of file:/Users/tml/Desktop/question/attempt.xsl: XPTY0019: Required item type of first operand of '/' is node(); supplied value has item type xs:string Transformation failed: Run-time errors were reported Error on line 37 of file:/Users/tml/Desktop/question/attempt.xsl: XPTY0019: Required item type of first operand of '/' is node(); supplied value has item type xs:string Transformation failed: Run-time errors were reported
<xsl:output method="xml" indent="yes"/> <xsl:key name="objects" match="xfm:object" use="@in-id"/> <xsl:template match="/"> <xsl:variable name="objects"> <!-- This would be generated with an apply-templates, but is hard coded for example --> <xfm:object in-id="AAA" out-id="111">text a 1</xfm:object> <xfm:object in-id="BBB" out-id="222">text b 2</xfm:object> <xfm:object in-id="CCC" out-id="333">text c 3</xfm:object> </xsl:variable> <xsl:value-of select="count($objects/*)"/> <xsl:apply-templates select="in-objects"> <xsl:with-param name="objects" select="$objects" tunnel="yes"/> </xsl:apply-templates> </xsl:template> <xsl:template match="in-objects"> <xsl:apply-templates select="in-object[1]"/> </xsl:template> <xsl:template match="in-object"> <xsl:param name="objects"/> <out-object> <refers-to> <xsl:value-of select="concat('input @ref: ',@ref,' ')"/> <!-- LINE 34: I expect $objects to be a tree fragment of 3 xfm:object here, but it is a string. --> <xsl:value-of select="concat('count($objects/*): ',count($objects/*),' ')"/> <!-- LINE 37: After $objects is a tree fragment here, this does not select '111' --> <xsl:value-of select="concat('get @out-id: ',$objects/key('objects',@ref)/@out-id)"/> </refers-to> </out-object> </xsl:template> <xsl:variable name="NL"> <xsl:text> </xsl:text> </xsl:variable> </xsl:transform>
|
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
|