1

I have an xml :

<Data>
<Revenue>
  <revDate>2015-05-31 00:00:00.000</revDate>
  <source>1</source>
  <currencyId>50</currencyId>
  ...
</Revenue>
<Revenue>
  ...
</Revenue>
</Data>

I need to populate an html template using xsl transformation. The logic is dependent on whether the 'Source' node is 1 or not.

I am trapping the source node in the first row of the revenue data in the xsl as follows -

<xsl:variable name="sourceID">
    <xsl:value-of select="Data/revenue[@source][1]/text()"/>
</xsl:variable>

This is then passed onto a javascript function -

<a href=".." onClick="javascript:return isSourceLinked('{sourceID}');">

However,this does not work as the null/blank check on the parameter sourceID always fails(irrespective of whether it contains value or not).

What am i doing wrong - how do I trap the node value?

2
  • 2
    your xpath seems wrong... revenue => R capital, @source is attribute not element although in your xml source is element. Commented May 26, 2015 at 4:24
  • How are you generating the Javascript? Or "passing" the XSL variableinto Javascript? You are missing a step here. Commented May 26, 2015 at 4:24

1 Answer 1

1

Your expression for sourceID is wrong. Try instead ...

<xsl:variable name="sourceID" select="Data/Revenue/source[1]/text()" />
Sign up to request clarification or add additional context in comments.

2 Comments

Shouldn't revenue be Revenue instead?
@DavidDossot: Yes. Tnx.

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.