0

having a xml with same tag names but for that tag names values were different , so we expecting an output like one by one transaction

<swift>
 <message>
 <block3>
    <tag>
       <name>32</name>
       <value>praveen</value>
    </tag>
    <tag>
       <name>42</name>
       <value>pubby</value>
   </tag>
</block3> 
<block4>
    <tag>
       <name>77</name>
       <value>pravz</value>
    </tag>
    <tag>
        <name>77</name>
        <value>pubbypravz</value>
    </tag>
    <tag>
        <name>76</name>
         <value>shanmu</value>
   </tag>
   </block4>
  </message>
</swift>

xslt

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">            
    <xsl:for-each select="swift/message">   

                  <xsl:for-each select ="block3/tag[name = '32']">
            <xsl:value-of select="value"/>
        </xsl:for-each>,<xsl:text/>

                    <xsl:for-each select ="block4/tag[name = '77']">
            <xsl:value-of select="value"/>,<xsl:text/>
        </xsl:for-each>

        </xsl:for-each>

</xsl:template>

by this above xslt i have reached up to this

praveen,pravz,pubbypravz,

output needed:

 praveen,pravz

 praveen,pubbypravz

hope we need to set a loop for each time please guide me ...

12
  • you should provide a sample of your xml source and a sample of the xml output you would like to obtain to get some answers. Commented May 14, 2011 at 5:44
  • USD,EUR,DINAR INR,EUR,DINAR .......... required output Commented May 14, 2011 at 5:46
  • on what basis people voted negatively ...if they dint know the output for that please be clam dont make unneccessarily reduce my reputations Commented May 14, 2011 at 5:53
  • Say, you have 3 different states, each one occurring three times with 3 different currency values for each - how many lines of output do you expect? 3^3 = 27 ? What purpose for? Commented May 14, 2011 at 7:31
  • @doc brown for people understanding purpose i have written like that and that to i was very new to this site don mine Commented May 15, 2011 at 1:24

1 Answer 1

1

Well, you changed your first example completely, so my first answer did not match any more to your question. That makes our discussion some kind of worthless for outsiders. Nevertheless, I adapted my solution to your new input data:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" />

    <xsl:template match="/">
    <xsl:for-each select ="/swift/message/block3/tag[name='32']">
       <xsl:variable name = "first-val" select="value"/>
       <xsl:for-each select ="/swift/message/block4/tag[name='77']">
           <xsl:value-of select="concat($first-val, ',',value)"/>
<xsl:text>
</xsl:text>
       </xsl:for-each>
    </xsl:for-each>

    </xsl:template>
</xsl:stylesheet>

Hope this helps.

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

6 Comments

@doc brown thanks for your reply for that above output loop counter will required i think so ..
@pubby: having problems to understand your comment, sorry. So is this a solution for your case, or is your situation more complex? Please clarify.
no is that solution which was provided by you it was not correct..i hope first we need get tag values of repeated one and we need to apply a loop in xslt okay let me edit the xml and xslt once i hope you can understand better boss
@doc i have modified a xml nn xslt so far i have reached please check out and let me know boss
@doc brown have you seen the above modified data i hope now you will be clear on this
|

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.