[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to merge translated XML files with the same IDs

Subject: How to merge translated XML files with the same IDs
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Thu, 30 Apr 2009 16:48:57 +0200
 How to merge translated XML files with the same IDs
Dear experts,

There is a XML document instance using unique IDs for internal cross-
references:

<doc language="en">
  <title id="id003">Wonderful World</title>
  <para>...</para>
  <para>... see <xref idref="id003" format="page" />.</para>
</doc>

Now assume this document is translated into many languages and in the
end all those documents should be merged into a single XML document
for publishing.

<book>
  <doc language="en">
  ...
  </doc>
  <doc language="de">
  ...
  </doc>
  <doc language="zh">
  ...
  </doc>
</book>

Since the translators do not touch the IDs we suddenly would have many
duplicate IDs in the document. I already learned the using doc() it is
possible to access XML files with the same IDs, but of course the
resulting document would not be valid against the DTD.

My approach would be to prefix every @id and @idref with the (unique)
@language of the <doc> element like this:

<xsl:template match="@idref | @id">
  <xsl:attribute name="{name()}">
    <xsl:value-of select="concat(ancestor::doc/@language, '_', .)"/>
  </xsl:attribute>
</xsl:template>

Or is there a more elegant way? I will be using XSLT 2.0.

Thanks,

- Michael M|ller-Hillebrand

--
_______________________________________________________________
Michael M|ller-Hillebrand: Dokumentation Technology
Adobe Certified Expert, FrameMaker
Consulting and Training, FrameScript, XML/XSL, Unicode
Blog [de]: http://cap-studio.de/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.