[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML to Table

Subject: XML to Table
From: "Veronica Sanchez" <vsguiseris@xxxxxxxxxxx>
Date: Fri, 16 Apr 2004 18:06:53 +0200
xml to table
Hi, i would like create a table from a xml with a format like this:

<XML>
 <ROWSET>
   <ROW num="1">
     <A>asdf</A>
     <B>asd</B>
     <C>asdf</C>
     <D>asdf</D>
     <E>ad</E>
     ...
   </ROW>
   <ROW num="2">
     <A>asdf</A>
     <B>asdf</B>
     <D>asdf</D>
     <E>asdf</E>
     ...
   </ROW>
   <ROW num="3">
     ...
   </ROW>
   ...
 </ROWSET>
 <DETAIL>
   <COLUM nom="A" class="a" ord="1"/>
   <COLUM nom="B" class="b" ord="2"/>
   <COLUM nom="C" class="c" ord="3"/>
 </DETAIL>
</XML>

I'm using a xsl like this to keep the fields that i need

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="a" match="//DETALLE/CAMPO" use="@nom"/>
<xsl:template match="XML">
<XML>
<ROWSET>
<xsl:for-each select="ROWSET/ROW">
<xsl:variable name="row" select="@num"/>
<ROW>
<xsl:attribute name="num"><xsl:value-of select="$row"/></xsl:attribute>
<xsl:for-each select="//DETAIL/COLUMN">
<xsl:variable name="column" select="@nom"/>
<xsl:choose>
<xsl:when test="//ROW[@num = $row]/*[name() = $column]">
<xsl:copy-of select="//ROW[@num = $row]/*[name() = $column]"/>
</xsl:when>
<xsl:otherwise>
<!-- To create empty node that is absent with his label,
ex. <C></C> at the second node -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ROW>
</xsl:for-each>
</ROWSET>
</XML>
</xsl:template>
</xsl:stylesheet>


Finally I use another xsl to give format of table.

The question is that i have problems with the first step, the xsl is too slow and i can't create the node that doesn't exist in the row and that I want to visualize.

I can change the structure of <DETAIL></DETAIL> if it would be necessary.

If it's possible i would prefer the use of one only xml. can I do it?


Thanks to all.


_________________________________________________________________
Correos mas divertidos con fotos y textos incrembles en MSN 8. Pruibalo gratis dos meses. http://join.msn.com/?pgmarket=es-es&XAPID=45&DI=1055


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.