Subject: Re: [xsl] how to extract text, translate and re-insert it in XHTML From: Evan Lenz <evan@xxxxxxxxxxxx> Date: Wed, 07 Jan 2009 12:48:41 -0800 |
<xsl:template match="/"> <translator-inputs> <xsl:apply-templates/> </translator-inputs> </xsl:template>
<!-- Ignore whitespace-only text --> <xsl:template match="text()"/>
<xsl:template match="text()[normalize-space()]"> <to-translator> <xsl:copy/> </to-translator> </xsl:template>
<translator-inputs> <to-translator>Hello this is </to-translator> <to-translator>bold</to-translator> <to-translator>. This is </to-translator> <to-translator>italic</to-translator> <to-translator>.</to-translator> </translator-inputs>
<translator-inputs> <to-translator>Hello this is </to-translator> <to-translator>bold</to-translator> <to-translator sentence-boundary="yes>This is </to-translator> <to-translator>italic</to-translator> <to-translator sentence-boundary="yes"/> </translator-inputs>
<results> <from-translator>Olleh siht si </from-translator> <from-translator>dlob</from-translator> <from-translator sentence-boundary="yes">Siht si </from-translator> <from-translator>cilati</from-translator> <from-translator sentence-boundary="yes"/> </results>
<!-- By default, copy everything unchanged. --> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template>
it's been a while since i've written anything in XSLT so i'm going to try to explain what a colleague is trying to do, assuming *i* understand it.
1) start with an involved XHTML document 2) "extract" just those (english) parts that involve translatable text, and hand it to a translator 3) translator translates english to, say, klingon 4) rebuild original document with klingon content instead of english
as i understand it, the point of the extraction is that no one wants to burden the translator with all of the XHTML tagging -- the translator wants to get the text stripped of all the "clutter", at which point, after translation, someone needs to be able to put the document back together.
is this even a reasonable thing to ask? in order to reassemble the document, i'm assuming one is going to have to ID every single bit of text to have a reference to build backwards.
thoughts on this? has anyone done something like this? or are you all too busy laughing hysterically by now?
rday
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] how to extract text, translat, Robert P. J. Day | Thread | Re: [xsl] how to extract text, tran, Ken Starks |
[xsl] how to extract text, translat, Robert P. J. Day | Date | Re: [xsl] Remove a number at the be, Graeme Kidd |
Month |