• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

xsl for xml tags with similar name

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an XML file like the following. I need to write an XSL file which will display the following columns of every tag(<col> under each tag(<row> . How do I do this? My sample XSL is also posted below XML which does not display the xml info in the table. Please help me.
</RowSet>
<data>
<row>
<col>7369</col>
<col>SMITH</col>
<col>CLERK</col>
</row>
<row>
<col>7499</col>
<col>ALLEN</col>
<col>SALESMAN</col>
</row>
<row>
<col>7521</col>
<col>WARD</col>
<col>SALESMAN</col>
</row>
</data>
</RowSet>
XSL:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="row">
<HTML>
<BODY>
<CENTER>
<TABLE>
<TR>
<TD>
<FONT COLOR="#CC0000" SIZE="+1">
<B>List of Products</B>
</FONT>
</TD>
</TR>
<TR>
<TD>
<xsl:for-each select="/RowSet/data/row">
<xsl:value-of select="col"/>
</xsl:for-each>
</TD>
</TR>
</TABLE>
<BR/>
<FORM ACTION="../jsps/Main.jsp" METHOD="post">
<CENTER>
<INPUT TYPE="SUBMIT" NAME="Back" VALUE="Back To Main Page"/>
</CENTER>
</FORM>
</CENTER>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Thank you and regards,
Raj.
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're matching on "row", but you're also doing a foreach on /RowSet/data/row . Do one or the other, not both.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Replace the corresponding lines with these:

<xsl:template match="data">
===========================
<xsl:for-each select="row">
============================
That's all. It will work
:roll:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic