Subject: RE: [xsl] org.apache.xpath.objects.XRTreeFrag error From: Thorsten Scherler <thorsten@xxxxxxxxxx> Date: Mon, 09 May 2005 12:53:19 +0200 |
On Fri, 2005-05-06 at 14:03 +0000, Aron Bock wrote: > Thorsten, > > Whenever you do something like: > > <xsl:variable> > .. something other than a scalar value > </xsl:variable> > > You end up with a "tree fragment", as you've found. Such fragments need to > be converted to a nodeset, which extension function is offered by various > processors. "node-set", by the MSXML processor, "nodeset" by xalan, etc. > You should be able to find examples on the net. > > As far as possible, however, try not to create a tree fragment (in XSLT > 1.0); it makes life easier. In Your case you could define your variable as: > > <xsl:variable name="objectProperty" select="..."/> > > and you'd get back a node-set that could be simply traversed further > downstream. > Wow, cheers. That helped a million, Aron. :) <xsl:variable name="objectProperty" select="..."/> +1 Yeah I hoped that it was that simple and I did not had to use extension functions. I tried and it is working like a charm. Cheers and again thanks for this solution. :) > Regards, > > --A > > > >From: Thorsten Scherler <thorsten@xxxxxxxxxx> > >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >Subject: [xsl] org.apache.xpath.objects.XRTreeFrag error > >Date: Fri, 06 May 2005 14:32:14 +0200 > > > >Hi list, > > > >I am trying to process the following code: > > > >I defined a variable like: > ><xsl:variable name="objectProperty"> > > <xsl:copy-of select="$model[@objectId= > >$objectId]/forrest:property[@name=$name]"/> > ></xsl:variable> > > > >This variable $objectProperty is a frag like this: > > <forrest:property newId="221" name="mq1-preis"> > > <euro>85</euro> > > <cent>00</cent> > > </forrest:property> > > > >Then I call another template with this frag: > ><xsl:call-template name="getText"> > > <xsl:with-param name="setX"> > > <xsl:copy-of select="$objectProperty"/> > > </xsl:with-param> > ></xsl:call-template> > > > >In the final template I have > ><xsl:template name="getText"> > > <xsl:param name="setX"><test>This is a test.</test></xsl:param> > >... > > <xsl:copy-of select="$setX"/> > >... > ></xsl:template> > > > >That is working fine because it will output: > > <forrest:property newId="221" name="mq1-preis"> > > <euro>85</euro> > > <cent>00</cent> > > </forrest:property> > > > >...but as soon I as I change the final template and use > ><xsl:value-of select="$setX/euro"/> or > ><xsl:copy-of select="$setX/euro"/> > > > >I get > >javax.xml.transform.TransformerException: java.lang.ClassCastException: > >org.apache.xpath.objects.XRTreeFrag > > > >Can anybody tell me what is going wrong and why the XPath is not > >working? > > > >TIA > > > >salu2 > >-- > >thorsten > > > >"Together we stand, divided we fall!" > >Hey you (Pink Floyd) > > > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today - it's FREE! > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > -- thorsten "Together we stand, divided we fall!" Hey you (Pink Floyd)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] org.apache.xpath.objects., Aron Bock | Thread | [xsl] multi-paragraph blockquotes, Bruce D'Arcus |
RE: [xsl] displaying unique entries, Hallas,M | Date | Re: [xsl] Is XSLT a suitable soluti, Geert Josten |
Month |