OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: XML Document to ascii text file

[ Lists Home | Date Index | Thread Index ]
  • From: "Robert C. Lyons" <boblyons@unidex.com>
  • To: 'Didier PH Martin' <martind@netfolder.com>, 'Mallikarjuna Sangappa' <malliks@rocketmail.com>, "'xml-dev@ic.ac.uk'" <xml-dev@ic.ac.uk>
  • Date: Wed, 9 Jun 1999 08:41:18 -0400

Didier wrote:
	"Can you explain how with just a simple example. ...
	 How would you transform this XML document above into a plain asci text? 
	 Can you show it with a XSL script?"


Oops. I sent that last message too soon.

See below for an example of an XSLT stylesheet that converts an XML document
into a plain ASCII text file. The XML document is not the same as yours,
but it's fairly simple.

Here's the XML document:

<?xml version='1.0' ?>
        <full_name>Nancy Magill</full_name>
        <phone_number>(100) 555-9328</phone_number>
        <full_name>Molly Jones</full_name>
        <phone_number>(200) 555-3249</phone_number>
        <full_name>Penny Lane</full_name>

Here's the XSLT stylesheet that converts the XML document into
an ASCII text file:

<?xml version="1.0"?>
    indent-result="no" default-space="strip">

    <xsl:template match="/contacts/contact">
        <xsl:apply-templates select="full_name"/>
        <xsl:apply-templates select="email_address"/>
        <xsl:apply-templates select="phone_number"/>

    <xsl:template match="full_name">
        <xsl:value-of select="."/>

    <xsl:template match="email_address">
        <xsl:value-of select="."/>

    <xsl:template match="phone_number">
        <xsl:value-of select="."/>


Here is the ASCII text file that is produced by the XSLT processor:

name=Nancy Magill
phone=(100) 555-9328
name=Molly Jones
phone=(200) 555-3249
name=Penny Lane

Hope this helps.


Bob Lyons
EC Consultant
Unidex Inc.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@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@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS