[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: Nat Wilson <beltramie@xxxxxxxxx>
Date: Fri, 6 Mar 2009 00:09:00 -0600
Re:  Effects of white space between xml elements
Thanks a lot for all your suggestions.  If I am interpreting what you
all are saying right, white space is handled differently depending on
a few factors. 1) the transformer can follow different rules 2) the
stylesheet can have rules that tell the transformer specifically how
and when to handle white space.

Ill try some of these rules out and see what the results are, thanks
for the help everyone.

Nat

On Mon, Feb 23, 2009 at 4:32 PM, Nat Wilson <beltramie@xxxxxxxxx> wrote:
> 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>pois
on
> 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
>



--
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-2011 All Rights Reserved.