Hi Sergey,

Xalan's is correct.   Here's the definition of the name() function from the
XPath recommendation:

   The name function returns a string containing a QName representing the
   expanded-name of the node in the argument node-set that is first in
   document order.

In your document, the <btw> element node is the first node in document
order.  Perhaps you are thinking this is an existential quantification test
(meaning that _some_ node in the node set has the name 'u'), or perhaps
you're thinking that because preceding-sibling is a reverse axis, that <u>
is the first element node in the node-set?  Neither is the case.  Here are
some variations you can try which might help to explain this more clearly:

   "//child[name(preceding-sibling::*)='btw']"

   "//child[name(preceding-sibling::*[1])='u']"

   "//child[preceding-sibling::u]"

If you have more questions, you should consider subscribing to and posting
to the Mulberry XSL list.  It's the best resource available for general
XPath and XSLT questions.

I have no idea what XSLT or XPath processor you're using with XMLSpy, but I
tested with Xalan 1.3+, Saxon 6.5.1, and MSXSL 3.0 and all produce the same
result.  Perhaps this is a bug in XMLSpy.

Dave



|---------+--------------------------->
|         |           "Sergey         |
|         |           Petrunia"       |
|         |           <[EMAIL PROTECTED]|
|         |           >               |
|         |                           |
|         |           04/12/2002 12:51|
|         |           PM              |
|         |           Please respond  |
|         |           to xalan-dev    |
|         |                           |
|---------+--------------------------->
  
>---------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                       |
  |        To:      <[EMAIL PROTECTED]>                                         
                                       |
  |        cc:      (bcc: David N Bertoni/Cambridge/IBM)                               
                                       |
  |        Subject: A Xalan-C bug?                                                     
                                       |
  
>---------------------------------------------------------------------------------------------------------------------------|



Hello,
 I am using latest Xalan-C and probably have found a bug.

Consider the xml file:
---test.xml---
<?xml version="1.0" encoding="UTF-8"?>
<root>
             <ex1>
                         <btw>btw node text</btw>
                         <u>u node text</u>
                         <child>child node text</child>
             </ex1>
</root>
---end of test.xml---

I've tried to select all "child" nodes that have "u" nodes among
preceding siblings and came up with the following xpath expression:
 //child[name(preceding-sibling::*)='u']

But SerializeNodeSet gives no matches for that expression:

SerializeNodeSet.exe test.xml /
"//child[name(preceding-sibling::*)='u']"

Warning: No nodes matched the location path
"//child[name(preceding-sibling::*)='u']".

Further expirements show that "child" node is returned only if "u" node
is the first sibling.
I've also tried this xpath expression in XML Spy and it yields the
"child" node no matter if "u" node is first sibling or not.

Is this a Xalan bug or XML Spy bug or what?

BR
--Sergey Petrunia






Reply via email to