xsl-list
[Top] [All Lists]

[xsl] merge translated text into English structure (similar but not identical)

2009-03-17 13:49:48
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 más 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 más 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] merge translated text into English structure (similar but not identical), Hoskins, Dorothy [OCDUS Non J&J] <=