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]
XPath and prefix bindings

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


[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