ThanX alot -- your explanation reduces dramatically the size of my xsl and enlarges my xsl-understanding. All what I've written in many hours, is shrinked to a few lines of code ;(. But it works great ;)))
cu Torsten > -----Original Message----- > From: David Neary [mailto:[EMAIL PROTECTED] > Sent: Donnerstag, 15. Mai 2003 16:41 > To: '[EMAIL PROTECTED]' > Subject: RE: XPath expression > > > > Hi, > > > -position() doesn't work for me (it always returns '1' for > > the first child > > of a node but i've to know the absolute position inside the > > whole xml tree) > > It only does this if the context nodeset is the set of > siblings. You can > have the context node set be other stuff. > > > -preceding-sibling::*/@* looks better i'll try it out > > Well, that is for literal attributes, rather than child nodes > (which is what > you seem to mean when you say attribute). > > To clarify, "name" would be an attribute of "node" in this... > <node name="doddery"/> > > > I start with the root node (naturally), list all Attributes > > of the current > > selected node by recursive call, then list all childs also by > > recursive call > > and so on. > > You can match all the nodes of the entire xml tree with //* - > this means > that if your XML is like this... > > <root> > <node> > <subnode/> > <subnode/> > </node> > <node> > <subnode/> > </node> > </root> > > then if you have a template (the [..] is to make sure that > the root node > isn't matched by the template, which would result in an > infinite loop)... > > <xsl:template match="/"> > <xsl:apply-templates select="//*[..]"/> > </xsl:template> > > <xsl:template match="*"> > <xsl:text>For </xsl:text> > <xsl:value-of select="name()"/> > <xsl:text> the position is </xsl:text> > <xsl:value-of select="position()"/> > <xsl:text> > </xsl:text> > </xsl:template> > > ... your output will be > > For root the position is 1 > For node the position is 2 > For subnode the position is 3 > For subnode the position is 4 > For node the position is 5 > For subnode the position is 6 > > > ps>I've attached the xsl. If anyone has time to look in it.... > > ...any comments/proposals etc. are very welcome > > Hope this helps. And if there are any follow-up questions, > please look into > the xsl list at the URL I gave you earlier. > > Cheers, > Dave. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
