RE: [xsl] Handling Repeating XML !!

Subject: RE: [xsl] Handling Repeating XML !!
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Mon, 23 Aug 2004 11:54:11 +0000
Is the XML you have shown fixed or are you allowed to change the xml ?
because, by the look of it, it doesnt look like it is properly designed..
for instance, your xml could be ..

<?xml version="1.0" encoding="UTF-8" standalone ="yes"?>
<A>
 <B>
   <Data id = "1">Data11</Data>
 </B>
 <C>
   <Data id = "2">Data21</Data>
 </C>
 <D>
   <Data id = "3">Data31</Data>
 </D>
 <B>
   <Data id = "1">Data12</Data>
 </B>
 <C>
   <Data id = "2">Data22</Data>
 </C>
 <D>
   <Data id = "3">Data32</Data>
 </D>
</A>

You normally dont want to keep separate nodes just to differentiate the types of logically same node.
With the above structure,
you can do


<xsl:template match = "A">

<xsl:apply-templates select = "//Data"/>
</xsl:template>

<xsl:template match = "Data">
 <xsl:value-of select = "."/>
<br/>
</xsl:template>

if you still want to continue with your XML , this will work.
<xsl:template match="A">
       <xsl:apply-templates select="*"/>
   </xsl:template>
   <xsl:template match="*">
   <xsl:value-of select = "."/>
   <br/>

</xsl:template>

But as I said, It is best to restructure your XML as Above.
HTH
Vasu

From: "rajasekhar v" <bigfundu@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Handling Repeating XML !!
Date: Mon, 23 Aug 2004 16:34:15 +0530

All,

I have the following XML,

<?xml version="1.0" encoding="UTF-8" standalone ="yes"?>
<A>
 <B>
   <Data1>Data11</Data1>
 </B>
 <C>
   <Data2>Data21</Data2>
 </C>
 <D>
   <Data3>Data31</Data3>
 </D>
 <B>
   <Data1>Data12</Data1>
 </B>
 <C>
   <Data2>Data22</Data2>
 </C>
 <D>
   <Data3>Data32</Data3>
 </D>
</A>

Basically, the sets of B,C,D keep repeating inside the common root tag A. And I want it to be displayed as the following in HTML:

Data11
Data21
Data31
Data12
Data22
Data32

Am not able to find any XSL example that would help me to do the same. Please help me out if any of you already have such an example worked out or know the trick to do it, since this is very important for me now.

Thanks and Regards,
Raj

_________________________________________________________________
Claim your Citibank Ready Cash today. http://go.msnserver.com/IN/54177.asp Its fast, easy and affordable.



_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger http://www.msn.co.uk/messenger


Current Thread