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

Re: output method (discussion)

Subject: Re: output method (discussion)
From: Denys Duchier <Denys.Duchier@xxxxxxxxxxxx>
Date: 19 Aug 1999 14:16:08 +0200
latex escape char
vidarg@xxxxxx (Vidar B. Gundersen) writes:

> What if I use XSLT to write LaTeX code? In that case, I need to handle
> the reserved charactes by escaping them:
>     $ & % # _ { } ~ ^ \
> So if the converter (might be the XSLT engine) encounter an &amp;
> (XML) it should not write & (text), but something like {\&}.
> 
> What is a good way of handling this?

I have to deal with precisely this issue of converting XML documents
into LaTeX.  XT supports an additional output method xt:nxml, but I
have found it to be insufficiently flexible for defining escaping
policies for LaTeX output.  Fortunately, XT makes it possible to
define your own output handler and that's what I have done - I call it
MapOutputHandler.  Code and documentation can be obtained from:

                http://www.ps.uni-sb.de/~duchier/xsl/

The idea, in a nutshell, is to allow you to define named escape maps
and to select them by name.

        <define name="latex.text">
          <escape char="$">\escDollar </escape>
          <escape char="&amp;">\escAmp </escape>
          ...
          <escape char="&#10;"> \escNone
</escape>
        </define>

Note that it is important to escape newlines since two in a row
otherwise mean \par; however, you should not remove them from the
input because otherwise you get very long lines that exceed TeX's
input buffer.  You might define similar maps for code elements.
For index elements that translate into \index{...} commands, you need
to be somewhat more careful since \index commands give special meaning
to certain characters that need to be quoted using a different
mechanism, i.e. by prefixing with character `"'.

        <define name="index.text">
          <include name="latex.text"/>
          <escape char='"'>""</escape>
          ...
        </define>

Since you typically want to process the content of index elements
using the same templates as for the rest of your document, but using
more restrictive escaping policies, you can temporarily alias one
policy to another:

        <alias name="latex.text" to="index.text">
          <alias name="latex.code" to="index.code">
            ...
          </alias>
        </alias>

Hope this helps.
Cheers,

-- 
Dr. Denys Duchier			Denys.Duchier@xxxxxxxxxxxx
Forschungsbereich Programmiersysteme	(Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45	http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50			Phone: +49 681 302 5618
66041 Saarbruecken, Germany		Fax:   +49 681 302 5615


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.