xsl-list
[Top] [All Lists]

Re: [xsl] troff to unicode conversion

2006-09-11 06:58:11

something like this would work I havent quite got the regexp right here
but it should show the idea, which is construct a regexp that matches
any escape sequence then once you find one, look it up in a key
constructed by the mapping table to see what the replacement is.

apply directly to your document (temp3.xml)

David



<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
<xsl:output encoding="US-ASCII"/>

<xsl:variable name="map" select="doc('pvl_mappings.xml')"/>
<xsl:key name="map" match="mapping" use="troff"/>

<xsl:template match="*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="text()">
  <xsl:analyze-string select="." regex=".|\\\*?\(..|\\\*\(K\\\(wi">
    <xsl:matching-substring>
      <xsl:value-of select="(key('map',.,$map)/unicode,.)[1]"/>
    </xsl:matching-substring>
    <xsl:non-matching-substring>
        <xsl:value-of select="."/>
    </xsl:non-matching-substring>
  </xsl:analyze-string>
</xsl:template>

</xsl:stylesheet>

--~------------------------------------------------------------------
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>