p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Automated tool to convert XML from DTD to DTD (http://p2p.wrox.com/showthread.php?t=62963)

lsantos2000 October 17th, 2007 08:00 AM

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


samjudson October 17th, 2007 08:07 AM

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 -/

mhkay October 17th, 2007 08:21 AM

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

All times are GMT -4. The time now is 03:07 PM.

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