tags:

views:

47

answers:

2
  <var>1</var>
      <value>not null</value>
      <var>2</var>
      <value>00FFFFFFF555555000100673</value>
      <var>3</var>
      <value>9694r</value>

If it were a list of vars I can iterate like

 <xsl:for-each select="var">
    ..  crap code
 </xsl:for-each>

But I need to catch the value related to var whenever i catch the var ,and display it in a table. I guess this is bad design , but I'm knee deep.

+2  A: 

You can use the following-sibling axis:

<xsl:for-each select="var">
   <xsl:value-of select="./following-sibling::value[1]" />
</xsl:for-each>
Oded
wow..thank you. Saved my time. can you recommend any reading related xslt? I mean books for newbies or newsgroups..?
Vignesh
@Vignesh - Try w3schools. http://www.w3schools.com/xpath/default.asp
Oded
@Oded, this is not correct. 1) `.::following-sibling::text()` is a syntax error (it must be `./following-sibling::text()`, and this is redundant with just `following-sibling::text()`). 2) it must not be `text()`, but `value` 3) `following-sibling` selects *all* following siblings, so it should be `<xsl:value-of select="following-sibling::value[1]" />`.
Tomalak
If i try this solution, I get an XPath syntax error because of the ".::" in the select. Also, "text()" doesn't return anything does it? (The following sibling is "value", right?)
DevNull
@DevNull See my comment. @Oded: Now it's correct. ;) +1
Tomalak
@Tomalak - Can you share some resources on XPath... I keep thinking I know this stuff and you keep showing me how wrong I am ;)
Oded
This is a seperate question but then, is there any way to put serial no. for my table in xsl?. No increments for variables are allowed.. Wondering ...
Vignesh
@Tomalak, you are right; i should've used "[1]" to specify the first following-sibling. I was using saxon 6.5.5 and it only returns the value of the first following-sibling. Xalan does the same thing. If I switch to Saxon-HE 9.2.0.6 (or PE/EE), it returns all of the following-siblings. Thanks for pointing that out. +1
DevNull
@Vignesh - You may be able to use the xpath `position()` function and output it `<xsl:value-of select="position()" />`.
Oded
@Vignesh, if by serial number you mean a unique identifier, you can use `<xsl:value-of select="generate-id()"/>`
DevNull
I actually used this.. <xsl:variable name="count"> <xsl:number/> </xsl:variable>Thank you anyway
Vignesh
+2  A: 

You could try using:

<xsl:value-of select="following-sibling::value"/>

in place of "crap code".

DevNull