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

Fwd: XPath and prefix bindings

  • From: Fraser Goffin <goffinf@gmail.com>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Thu, 16 Aug 2012 00:05:18 +0100

Fwd:  XPath and prefix bindings
Arrggghh, missed the XML-dev address off.

---------- Forwarded message ----------
From: Fraser Goffin <goffinf@gmail.com>
Date: Thu, 16 Aug 2012 00:04:10 +0100
Subject: Re:  XPath and prefix bindings
To: Michael Kay <mike@saxonica.com>

Indeed, and it would appear from the small number of tests I have done
that not all of the prefix bindings are made available to the XPath
evaluation, although some are (certainly those declared on the
starting element which may/may not be the document root). This wasn't
really a question about XMLSpy or any other tool per se, it was more
about whether I was misunderstanding something fundamental about
Xpaths that include prefixes. What has turned up is that it's really
about at what point the prefixes are resolved and thus accessible to
the Xpath processing.

Since David brought XSLT up earlier, What does Saxon do iro namespace binding ?

Fraser

On 15/08/2012, Michael Kay <mike@saxonica.com> wrote:
>
> Just because the prefixes are declared in the source document doesn't
> mean that they are declared in the static context of your XPath
> expressions. Tools such as XML Spy do try to be helpful by copying the
> source document namespace bindings to the Xpath context, but to find out
> exactly what XML Spy does, you will need to consult its documentation
> (I'm being a little optimistic there, I know...)
>
> Michael Kay
> Saxonica
>
> On 15/08/2012 18:53, Fraser Goffin wrote:
>> Here's something I *thought* I understood, but now I'm not so sure ?
>>
>> Below is an XML instance that includes two namespace prefixes bound to
>> the same namespace (dis and NS1) :-
>>
>> <dis:Numbers xmlns:dis="urn:numbers">
>> 	<NS1:Odds xmlns:NS1="urn:numbers">
>> 		<NS1:One>1</NS1:One>
>> 		<NS1:Three>3</NS1:Three>
>> 		<NS1:Five>5</NS1:Five>
>> 	</NS1:Odds>
>> 	<NS1:Evens>
>> 		<NS1:Two>2</NS1:Two>
>> 		<NS1:Four>4</NS1:Four>
>> 		<NS1:Six>6</NS1:Six>
>> 	</NS1:Evens>
>> </dis:Numbers>
>>
>> If I use this XPath, I expected it to locate the element 'One' :-
>>
>> /dis:Numbers/NS1:Odds/NS1:One
>>
>> however in XMLSpy (I know this has some quirks) I get :-
>>
>> 'Invalid namespace prefix when using XPath 1' (or 'Undefined namespace
>> prefix 'NS1' if I try using XPath 2)
>>
>> Hmmmm ..... I *thought* NS1 would be in scope for evaluating the
>> NS1:Odds location step since it is declared on that node ?
>>
>> I tried the same thing using various on-line XPath evaluators with
>> pretty much the same result ?
>>
>> If however I add the declaration for NS1 to the root element the XPath
>> locates the node with no problem
>>
>> <dis:Numbers xmlns:dis="urn:numbers" xmlns:NS1="urn:numbers">
>> 	<NS1:Odds xmlns:NS1="urn:numbers">
>> 		<NS1:One>1</NS1:One>
>> 		<NS1:Three>3</NS1:Three>
>> 		<NS1:Five>5</NS1:Five>
>> 	</NS1:Odds>
>> 	<NS1:Evens>
>> 		<NS1:Two>2</NS1:Two>
>> 		<NS1:Four>4</NS1:Four>
>> 		<NS1:Six>6</NS1:Six>
>> 	</NS1:Evens>
>> </dis:Numbers>
>>
>> What am I mis-understanding here ?
>>
>> Regards
>>
>> Fraser
>>
>> _______________________________________________________________________
>>
>> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
>> to support XML implementation and development. To minimize
>> spam in the archives, you must subscribe before posting.
>>
>> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
>> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
>> subscribe: xml-dev-subscribe@lists.xml.org
>> List archive: http://lists.xml.org/archives/xml-dev/
>> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>>
>>
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.