Subject: Re: [xsl] simple XPath question From: James Melton <james.melton@xxxxxxxxxxx> Date: Tue, 03 Jul 2001 09:14:40 -0400 |
Jeni, Your description finally makes my output comprehensible. The number I'm displaying with <xsl:copy-of select="position()"/> inside the template refers to the position in the node list generated by <xsl:apply-templates select="item/country"/>. That's why the non-intuitive numbering (US->1, Canada->3) in my output below. Did the language designers realize that subtle notions of context combined with implicit referents (e.g. the node list referent for position()) would be very confusing? Jim. Jeni Tennison wrote: > > If > you select nodes to apply templates to: > > <xsl:template match="warehouse"> > <xsl:apply-templates select="item/country" /> > </xsl:template> > > then within the template for those nodes, the current node list > contains all the country children of the item children of the > warehouse element. > > [...] > > When you *match* nodes with a pattern, then position() gives the > position of the node amongst its similar siblings - it always uses the > source tree to work out the position because match patterns have no > concept of context node lists. James Melton wrote: > > As another bizarre bit, I tested this by adding a country after the "US" > country, and left in your <xsl:copy-of select='position()'/> code. I > found that the number displayed corresponds to the number of countries, > and not the number of "first" countries; i.e. with this input: > <?xml version='1.0'?> > <warehouse> > <item> > <name>orange</name> > <country>US</country> > <country>UK</country> > </item> > <item> > <name>ice wine</name> > <country>Canada</country><country>UK</country> > </item> > </warehouse> > > I get this output: > <?xml version="1.0" encoding="UTF-8"?> > <storage> > <first-country>1<country>US</country> > </first-country> > <country>UK</country> > <first-country>3<country>Canada</country> > </first-country> > <country>UK</country> > </storage> > ____________________________________________________________ James Melton CyLogix 609.750.5190 609.750.5100 james.melton@xxxxxxxxxxx www.cylogix.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] ANN: New Visual XSL design to, Sanjay Manchanda | Thread | Re: [xsl] simple XPath question, Jeni Tennison |
RE: Antwort: Re: [xsl] Internet Exp, Andreas Waechter | Date | RE: [xsl] Is this about grouping ?, Benoit_Aumars |
Month |