ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: A whitespace issue in XML::LibXML
by Petr Pajas other posts by this author
Jul 21 2007 4:10AM messages near this date
view in the new Beta List Site
Re: A whitespace issue in XML::LibXML | Re: A whitespace issue in XML::LibXML
& XSLT On Saturday 21 July 2007, Vaclav Barta wrote:
>  On Saturday 21 July 2007 01:04, Richard E. Rathmann wrote:
>  > > Vaclav Barta schrieb:
>  > >> On Friday 20 July 2007 20:27, Birgit Kellner wrote:
>  > >>> children of the element <span> that can be contained within <seg>.
>  > >>
>  > >> seg/span/text()
>  > >
>  > > Yes, but that wouldn't get me the proper sequence, no?
>  > > Consider:
>  > > <seg>This is <span>a cold breeze</span><note>Oh, and here's some text
>  > > which deals with a completely different subject-matter, say, bunny
>  > > rabbits on a balcony.</note> on an unbearably hot summer evening.</seg>
>  >
>  > Assuming that $seg contains a reference to the "seg" node in the example
>  > above:
>  >
>  > my $seg_text = '';
>  > for my $node ($seg->findnodes('text() | span'))
>  > {
>  >     $seg_text .= $node->findvalue('string(.)');
>  > }
>  >
>  > will produce "This is a cold breeze on an unbearably hot summer
>  > evening."   Is this what you are trying to achieve (or at least steer
>  > you in the right direction)?
>  >
>  > FYI, the 'text() | span' XPath expression above selects just the raw
>  > text node and "span" element children of the "seg" element, skipping the
>  > "note" element children (or any other child nodes, for that matter).  By
>  > combining the two separate relative XPaths "text()" and "span" with an
>  > or operator, findnodes() will return all the nodes in the proper
>  > sequence.
> 
>  I'm not saying it won't, but is it supported usage? I've looked it up
>  yesterday and have been quite surprised to find in
>  http://www.w3.org/TR/xpath that a nodeset is "an unordered collection of
>  nodes without duplicates", as well as quite a few XML geeks pointing out
>  that the rest of the spec pretty much assumes nodes in nodesets are kept in
>  document order. Does XML::LibXML (that is, libxml2) guarantee order?

Yes, in libxml2 nodesets always serialize to nodelists in the document order 
(even for expressions consisting of a reversed axis, e.g. preceding::*).

The only exception is when the nodeset contains nodes from several documents, 
in which case the nodes are returned in document order w.r.t. each single 
document but relative order of nodes belonging to different documents is 
undefined.

-- Petr
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Birgit Kellner
Petr Pajas
Birgit Kellner
A. Pagaltzis
Vaclav Barta
Birgit Kellner
Richard E. Rathmann
Vaclav Barta
Petr Pajas
Vaclav Barta
Mark - BLS CTR Thomas

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved