|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] xsl structuring....
Hi everyone,
I am having a structuring problem with displaying the xml file in the format I want. Even though I think it must be a common one cause I came accross similar kind of structuring many times, but this time it is in XSL. I have an XML file in this format. <History>
<des>
<desRow>
<name>n1</name>
<qty>10</qty>
</desRow>
<desRow>
<name>n2</name>
<qty>11</qty>
</desRow>
<desRow>
<name>n3</name>
<qty>12</qty>
</desRow>
<desRow>
<name>n6</name>
<qty>14</qty>
</desRow>
<desRow>
<name>n7</name>
<qty>15</qty>
</desRow>
</des> <asis>
<asRow>
<name>n1</name>
<qty>20</qty>
</asRow>
<asRow>
<name>n2</name>
<qty>21</qty>
</asRow>
<asRow>
<name>n3</name>
<qty>22</qty>
</asRow>
<asRow>
<name>n9</name>
<qty>30</qty>
</asRow>
</asis>
</History>
/* ********************************************** */Now my problem is to display it in the following format. Name desQty asisQty n1 10 20 n2 11 21 n3 12 22 n6 14 - n7 15 - n9 - 30 To achieve this, using the traditional sequential programming approach, I do the following. (Still hard to think in terms of structured - recursive approach.) :) <xsl:for-each select="des/desRow"
<xsl:variable name="desName" select="name"/>
<TR><TD><xsl:value-of select="name"/></TD>
<TD<xsl:value-of select="qty"/></TD>
<xsl:for-each select="asis/asRow"
<xsl:if test="$desName = name">
<TD><xsl:value-of select="qty"/></TD>
</xsl:if>
</xsl:for-each> </TR>
</xsl:for-each>This <xsl:for-each> block will get all the common elements and new elements in "des". And I am unable to think of a way to get the new elements in "asis". To get this if I write another FOR loop, with "asis" as outer loop, still I will have no way to determine that a match has been made and that it is a new element. How much I wish XSL had (actual)variables even though it has one. I would have used a flag and set it to true if a match was made and it would have solved my problem. To get around this problem, I was thinking of another dumb way. Is there any way you can change the XML from XSL????????????? I was thinking of having a flag attribute for each "Row" and set it to true if a match has been made. But then I know it is not right as you are changing content for display. Please, any suggestions towards this from the XSL gurus will be greatly appreciated. Thanx, -Saif. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








