Subject: RE: [xsl] Root when the current node is part of Parameter Result Tree Fragement/Nodelist From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx> Date: Tue, 9 Mar 2004 15:12:02 -0800 |
>> The problem is that - within the context of the ParamColour matching >> template, the key object doesn't seem to be defined - in fact, even root of Actually, I believe the key is defined, it just doesn't match anything in the current document. When you call apply-templates on your parameter node you are changing the current document to that of the parameter. >> this context node ( i.e. <xsl:copy-of select="//" /> is only the Parameter >> contents. This makes me very sad. >> Is there a keyword or expression I can use to get the originally processed >> document while I am in the context of a node from an RTREEFRAG or external >> parameter nodeset ? You could save the root node in a global variable. <xsl:variable name="docRoot" select="/"/> Another solution would be to change your template match and apply-templates to something like this: <xsl:template match="Object"> <xsl:copy-of select="."/> <xsl:apply-templates select="Colour"/> </xsl:template> <xsl:template match="Colour"> <xsl:if test=".=$OtherExpr/ParamColour"> Is the same colour! </xsl:if> </xsl:template> Josh -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Colin Toal Sent: Tuesday, March 09, 2004 1:45 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Root when the current node is part of Parameter Result Tree Fragement/Nodelist Hi all, I hope I'm not breaking etiquette, but I could not find an answer to this in the FAQ or archives. I have an XML source document like this: <Objects> <Object> <Name>Toothbrush</Name> <Type>Electric</Type> <Colour>White</Type> </Object> <Object> <Name>Soap Dish</Name> <Type>Plastic</Type> <Colour>Blue</Colour> <Object> </Objects> I process it with a stylesheet like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"> <xsl:key name="kObject" match="Object" use="Name"/> <xsl:param name="ObjectName" /> <xsl:param name="OtherExpr" /> <xsl:template match="/Objects"> <FoundObject> <xsl:apply-templates select="key('kObject', $ObjectName/Name)"/> </FoundObject> </xsl:template> <xsl:template match="Object"> <xsl:copy-of select="."/> <xsl:apply-templates select="$OtherExpr/ParamColour"/> </xsl:template> <xsl:template match="ParamColour"> <xsl:if test="current() = key('kObject', $ObjectName/Name)/Colour"> Is the same colour! </xsl:if> </xsl:template> I process the XML document with this Stylesheet using SAXON 7.8 in Java, and I pass a DOMSource object into each of the parameters that looks like the following: For ObjectName Param <Name>Toothbrush</Name> For Other Expr Param: <ParamColour>White</ParamColour> The problem is that - within the context of the ParamColour matching template, the key object doesn't seem to be defined - in fact, even root of this context node ( i.e. <xsl:copy-of select="//" /> is only the Parameter contents. This makes me very sad. Is there a keyword or expression I can use to get the originally processed document while I am in the context of a node from an RTREEFRAG or external parameter nodeset ? Thanks in advance for your help, Colin Toal _________________________________________________________________ MSN Premium with Virus Guard and Firewall* from McAfee® Security : 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Root when the current nod, Colin Toal | Thread | RE: [xsl] Root when the current nod, Colin Toal |
Re: [xsl] iE 6.0 makes by output me, J.Pietschmann | Date | Re: [xsl] Trouble with namespaces a, Kevin Jones |
Month |