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

Re: Effects of white space between xml elements

Subject: Re: Effects of white space between xml elements
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Tue, 24 Feb 2009 00:16:21 +0100
Re:  Effects of white space between xml elements
<xsl:for-each select="child::*"> does what you want.

"child::node()" matches the (white space) text nodes in addition.


Mit besten Gr|_en / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschdftsf|hrung: Erich Baier
Sitz der Gesellschaft: Bvblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



             Nat Wilson
             <beltramie@gmail.
             com>                                                       To
                                       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
             02/23/2009 11:32                                           cc
             PM
                                                                   Subject
                                        Effects of white space
             Please respond to         between xml elements
             xsl-list@xxxxxxxx
              lberrytech.com








Does white space between elements of an xml document effect the output
of a transformation of that document?  I noticed that sometimes adding
a new line in between the closing tag of one element and the opening
tag of the next element changes my output, even though I am working
with the same stylesheet.

I thought that white space in an XML document was ignored during the
transformation; that the only thing that will effect the output are
the on/off tags and how they are nested in each other.  If tags are
nested properly, shouldn't white space and new lines in between
elements be irrelevant?

Here is an example of what I mean.

Stylesheet element I am using:

    <xsl:template match="HERB/actions">
        <p></p>
        <xsl:text>Effects: </xsl:text>
        <xsl:for-each select="child::node()">
            <xsl:apply-templates/>
            <xsl:text>, </xsl:text>
        </xsl:for-each>
        <xsl:text>.</xsl:text>
    </xsl:template>

2 inputs Im using with this stylesheet, only different in their
spacing between elements:

Input 1:

<chemistry><activeIngredient>Coniine</activeIngredient></chemistry>

<actions><effect>antispasmodic</effect><effect>sedative</effect><effect>poiso
n

antidote</effect></actions>

Output 1:

 "Effects: antispasmodic, sedative, poison antidote,"

Input 2 (has new lines separating the <effect> elements but nested the
same>

<chemistry><activeIngredient>Coniine</activeIngredient></chemistry>
    <actions>
        <effect>antispasmodic</effect>
        <effect>sedative</effect>
        <effect>poison antidote</effect>
    </actions>

Output 2:

"Effects: , antispasmodic, , sedative, , poison antidote, ,"

Why would it add this extra comma in the output list?  Is it that I am
writing the xsl element incorrectly?  Is there some aspect of XML that
I am totally missing?  And if so, are there other times that the
output can be different due to more/less white space between elements?

Thanks,

Nat Wilson
Environment
Transformer Saxon 6.5.5
Run with oXygen 10.0
xml version="1.0" encoding="UTF-8"



--
Nat

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.