BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


SQL XML
Sort a table using the header of the table
Applying a XSLT stylesheet using the DBMS_XMLQuery package
N:N relationships with DBMS_XMLQuery Package
DBMS_XMLQuery package bind values to produce more than one xml file
Download data from a database in XML
Inserting XML file into a table using DBMS_XMLSave Package
Insert XML file into a table using ADO
How to call out to a COM component's method through XSLT
How to select DISTINCT items from XML via XSLT
How to convert Word (RTF) documents to XML for auto publication
Creating SQL Statements with XSLT
SQL straight to XML w/ transform
History Of XML
History Of XML And What Is XML.
Order Automation
You enjoy while you are away and let your machine do the job for you.
SQL Server 2000 User Defined Functions - A Powerful concept
XML/XSLT Maker
Generic ADO recordset to HTML table using XML / XSL
How to display the first three nodes of a XML file with XmlDocument?


 
 

<< SEOSystem.XML >>


By Pedro Gil
First Posted 11/29/2001
Times viewed 296

Convert XDR to XML


This post contains attachments
v20011129063131.zip 

Summary Converting files persited with ADO that use XDR to another schema.

Well I've seen many times question and answers, about converting for instance a ADO persisted recordset that will use a XDR schema with all those attributes, into another XML with elements. But most the answer I've seen, will use a simple approach of converting attributes into elements, using this type of code, that it was one of my first XSLT stylesheets.

<xsl:stylesheet version='1.0'
 exclude-result-prefixes=xsl s dt rs z
 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'>
<xsl:output method=xml indent=yes omit-xml-declaration='no'/>

<xsl:template match=/>
 <Orders>
  <xsl:apply-templates select=xml/rs:data/z:row/>
 </Orders>
</xsl:template>

<xsl:template match = z:row>
  <Order>
 <xsl:for-each select = '@*'>
  <xsl:element name='{name(.)}' >
    <xsl:value-of select='.' />
  </xsl:element>
 </xsl:for-each>
 </Order>
</xsl:template>
</xsl:stylesheet>

There are several problem IMHO opinion with this type of approach, first of all the <Orders> and <Order> elements are hardcoded, making this stylesheet only applicable to a particular XML|XDR file. The other is the simplistic approach of one attribute one element. You can say that I could have made the stylesheet in a different format according to the desired output, but the would mean more hardcoded stylesheet that I could not use with other XML|XDR files.

I decide to develop a XSLT stylesheet that makes another XSLT stylesheet that you can apply to the XML/XDR file in order to convert it.

The sequence would be something like this:

1) Change the params.xml file to reflect the desired output.

2) Transform the params.xml file using the genXSLT.xsl

3) Apply the output of this to the XML/XDR file.

On the sample I'm publishing here, I'm converting a file that was persisted from the table orders from the northwind database.

Files included in the attachment:

genXSLT.xsl --> the XSLT stylesheet that generates the conXSLT.xsl based on params.xml

params.xml --> the xml used by the genXSLT.xsl to build the conXSLT.xsl

conXSLT.xsl --> the result of the previous transformation and to be applied to the Orders.xml

orders.xml --> sample xml/xdr file.

output.xml --> the result of the whole process.

Pedro Gil
www.geocities.com/pmpg98_pt
http://www.vbxml.com/xselerator/default.asp the best XSLT IDE.

Additional information


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< SEOSystem.XML >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML