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

RE: XML Document to ascii text file

  • From: "G. Ken Holman" <gkholman@C...>
  • To: XML-Dev Mailing list <xml-dev@i...>
  • Date: Mon, 14 Jun 1999 15:26:09 -0700

xslt transform to text file
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>&#xa;</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@C...
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@i...
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@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.