Transforming xml using xslt

Here should go questions about transforming XML with XSLT and FOP.
Posts: 1

Transforming xml using xslt

Mon Nov 17, 2014 1:35 pm

Hi All,

I am new to xslt and working on a project to transfer one xml into another.

The issue I am getting is while iterating and assigning values as shown below.

Example XML1:

Code: Select all

<something:Main id="id8" modifiedDate="2014-11-14 14:33:33">

Now when i use xslt to get each values for further processing it is taking first value everytime. Like

Code: Select all

<xsl:for-each select="//something:Main/something:Parent">
<xsl:variable name="ClassId">
<xsl:value-of select="//something:Parent" />
<xsl:element name="Testing">
<xsl:attribute name="ClassID">
<xsl:value-of select="$ClassId" />

Here for the first iteration it will print "FirstValue" but in second iteration as well, instead of printing second value it is priting FirstValue. Could you please tell me where am I going wrong?

Posts: 2371

Re: Transforming xml using xslt

Tue Nov 18, 2014 6:40 pm


You're not using the current context (.) in the for-each statement.
Instead of

Code: Select all

<xsl:value-of select="//something:Parent"/>


Code: Select all

<xsl:value-of select="." />

Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Return to “XSLT and FOP”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest