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
Mango LierSubject: Transforming ADO output
Author: Mango Lier
Date: 14 Sep 2006 12:39 AM
Need a little help with XML/XSLT transform? What I am trying to achieve is to take the raw XML from an ADO recordset and then convert it to a hierarchical XML using ParentID as the child of the ID. If the ID is 0 then the element is at root level output like below:

<Row>
<Cell>Title</Cell>
<Cell>Description</Cell>
<Row>
<Cell>Title</Cell>
<Cell>Description</Cell>
<Row>
<Cell>Title</Cell>
<Cell>Description</Cell>
</Row>
</Row>
</Row>

With the little knowledge I have of XML and XSLT I came up with following transform but it is not working. I was wondering if you could provide some pointers on how to develop such a transform.


=================== INPUT XML FILE ========================
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly">
<s:AttributeType name="ID" rs:number="1" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
</s:AttributeType>
<s:AttributeType name="ParentID" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
</s:AttributeType>
<s:AttributeType name="Title" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="100"/>
</s:AttributeType>
<s:AttributeType name="Description" rs:number="4" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="100"/>
</s:AttributeType>
<s:AttributeType name="CloseForComments" rs:number="5" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
</s:AttributeType>
<s:AttributeType name="Url" rs:number="6" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="100"/>
</s:AttributeType>
<s:extends type="rs:rowbase"/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ID="1" ParentID="0" Title="Security" Description="gfhfdgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="2" ParentID="1" Title="Specification" Description="dgfhdfgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="3" ParentID="2" Title="Version 1" Description="dfghgfh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="4" ParentID="2" Title="Version 2" Description="gfdhdfgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="5" ParentID="1" Title="Hardware" Description="dfghdfgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="6" ParentID="5" Title="Silicon" Description="gfdhgdfh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="7" ParentID="5" Title="Test Boards" Description="dgfhgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="8" ParentID="1" Title="Software" Description="dgfhgfdh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="9" ParentID="8" Title="Security" Description="gfdhdfgh" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="10" ParentID="8" Title="Database" Description="dfghgh" CloseForComments="0" Url="http://www.Yahoo.com"/>
<z:row ID="11" ParentID="1" Title="Display" Description="gfdhdfghs" CloseForComments="0" Url="http://www.Yahoo.com"/>
<z:row ID="12" ParentID="0" Title="Communications" Description="sdfgsd" CloseForComments="0" Url="http://www.Yahoo.com"/>
<z:row ID="13" ParentID="12" Title="Specification" Description="dsfgfdg" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="14" ParentID="13" Title="Version 1" Description="sfdgsdfg" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="15" ParentID="13" Title="Version 2" Description="sdfgdsgf" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="16" ParentID="12" Title="Hardware" Description="sfdgfdg" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="17" ParentID="16" Title="Silicon" Description="fdsgfdg" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="18" ParentID="16" Title="Test Boards" Description="fdgfdgs" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="19" ParentID="12" Title="Software" Description="oiupoiu" CloseForComments="1" Url="http://www.Yahoo.com"/>
<z:row ID="20" ParentID="19" Title="Security" Description="uiop" CloseForComments="1" Url="http://www.Yahoo.com"/>
</rs:data>
</xml>=================== END OF XML FILE =======================


============== MY FAILED TRANSFORM ATTEMPT ==============
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema" version="1.0">

<xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">
<xsl:apply-templates select="*/xml/rs:data/z:row[not(@ParentID = /*/xml/rs:data/z:row/@ID)]"/>
</xsl:template>

<xsl:template match="xml/rs:data/z:row">
<treenode Projects="{@Title}">
<xsl:apply-templates select="/*/xml/rs:data/z:row[@ParentID = current()/@ID]"/>
</treenode>
</xsl:template>
</xsl:stylesheet>
=================== END OF MY TRANSFORM ==================

Postnext
Ivan PedruzziSubject: Transforming ADO output
Author: Ivan Pedruzzi
Date: 14 Sep 2006 01:05 AM
This forum is for Stylus Studio users only and we can't find your email address in our records.

Which Stylus Studio version are you running?

Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html

Postnext
Mango LierSubject: Transforming ADO output
Author: Mango Lier
Date: 14 Sep 2006 02:10 AM
I am not a stylus studio customer but I have used demo version of your app in the past.

It is up to you, any help is appricated though

Posttop
James DurningSubject: Transforming ADO output
Author: James Durning
Date: 14 Sep 2006 10:54 AM
check your post in the oxygen forum.

 
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.