XML Document to ascii text file
G. Ken Holman
gkholman at CraneSoftwrights.com
Tue Jun 15 09:14:56 BST 1999
At 99/06/08 14:17 -0400, Didier PH Martin wrote:
>Can you explain how with just a simple example. Let's say the XML document
>is:
>
><document>
><title>
> This is the title
></title>
><par>
>One upon a time...
></par
></document>
>
>How would you transform this XML document above into a plain asci text? Can
>you show it with a XSL script?
A set of "plain ASCII text" semantics has been implemented in XT under the
namespace URI "java:com.jclark.xsl.sax.NXMLOutputHandler".
Using this set of semantics I have created XSL scripts that generate MSDOS
batch files and other text files. These semantics provide for emitting
characters such as "&" and "<" in a clear form (very helpful when writing
batch files with input redirection). It also gives control over the
emitted character encoding so that single-character accented letters can be
output without having them be two-character UTF-8 encodings. For these
reasons, I feel James' NXML meets a need not met just by using a text
subset of an output XML file.
For example, using your document above I have a session below that attempts
to illustrate what can be done.
James has some documentation in his http://www.jclark.com/xml/xt.html file.
It happens this is also covered briefly with another example in a chapter
of my XSL training material included in my free preview excerpt (the first
three chapters) available from our web site ... it is a free excerpt of:
Introduction to XSLT (XSL Transformations)
Third Edition - 1999-06-08 - ISBN 1-894049-00-4
Copyright (C) 1999 Crane Softwrights Ltd.
http://www.CraneSoftwrights.com/x/
205 Pages / $40.00 US dollars / Includes free updates
I have received requests to add more detail to the documentation for this
non-XML (NXML) environment, so that will be made available in a future
edition (all future editions are available at no charge to all existing
customers).
I hope this helps.
.............. Ken
T:\didier>type test.xml
<?xml version="1.0"?>
<document>
<title>
This is the title
</title>
<par>
One upon a time...
</par>
</document>
T:\didier>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns="java:com.jclark.xsl.sax.NXMLOutputHandler"
result-ns="">
<xsl:template match="text()"/>
<xsl:template match="/">
<nxml encoding="Latin1">
<data><xsl:apply-templates/></data>
</nxml>
</xsl:template>
<xsl:template match="title">
<char number="60"/>
<char number="60"/>
<char number="60"/>TITLE<char number="62"/>
<char number="62"/>
<char number="62"/><xsl:value-of select="."/>
</xsl:template>
<xsl:template match="par">
<xsl:text>
</xsl:text>
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
T:\didier>call xsl test.xml test.xsl test.txt
T:\didier>type test.txt
<<<TITLE>>>
This is the title
One upon a time...
T:\didier>
--
G. Ken Holman mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services outline, XSL/DSSSL shareware,
stylesheet resource library, conference training schedule,
commercial stylesheet training materials, on-line XSL CBT.
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list