Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] AltovaXML and fragment id, Michael Ludwig | Thread | [xsl] ExtendedData from KML, Alan Hale |
Re: [xsl] AltovaXML and fragment id, David Carlisle | Date | [xsl] ExtendedData from KML, Alan Hale |
Month |