0

XML:

<sheet>
    <row num="4">
        <cell num="1">Customer CODE</cell>
        <cell num="2">2213213</cell>
    </row>
    <row num="5">
        <cell num="1">header</cell>
        <cell num="4">12312</cell>
    </row>
</sheet>

I want to set to variable value 5. Because in 5th row there is cell[@num='1'] which equals to header.

This is just returns true

<xsl:variable name="header_pos" select="//row/cell[@num='1']='header'"/>

But I don't know how to get row num value for that cell.. Could you please help

2 Answers 2

4

This is the expression you are looking for:

<xsl:variable name="header_pos" select="//row[cell[@num='1']='header']/@num"/>

i.e Get the row when the cell, with attribute num = '1', has a value of 'header'

Sign up to request clarification or add additional context in comments.

Comments

2

Try this:

<table xsl:version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="header_pos" select="sheet/row/cell/@num" />
<xsl:value-of select="$header_pos" separator=", "/>
</table>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.