xsl-list
[Top] [All Lists]

Re: Basic question about Namespace handling in XPath 1.0 (not necessarily related to XSLT)

2005-09-28 07:26:20
Ah, in that case no. As David more or less points out, you have to supply them yourself. Msxml behaves likewise. You might be able to retrieve the mapping from the source tree and pass that to the xpath evaluation, though.

Cheers

Prakash wrote:

Thanks Geert.

My question is not in relation to XSLT. I was talking about the namespace prefix resolution in general for XPath. For example, in Java, JAXP 1.3 has some APIs to process XPath given a context ( likewise DOM Level 3 has some APIs). These APIs are application independent. I guess, the namespace mappings available in scope to the context node will be the deciding factor, right?. Pls, correct me if I am wrong.

Thanks,
Prakash

Geert Josten wrote:

Hi,

The answer should be pretty clear, it all depends on how you declare the namespaces in your XSL stylesheet... :)

1. If we have a XPath like "//sup:name", how will the XPath processor know which "sup:name" will have to be returned? (considering that there are two sup:name elements that are in two different namespaces.



<xsl:value-of select="//sup:name" xmlns:sup="http://www.suppliers.com"; /> will result in the first one.

<xsl:value-of select="//sup:name" xmlns:sup="http://www.anothersuppliers.com"; /> will result in the second one.

You will probably choose to assing prefix sup1 to the first namespace and sup2 to the second. If you want both, you can then simply specify //sup1:name|//sup2:name (or //*:name in XSLT 2.0 altogether)

2. Similarly, if we have a XPath such as "//order", which "order" will be considered considering that there are two order elements both in default namespace (first order element is actually in null namespace whereas the second one in default namespace declared in the root element)



Likewise. I expect that //order results in the first when you don't specify a default namespace, and in the second if you use xmlns="http://www.customers.com";.

It is adviced not to use default namespaces in XSL stylesheets, though.

Cheers,
Geert

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
Drs. G.P.H. Josten
Consultant



Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>