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

merge translated text into English structure (similar

Subject: merge translated text into English structure (similar but not identical)
From: "Hoskins, Dorothy [OCDUS Non J&J]" <DHoskins@xxxxxxxxxxx>
Date: Tue, 17 Mar 2009 13:49:18 -0400
 merge translated text into English structure (similar
HI,
With Saxon 8, XSLT 2.0 in use, I can get a merge process to work pretty well
using examples that I found online (thanks to all of you who posted on merging
files). But I have hit a snag on the best way to handle the mixed-content
elements, where if English has child elements that don't appear in the
translation, I would like to go ahead and poke in the translated text for the
element, and generate a comment about the missing children in the matching
location in the translated file ($doc2). Knowing that it is hard to understand
without examples, here is my sample content:

English (note the <b> elements in the <p>):
<section>
<p otherprops="purpose">Use the screen to access <b>M</b>echanism
<b>E</b>xercise <b>D</b>iagnostics for the Supply.</p>
<fig outputclass="sidebar">
<p product="FIS"><xref href="../docs/RefGuide/Centers/MicroIA_Center.xml">Tell
me more about Supply</xref></p>
</fig>
</section></

Translation:
<section>
<p otherprops="purpose">Utilice la pantalla Tambor para acceder a los MEDs del
tambor.</p>
<fig outputclass="sidebar">
<p product="FIS"><xref href="dummy.xml">Para saber mas sobre el
tambor</xref></p>
</fig>
</section>

Desired output:
<section>
<p otherprops="purpose">Utilice la pantalla Tambor para acceder a los MEDs del
tambor.<!-- missing child b --><!-- missing child b --><!-- missing child b
--></p>
<fig outputclass="sidebar">
<p product="FIS"><xref href="../docs/RefGuide/Centers/MicroIA_Center.xml">Para
saber mas sobre el tambor </xref></p>
</fig>
</section>

Partial XSLT (already have loaded translated file as $doc2, and have passed
through the <section> element:
<xsl:template match="p">
	<xsl:variable name="transText"><xsl:value-of select="$doc2//*[saxon:path() =
current()/saxon:path()]/." /></xsl:variable>
        <xsl:element name="p">
			<xsl:copy-of select="@*"/>
				<xsl:choose>
					<xsl:when test="child::*"><!-- what test to use, how to handle mixed
content and output comments when structure in doc2 doesn't match?
--></xsl:when>
					<xsl:otherwise><xsl:value-of select="$transText" /></xsl:otherwise>
				</xsl:choose>
        </xsl:element>
</xsl:template>

Thanks, Dorothy

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-2011 All Rights Reserved.