Whitespace added to attributes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Whitespace added to attributes

Kevin Bird-2
Hi

If I transform the below with Saxon 8.6.1 I get addiitonal whitespace
only text nodes appearing between some of the attributes. If I
transform the same files with Saxon 8.4 I do not get the additional
whitespace.

How do I stop the behaviour in 8.6.1?

Thanks
--
Kevin


-----
XML
-----
<holidays>
        <price board="self catering" code="23259" date-id="1" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
        <price board="self catering" code="23259" date-id="2" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
        <price board="self catering" code="23259" date-id="3" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
        <price board="self catering" code="23259" date-id="4" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="Mid">-</price>
</holidays>

-----
XSL
-----
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output indent="yes" method="xml"/>

        <xsl:strip-space elements="*"/>

        <!-- identity template -->
        <xsl:template match="/">
                        <xsl:apply-templates mode="kevin"/>
        </xsl:template>

        <xsl:template match="node()|@*" mode="kevin">
                <xsl:copy>
                        <xsl:apply-templates select="@* | node()" mode="kevin"/>
                </xsl:copy>
        </xsl:template>
</xsl:stylesheet>

-----------------
8.6.1 output
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<holidays>
   <price board="self catering" code="23259" date-id="1" nights="7"
person="adult"
          room="1 bedroom apartment:4 adults sharing"
          season="High">-</price>
   <price board="self catering" code="23259" date-id="2" nights="7"
person="adult"
          room="1 bedroom apartment:4 adults sharing"
          season="High">-</price>
   <price board="self catering" code="23259" date-id="3" nights="7"
person="adult"
          room="1 bedroom apartment:4 adults sharing"
          season="High">-</price>
   <price board="self catering" code="23259" date-id="4" nights="7"
person="adult"
          room="1 bedroom apartment:4 adults sharing"
          season="Mid">-</price>
</holidays>

----------------
8.4 output
---------------
<?xml version="1.0" encoding="UTF-8"?>
<holidays>
   <price board="self catering" code="23259" date-id="1" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
   <price board="self catering" code="23259" date-id="2" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
   <price board="self catering" code="23259" date-id="3" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="High">-</price>
   <price board="self catering" code="23259" date-id="4" nights="7"
person="adult" room="1 bedroom apartment:4 adults sharing"
season="Mid">-</price>
</holidays>


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Whitespace added to attributes

Florent Georges
Kevin Bird wrote:

> If I transform the below with Saxon 8.6.1 I get
> addiitonal whitespace only text nodes appearing
> between some of the attributes.

  So they're not text nodes.  They're not nodes at all.  Just
whitespaces added while serializing the output.  That doesn't change
the output tree.

> <xsl:output indent="yes" method="xml"/>

  If you specify indent="yes" to the serializer, the behaviour you
observed is the correct one.

  Regards,

--drkm






















       

       
               
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Whitespace added to attributes

Michael Kay
In reply to this post by Kevin Bird-2
The whitespace appears between attributes within a start tag, where any XML
parser will ignore it. (It's not a "text node" - it won't even be reported
to applications.) It is added only if you specify indent="yes". The
specification for indent="yes" says that the serializer should output extra
whitespace in order to improve readability by humans, and that wasn't
happening where elements had lots of long attributes (especially for
elements with lots of namespace declarations). I'm sorry you don't find the
change an improvement, but it won't affect the acceptability of the output
document to receiving application. The only way you can switch it off is to
say indent="no".

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Kevin Bird
> Sent: 28 February 2006 14:54
> To: [hidden email]
> Subject: [saxon] Whitespace added to attributes
>
> Hi
>
> If I transform the below with Saxon 8.6.1 I get addiitonal whitespace
> only text nodes appearing between some of the attributes. If I
> transform the same files with Saxon 8.4 I do not get the additional
> whitespace.
>
> How do I stop the behaviour in 8.6.1?
>
> Thanks
> --
> Kevin
>
>
> -----
> XML
> -----
> <holidays>
> <price board="self catering" code="23259" date-id="1" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
> <price board="self catering" code="23259" date-id="2" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
> <price board="self catering" code="23259" date-id="3" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
> <price board="self catering" code="23259" date-id="4" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="Mid">-</price>
> </holidays>
>
> -----
> XSL
> -----
> <?xml version="1.0"?>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output indent="yes" method="xml"/>
>
> <xsl:strip-space elements="*"/>
>
> <!-- identity template -->
> <xsl:template match="/">
> <xsl:apply-templates mode="kevin"/>
> </xsl:template>
>
> <xsl:template match="node()|@*" mode="kevin">
> <xsl:copy>
> <xsl:apply-templates select="@* |
> node()" mode="kevin"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
> -----------------
> 8.6.1 output
> -----------------
> <?xml version="1.0" encoding="UTF-8"?>
> <holidays>
>    <price board="self catering" code="23259" date-id="1" nights="7"
> person="adult"
>           room="1 bedroom apartment:4 adults sharing"
>           season="High">-</price>
>    <price board="self catering" code="23259" date-id="2" nights="7"
> person="adult"
>           room="1 bedroom apartment:4 adults sharing"
>           season="High">-</price>
>    <price board="self catering" code="23259" date-id="3" nights="7"
> person="adult"
>           room="1 bedroom apartment:4 adults sharing"
>           season="High">-</price>
>    <price board="self catering" code="23259" date-id="4" nights="7"
> person="adult"
>           room="1 bedroom apartment:4 adults sharing"
>           season="Mid">-</price>
> </holidays>
>
> ----------------
> 8.4 output
> ---------------
> <?xml version="1.0" encoding="UTF-8"?>
> <holidays>
>    <price board="self catering" code="23259" date-id="1" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
>    <price board="self catering" code="23259" date-id="2" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
>    <price board="self catering" code="23259" date-id="3" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="High">-</price>
>    <price board="self catering" code="23259" date-id="4" nights="7"
> person="adult" room="1 bedroom apartment:4 adults sharing"
> season="Mid">-</price>
> </holidays>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking
> scripting language
> that extends applications into web and mobile media. Attend
> the live webcast
> and join the prime developer group breaking into this new
> coding territory!
> <a href="http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Whitespace added to attributes

Kevin Bird-2
> I'm sorry you don't find the
> change an improvement, but it won't affect the acceptability of the output
> document to receiving application. The only way you can switch it off is to
> say indent="no".

It's not that I don't find the change an improvement, it's just that
it was different to what I was expecting!!

I had made some major changes to a couple of stylesheets and wasn't
sure whether I had introduced whitespace in error.

Thanks for the explanation.

--
Kevin


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help