[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] General rule for designing XPath expressions to return items in document order?


Subject: Re: [xsl] General rule for designing XPath expressions to return items in document order?
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Thu, 9 Jan 2014 11:13:59 -0000 (GMT)

On Thu, January 9, 2014 10:51 am, Costello, Roger L. wrote:
> I applied this XPath expression
>
> 	//head
>
> to this XML document
>
> <Document>
>     <head>
>         <head>B</head>
>         A
>     </head>
> </Document>
>
> using oXygen (where SAXON is the XPath processor) and got these results:
>
> A
> B
>
> That is, the results are in non-document order.

Your reported results don't match your XPath applied to your document, but
the order of the <head> containing 'A' (ignoring the child <head>) then
the <head> containing 'B' is document order because the <head> containing
'A' starts before the <head> containing 'B'.

If you selected text nodes (and ignored all white-space), then 'B' would
come before 'A'.

Your reported results don't match your XPath applied to your document
since the first <head> is:

<head>
        <head>B</head>
        A
     </head>

with a string value ignoring, rather than just normalising, white-space
(if that's what you were reporting) of 'BA'.

Regards,


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C


Current Thread
Keywords