Subject: Re: [xsl] questions regarding the use of position() From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> Date: Thu, 31 Jan 2002 22:04:44 +0100 |
> there are two questions; > firstly, is there a way to refer back to the main position when you are > looking at its child element? e.g. > > <xsl:template match="body1"> > the position of main is <xsl:value-of select="position()"/> > </xsl:template> > this approach will only give the position of the body1, but is there are > ways to display the position of main when you are in the body1 template? No, because position() is context-dependent. I.e. using <xsl:apply-templates/> in the template matching Main, position() in template matching body1 returns 2 (because of 1st node <head>). Or even 4, because of empty text nodes in front of <head> and <body1>. But writing <xsl:apply-templates select="body1"/> and your position() will return 1. But you can count the preceding-sibling nodes of your parent: <xsl:value-of select="count(../preceding-sibling::Main) + 1"/> > secondly, is there are ways of creating an id for the body1 element? (how > about the use of xsl:id? not so sure about this) I don't know of any xsl:id. But there is the way using generate-id(): <xsl:value-of select="generate-id()"/> You can specify a XPath-expression as argument for generate-id(), no argument means current node. Hope this helps, Joerg XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] questions regarding the use o, 林 子芯 | Thread | [xsl] how to output elements in ran, Massimo Santini - ma |
[xsl] questions regarding the use o, 林 子芯 | Date | [xsl] how to output elements in ran, Massimo Santini - ma |
Month |