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

Re: troff to unicode conversion

Subject: Re: troff to unicode conversion
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 11 Sep 2006 14:57:58 +0100
Re:  troff to unicode conversion
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>

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