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

Re: Query re XMLSpy XPath engine

Subject: Re: Query re XMLSpy XPath engine
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 22 Jul 2002 08:21:40 -0700 (PDT)
xmlspy xpath namespace
> --- Elliotte Rusty Harold <elharo at metalab dot unc dot edu> wrote:
> 
> > 
> > At 1:23 PM +1000 7/22/02, Michael Leditschke wrote:
> > 
> > I have the following document
> > 
> > <root xmlns:html="http://www.w3.org/1999/xhtml";
> > xmlns="http://www.a.com";>
> >   <hr xmlns="http://www.w3.org/1999/xhtml"/>
> > </root>
> > 
> > Using the inbuilt XPath engine in XMLSpy 4.4, I
> > issue the following XPath query
> > 
> > //hr
> > 
> > It returns the hr element.
> > 
> > If I try
> > 
> > //html:hr
> > 
> > nothing is returned.
> > 
> > This seems the wrong way around to me. Have
> > I missed something?
> > 
> > 
>  Yes. Your hr element is in the http://www.a.com namespace, not the
>  http://www.w3.org/1999/xhtml namespace. So ion the second case
> XMLSpy
>  is correct.
>  
>  However, in the first case, XMLSpy is incorrect. //hr requests an hr
>  element in no namespace because the default namespace never applies
>  in
>  an XPath expression. Thus, //hr should return an empty node-set.
>  --
>  
> 
>
+-----------------------+------------------------+-------------------+
>  | Elliotte Rusty Harold | elharo@xxxxxxxxxxxxxxx | Writer/Programmer
>  |
> 
>
+-----------------------+------------------------+-------------------+
>  | XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
>  | http://www.cafeconleche.org/books/xian2/ |
>  | http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
> 
>
+----------------------------------+---------------------------------+
>  


XMLSpy is incorrect ***in both cases***.

   <hr xmlns="http://www.w3.org/1999/xhtml"/>

The above "hr" element is in the namespace
"http://www.w3.org/1999/xhtml", which overrides the previous default
namespace.

According to the spec 
(http://www.w3.org/TR/REC-xml-names/#scoping-defaulting):

"5.2 Namespace Defaulting
A default namespace is considered to apply to the element where it is
declared (if that element has no namespace prefix)"

As Jeni noted, the result of the evaluation of "//html:hr" will depend
on whether the "html" prefix has been declared at the current context
when the evaluation is performed.

As the "html" prefix is specified on the top element of the xml
docoment, the evaluation of "//html:hr" must be return the element:

<hr xmlns="http://www.w3.org/1999/xhtml"/>


Hope this helped.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.