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

Re: XPath search problem

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

Re:  XPath search problem
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]


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-2011 All Rights Reserved.