XML Development

Moderators: None (Apply to moderate this forum)
Number of threads: 252
Number of posts: 451

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
XSL Transformation help needed (original and new provided) - crosspost Posted by Anatoli on 21 Apr 2005 at 11:35 PM
Crossposted in .Net + XML

Hi all,

I am to this forum and new to XSL. I am working on a generic reporting solution. XSL is the stumbling block.
I need to create an XSL stylesheet that converts ANY(!) XML created by .Net DataSet object into an XML file,
which can be diplayed in a web page using another stylesheet.

The DataSet can have results from multiple (!) queries.
The very first one unnamed SQL creates <table> node with the column names as children where text has the data.
Every new SQL creates Table1, Table2, etc. I need to convert all queries into headers with column names and rows with data.

Original:

<?xml version="1.0" standalone="yes"?>
<OriginalDataSet>
<Table>
<Column1>25.7500</Column1>
</Table>
<Table1>
<Test_x0020_Decimal>45.15</Test_x0020_Decimal>
</Table1>
<Table2>
<Today>2005-04-13T23:02:38.6270000+10:00</Today>
</Table2>
<Table3>
<Num_x0020_of_x0020_Authors>23</Num_x0020_of_x0020_Authors>
</Table3>
<Table4>
<Num_x0020_of_x0020_Employees>43</Num_x0020_of_x0020_Employees>
</Table4>
<Table5>
<Column1>Testing Output</Column1>
</Table5>
<Table6>
<au_id>172-32-1176</au_id>
<au_lname>White</au_lname>
<au_fname>Johnson</au_fname>
<phone>408 496-7223</phone>
<address>10932 Bigge Rd.</address>
<city>Menlo Park</city>
<state>CA</state>
<zip>94025</zip>
<contract>true</contract>
</Table6>
<Table6>
<au_id>213-46-8915</au_id>
<au_lname>Green</au_lname>
<au_fname>Marjorie</au_fname>
<phone>415 986-7020</phone>
<address>309 63rd St. #411</address>
<city>Oakland</city>
<state>CA</state>
<zip>94618</zip>
<contract>true</contract>
</Table6>
</OriginalDataSet>

New, comments are not necessary, they are for readability only

<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="datasetstylesheet.xsl" ?>
<DATASET>

<!-- <Table> -->
<header>
<field>Column1</field>
</header>
<row>
<field>25.7500</field>
</row>

<!-- <Table1> -->
<header>
<field>Test_x0020_Decimal</field>
</header>
<row>
<field>45.15</field>
</row>

<!-- <Table2> -->
<header>
<field>Today</field>
</header>
<row>
<field>2005-04-13T23:02:38.6270000+10:00</field>
</row>

<!-- <Table3> -->
<header>
<field>Num_x0020_of_x0020_Authors</field>
</header>
<row>
<field>23</field>
</row>

<!-- <Table4> -->
<header>
<field>Num_x0020_of_x0020_Employees</field>
</header>
<row>
<field>43</field>
</row>

<!-- <Table5> -->
<header>
<field>Column1</field>
</header>
<row>
<field>Testing Output</field>
</row>

<!-- <Table6>, NOTE: only one header but 2 rows! -->
<header>
<field>au_id</field>
<field>au_lname</field>
<field>au_fname</field>
<field>phone</field>
<field>address</field>
<field>city</field>
<field>state</field>
<field>zip</field>
<field>contract</field>
</header>
<row>
<field>172-32-1176</field>
<field>White</field>
<field>Johnson</field>
<field>408 496-7223</field>
<field>10932 Bigge Rd.</field>
<field>Menlo Park</field>
<field>CA</field>
<field>94025</field>
<field>true</field>
</row>
<row>
<field>213-46-8915</field>
<field>Green</field>
<field>Marjorie</field>
<field>415 986-7020</field>
<field>309 63rd St. #411</field>
<field>Oakland</field>
<field>CA</field>
<field>94618</field>
<field>false</field>
</row>

</DATASET>

Your help is appreciated!
Anatoli

If you need more info, please post here.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.