[Home] [By Thread] [By Date] [Recent Entries]

  • From: Philippe Poulard <philippe.poulard@s...>
  • To: "Marshall, Steven (SKM)" <SMarshall@s...>
  • Date: Mon, 11 Feb 2008 10:53:05 +0100

Hi,

Marshall, Steven (SKM) a écrit :
> I'm having a problem getting a .NET XMLDocument to give me back the set
> of nodes I want.  The relevant code looks like this:
>  
> Dim nl as XMLNodelist
> Dim nsm as XMLNamespaceManager
>  
> nl=xDoc.SelectNodes("//codelistItem/CodeListDictionary[@gml:id='Language
> Code']/codeEntry", nsm)
>  
> I have created the NamespaceManager and added to it every namespace
> mentioned in the XML document.  

In your XML document, there is a default namespace URI which is applied 
to all unprefixed elements (in the scope). With XPath, unprefixed 
elements have no namespace URI, so you have to bound them to the 
expected namespace URI by using the prefix of your choice ; you should 
have something like this :

nsm.declare( "GMX", "http://www.isotc211.org/2005/gmx" )
.../...
nl=xDoc.SelectNodes("//GMX:codelistItem/GMX:CodeListDictionary[@gml:id='Language 
Code']/GMX:codeEntry", nsm)

The different behaviour you noticed is certainly due to the tool that 
likely uses XPath 2 (unlike XPath 1 you can set a default namespace URI 
that applies to unprefixed elements with XPath 2) whereas your processor 
uses XPath 1.

The other workaround would be to configure your XPath processor to be 
compliant to XPath 2

> 
> <?xml version="1.0" encoding="UTF-8"?>
> <CT_CodelistCatalogue xmlns="http://www.isotc211.org/2005/gmx"
                         ^^^^^

>   xmlns:gco="http://www.isotc211.org/2005/gco"
> xmlns:gml="http://www.opengis.net/gml"
>   xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://www.isotc211.org/2005/gmx ../gmx/gmx.xsd
> http://www.isotc211.org/2005/gco ../gco/gco.xsd
> http://www.opengis.net/gml ../gml/gml.xsd http://www.w3.org/1999/xlink
> ../xlink/xlinks.xsd">
> 

-- 
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !


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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member