|
next
|
Subject: 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
|
|
|
|