Return all row Value

Here should go questions about transforming XML with XSLT and FOP.
vivekfriend
Posts: 2
Joined: Mon Dec 30, 2013 8:42 am

Return all row Value

Post by vivekfriend »

Hi

I am using Oxygen XML Editor 15.1

There are 3 rows in one node element i.e. testnode

Now I need to fetch this rows data and display in a table (HTML)

Currently I a using following code:

Code: Select all

  <xsl:for-each select="/ns1:Resource/ns1:testpath/ns1:ExceptionMessage" xmlns:ns1="http://webservicepath">
<xsl:element name="tr">
<xsl:attribute name="align">center</xsl:attribute>

<xsl:element name="td">
<xsl:attribute name="align">left</xsl:attribute>
<font name="verdana" size="3">
<xsl:attribute name="width">120</xsl:attribute>
<i>
<xsl:value-of select="/ns1:Resource/ns1:testpath/ns1:ExceptionMessage/ns1:Message/text()" xmlns:ns1="http://webservicepath"/>
</i>
</font>
</xsl:element>
</xsl:element>
</xsl:for-each>
Now problem in above code is there are 3 rows in node so currently there are 3 rows display but value of all rows are same as first row value.

What is the problem?
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Return all row Value

Post by adrian »

Hi,

The problem is the xsl:value-of/@select. Because you're using an absolute XPath inside the xsl:for-each, you are ignoring the current context (the current for-each item).
So, since the current context is an item from /ns1:Resource/ns1:testpath/ns1:ExceptionMessage, instead of:

Code: Select all

<xsl:value-of select="/ns1:Resource/ns1:testpath/ns1:ExceptionMessage/ns1:Message/text()" xmlns:ns1="http://webservicepath"/>
you should use:

Code: Select all

<xsl:value-of select="ns1:Message/text()" xmlns:ns1="http://webservicepath"/>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
vivekfriend
Posts: 2
Joined: Mon Dec 30, 2013 8:42 am

Re: Return all row Value

Post by vivekfriend »

Thankx adrian....

It's Work.... :)
Post Reply