XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Wayne WatsonSubject: Creating embedded structures for XML to XML conversion
Author: Wayne Watson
Date: 08 Jan 2007 02:16 PM
I am not very strong with XSLT, and I am pretty sure that I am not doing this is the ideal fashion so I am hoping someone can point me in the right direction.

I have a program that I am using that has a defined xml structure that is tedious to work with for defining data. So I am trying to use xslt to remap the xml into an embedded structure that can be used with General Interface.

The inbound xml structure is

<dataset>

<table key="EnvSub">
<tc name="Key" type="string" index="true"/>
<tc name="$EaiEnv" type="string" index="false"/>
<tc name="$GoldEnv" type="string" index="false"/>
<tc name="$AppEnv" type="string" index="false"/>
<tr name="AIXPROD">
<td>AIXPROD</td>
<!-- Key -->
<td>SFPROD</td>
<!-- EaiEnv -->
<td>GoldProd</td>
<!-- GoldEnv -->
<td>AppProd</td>
<!-- AppEnv -->
</tr>
<tr name="AIXDEV">
<td>AIXDEV</td>
<!-- Key -->
<td>SFTEST</td>
<!-- EaiEnv -->
<td>GoldUAT</td>
<!-- GoldEnv -->
<td>AppDev</td>
<!-- AppEnv -->
</tr>
</table>

</dataset>



A single xml document will contain several tables, the <tc> element defines the table column, and there has to be a matching number of <td> (table data) elements to <tc> elements, the <td> elements are under the <tr> elements, there can be any number of <tr> elements.



The CDF format is very simple with just a data element and record elements, everything is defined as attributes of the element. It allows for nested record structures and this is partly where I am running into an issue. This is the structure that I am trying to get out with XSLT as matched with the example input shown above.



<data xmlns:fo="http://www.w3.org/1999/XSL/Format" jsxid="jsxroot">

<record jsxtext="EnvSub" jsxid="idF544770">
<record jsxid="tc_1" name="Key" type="string" index="true">
<record td="AIXPROD" jsxid="tr_1"/>
<record td="AIXDEV" jsxid="tr_2"/>
</record>
<record jsxid="tc_2" name="$EaiEnv" type="string" index="false">
<record td="SFPROD" jsxid="tr_1"/>
<record td="SFTEST" jsxid="tr_2"/>
</record>
<record jsxid="tc_3" name="$GoldEnv" type="string" index="false">
<record td="GoldProd" jsxid="tr_1"/>
<record td="GoldUAT" jsxid="tr_2"/>
</record>
<record jsxid="tc_4" name="$AppEnv" type="string" index="false">
<record td="AppProd" jsxid="tr_1"/>
<record td="AppDev" jsxid="tr_2"/>
</record>
</record>

My goal is that for each table, sub-group each tr/td with the corresponding tc element.

I have been using Stylus Stuido and I have actually been able to get most of the xslt working to transform the data, the issue that I am having is matching the td element to the corresponding tc element. I have not been able to figure out how to do it with the mapper, and I haven't been able to figure out the right way to caputre the result writing it raw.

Thanks

Wayne Watson


Documentrtview2cdf.xsl
current xslt file I am working with

Documentlookup_example.xml
Data source file

Postnext
Minollo I.Subject: Creating embedded structures for XML to XML conversion
Author: Minollo I.
Date: 08 Jan 2007 02:50 PM
Wayne,
what is the logic according to which a <td> is associated to a specific <tc>? It doesn't seem to be by name, according to the example you posted; and it doesn't seem to be positional (you have many more <td>'s than <tc>'s, under different <tr>'s).

Postnext
Wayne WatsonSubject: Creating embedded structures for XML to XML conversion
Author: Wayne Watson
Date: 08 Jan 2007 05:15 PM
The relationship is positional; in any given table the number of <tc>s has to equal the number of <td>s, the <tc> element represents the table column name, the <td> represents that table column data for that table row.

For every table you can have a flexible number of <tc> and <td> elements as long as they are equal.

Postnext
Minollo I.Subject: Creating embedded structures for XML to XML conversion
Author: Minollo I.
Date: 08 Jan 2007 05:36 PM
Maybe changing lines 27-30 into...

<xsl:variable name="tcPos" select="position()"/>
<xsl:for-each select="../tr">
<xsl:element name="record">
<xsl:attribute name="td">
<xsl:value-of select="td[$tcPos]"/>

?

Posttop
Wayne WatsonSubject: Creating embedded structures for XML to XML conversion
Author: Wayne Watson
Date: 09 Jan 2007 11:38 AM
Thanks for the help, that totally did the trick.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.