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

Re: XPath and prefix bindings

  • From: Jeff Greif <jgreif@alumni.princeton.edu>
  • To: Fraser Goffin <goffinf@gmail.com>
  • Date: Wed, 15 Aug 2012 17:48:50 -0700

Re:  XPath and prefix bindings
I wrote the two paragraphs, based on my understanding.  I have no
citation for this information and which processors it applies to, but
I'm pretty sure it describes Xalan's XPath evaluation methods and XSLT
in general.

The XPath can only be applied *correctly* if all the namespace prefixes
in it are bound, but perhaps if some prefix has no binding in scope it
is bound to the null namespace, rather than there being some kind of
error generated.  This would be easy to test in any processor.

Jeff

On 8/15/2012 3:28 PM, Fraser Goffin wrote:
> Jeff,
> 
> I agree. So from that I would assume that neither XMLSpy nor any of
> the other online Xpath evaluators were actually providing the complete
> set of prefix bindings prior to evaluation of the expression (except
> for those declared on the root element). Certainly if I was writing
> code to consume this XML and apply XPath expression to it I would need
> to provide the bindings apriori.
> 
> Incidentally where did those two paragraphs come from ?
> 
> Fraser.
> 
> On 15/08/2012, Jeff Greif <jeff.greif@gmail.com> wrote:
>> I believe the following describes how namespaces are used in XPath
>> application.
>>
>> Essentially, a dictionary of prefix -> namespace pairs must be available
>> for all the prefixes used in the XPath prior to application of the XPath
>> to a particular node in the document.  This dictionary may come from the
>> prefix -> namespace pairs in scope at that context node, or be provided
>> by the code that applies the XPath.
>>
>> The prefixes used in the XPath may be considered to have been replaced,
>> before the XPath is applied to the document, by the corresponding
>> namespaces, and have no relation to the prefixes used in the document.
>> Then when a node is matched against a step in the XPath, the namespace
>> for the XPath step is matched against the namespace to which the
>> namespace prefix in the document resolves.
>>
>> Jeff
>>
>>
>> On 8/15/2012 1:01 PM, Fraser Goffin wrote:
>>> Thanks Andrew, you're right I did miss the NS1 declaration on the
>>> Evens element, however even when added I still get the sa me error ?
>>>
>>> Fraser.
>>>
>>> On 15 August 2012 19:44, Andrew Welch <andrew.j.welch@gmail.com> wrote:
>>>>> <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 however I add the declaration for NS1 to the root element the XPath
>>>>> locates the node with no problem
>>>>
>>>>> What am I mis-understanding here ?
>>>>
>>>> It's not namespace well formed because the NS1 prefix on Evens isn't
>>>> mapped... as you say moving the declaration so that it's in scope for
>>>> NS1:Evens fixes the problem.
>>>>
>>>>
>>>> --
>>>> Andrew Welch
>>>> http://andrewjwelch.com
>>>
>>> _______________________________________________________________________
>>>
>>> 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
>>>
>>>
>>
>>
> 
> _______________________________________________________________________
> 
> 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.