XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Fwd: [xml-dev] XPath and prefix bindings

---------- Forwarded message ----------
From: Dimitre Novatchev <dnovatchev@gmail.com>
Date: Wed, Aug 15, 2012 at 4:27 PM
Subject: Re: [xml-dev] XPath and prefix bindings
To: Fraser Goffin <goffinf@gmail.com>


What is the hosting language (such as C#, Java, PHP, ..., etc) in
which you are evaluating the XPath expressions?

You need to "register" the namespaces (the bindings (prefix,
namespace-uri)+) and then you can use any of the registered prefixes
in an XPath expression and its evaluation.

The rules for registering namespaces are different for different
hosting languages/environments.


Cheers,
Dimitre.

On Wed, Aug 15, 2012 at 10:53 AM, Fraser Goffin <goffinf@gmail.com> 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
>



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.


-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.


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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS