Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 17th, 2007, 08:00 AM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automated tool to convert XML from DTD to DTD

Hi… this is regarding XML to XML conversion, based on different DTDs

I have one XML file based on a given DTD, I am trying to convert the XML content to a new XML based on a different DTD.

DTD 2 is a subset of DTD 1 with different element names. DTD1 is huge, DTD2 as well. I started to do this manually but it is taking a lonf time. I am trying to get some automated program tool to generate me a XLST transform to go from existing XML 1 (using DTD 1) to generated XML 2 (using DT2). Something that allows me to map the DTD elements and attributes, say, element “A” in XML 1 transforms into element “A1” in XML 2, so it then generates XSL for me. Do you know of any tool that would do that?

Thanks in advance for your time, I really appreciate it


Reply With Quote
  #2 (permalink)  
Old October 17th, 2007, 08:07 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

If its simply a one to one mapping then you can start by specifying the identity template:

<xsl:template match="node()|@*">
   <xsl:apply-templates select="@*"/>

And then defining 'replace' templates:

<xsl:template match="A">
  <xsl:apply-template select="@*"/>

Repeat this for each element that is changed.

I don't know of any products that could do this automatically for you however.

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old October 17th, 2007, 08:21 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Stylus studio has a graphical tool that does this kind of thing, and I think there's something similar in XML Spy as well. In my experience these tools only work well when there is quite a close correspondence between the two DTDs, i.e. when it's mainly a matter of renaming the elements (they can do a lot more than that, but my experience is that it becomes easier to write the code).

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to parse the XML file and DTD tufailfifa XML 0 June 25th, 2007 07:02 AM
Convert DTD to schema boknoy XML 1 March 28th, 2007 03:51 AM
Convert DTD to Schema bcogney XML 7 March 25th, 2007 06:39 PM
XML converter by using own DTD? DorisTan XML 0 January 18th, 2005 09:57 AM
Defining a DTD for an XMl Document boemane C# 0 August 24th, 2004 08:17 AM

All times are GMT -4. The time now is 07:01 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.