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

RE: Can grouping here the solution ?

Subject: RE: Can grouping here the solution ?
From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx>
Date: Tue, 22 Nov 2011 16:08:05 +0000
RE:  Can grouping here the solution ?
I find it helpful to consider that from XSLT's point of view, everything in an
XML document is a node. :)

If you have:

<page>page <!-- was 2 now changed-->1</page>

Then the content of <page> is the following sequence:

1. text()[1] = "page "
2. comment() = "was 2 now changed"
3. text()[2] = "1"

page/text() is therefore a set of text()[1] and text()[2]



-----Original Message-----
From: Echlin, Robert [mailto:Robert.Echlin@xxxxxxxxxxxxx]
Sent: 22 November 2011 15:53
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Robby Pelssers
Subject: RE:  Can grouping here the solution ?

Wow.
I would have thought that "text()" would return the text, not a sequence of
nodes.
That's really counter intuitive.
Rob


-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Tuesday, November 22, 2011 5:22 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Robby Pelssers
Subject: Re:  Can grouping here the solution ?

On 21/11/2011 18:10, Robby Pelssers wrote:
> Ok Ken, thx for the advice.  I actually never used to do so but at
> some point in time I figured it would express more clearly the
> intent. I guess I should just always assume this by default to safe
> on typing.




actually using text() makes your code more fragile. If the input has any
comments for example:

<page>page <!-- was 2 now changed-->1</page>

page has string value "page 1" so will work as expected if selected with
an xpath of page but page/text() selects a sequence of two text nodes
with values "page " and "1" which will either do the wrong thing, or
generate an error, depending on how its used.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

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.