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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2016)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Steven MatthewsSubject: XML to XML transformation
Author: Steven Matthews
Date: 07 May 2006 01:21 PM
Hi There,

I simply need to transform some XML in one format to another. I have been using some middleware to return XML from a relational database using an XML query. Here is an XML dataset sample:

<database URL="jdbc:odbc:SPM">
<NSW QUERY="select invoice.invoiceNum,salesDate,shipToAddress,shipToCity,shipToState,shipToZip,contactName,
contactPhone,lines.prodCode,salesQty,prodName,prodDesc,prodPrice,products.supCode,supplierName,
supplierAddress,supplierCity,supplierState,supplierPhone,supplierFax,supplierContact
from invoice, lines, products, suppliers
where invoice.invoiceNum = lines.invoiceNum and lines.prodCode = products.prodCode and products.supCode = suppliers.supCode
and invoice.shipToState = 'NSW'"
>
<NSW_rec>
<invoiceNum>110</invoiceNum>
<salesDate>19. Aug. 01</salesDate>
<shipToAddress>32 Palm Ave</shipToAddress>
<shipToCity>Batemans Bay</shipToCity>
<shipToState>NSW</shipToState>
<shipToZip>2986</shipToZip>
<contactName>Christian</contactName>
<contactPhone>2734-8564</contactPhone>
<prodCode>FP001</prodCode>
<salesQty>34</salesQty>
<prodName>Flamingo Slippers</prodName>
<prodDesc>Pink fluffy flamingo slippers with rubber soles</prodDesc>
<prodPrice>20.0000</prodPrice>
<supCode>s0001</supCode>
<supplierName>Jacks Apparell</supplierName>
<supplierAddress>34 Westbourne Ave</supplierAddress>
<supplierCity>Melbourne</supplierCity>
<supplierState>Vic</supplierState>
<supplierPhone>9658-2345</supplierPhone>
<supplierFax>9658-2346</supplierFax>
<supplierContact>Terry</supplierContact>
</NSW_rec>
</NSW>
</database>

I need to be able to transform, using XSLT, this rather flat data into something more hierarchical. The <NSW_rec> actually needs re-structuring, to this:

<NSW_rec>
<invoiceNum>110</invoiceNum>
<tbl_lines>
<prodCode>FP001</prodCode>
<tbl_products>
<prodName>Flamingo Slippers</prodName>
<prodDesc>Pink fluffy flamingo slippers with rubber</prodDesc>
<prodPrice>20.0000</prodPrice>
<supCode>s0001</supCode>
<tbl_suppliers>
<supplierName>Jacks Apparell</supplierName>
<supplierAddress>34 Westbourne Ave</supplierAddress>
<supplierCity>Melbourne</supplierCity>
<supplierState>Vic</supplierState>
</tbl_suppliers>
<supplierPhone>9658-2345</supplierPhone>
<supplierFax>9658-2346</supplierFax>
<supplierContact>Terry</supplierContact>
</tbl_products>
<salesQty>34</salesQty>
</tbl_lines>
<salesDate>19. Aug. 01</salesDate>
<shipToAddress>32 Palm Ave</shipToAddress>
<shipToCity>Batemans Bay</shipToCity>
<shipToState>NSW</shipToState>
<shipToZip>2986</shipToZip>
<contactName>Christian</contactName>
<contactPhone>2734-8564</contactPhone>
</NSW_rec>

I have has some practice converting XML to XHTML but not XML to other XML.

Any advice or tips would be appreciated,

Steven Matthews


Postnext
Ivan PedruzziSubject: XML to XML transformation
Author: Ivan Pedruzzi
Date: 07 May 2006 02:20 PM

The mapping looks pretty straightforward, did you try using XML to XML mapper?

http://www.stylusstudio.com/xslt_mapper.html

Ivan Pedruzzi
Stylus Studio Team

Posttop
Jack BradinSubject: XML to XML transformation
Author: Jack Bradin
Date: 11 Jul 2006 02:59 PM
Try the Mapper - pretty usefull!!

http://www.jx9media.com

   
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.