Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XPath expressions: Problem with namespaces

From: reyes <reyesvsn@-----.--->
To: NULL
Date: 10/20/2008 3:43:00 AM
Hello everybody,

 I have a question concerning XPath expressions and namespaces.
Consider this XML:

<?xml version="1.0" encoding="UTF-8"?>
<newsMessage  	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:rtr="http://www.reuters.com/ns/2003/08/content"
		xmlns="http://iptc.org/std/nar/2006-10-01/">
	<header>
		<transmitId>LWN_2008-07-26_892</transmitId>
		<priority>4</priority>
		<channel>VID</channel>
	</header>
	<itemSet>
		<!-- ========================================================= -->
		<!-- PRIMARY ITEM : NEP -->
		<packageItem standard="NewsML-G2" standardversion="2.1"
conformance="power"

guid="tag:reuters.com,2008:newsml_WNEI6QNH" version="2" xml:lang="en">
			<!-- ========================================================= -->
			<itemMeta>
				<itemClass qcode="icls:composite"/>
				<versionCreated>2008-07-26T15:55:37Z</versionCreated>
				<fileName>20080726954SP-FRANCE-EVIAN_GOLF.xml</fileName>
				<link rel="irel:prevVersion"

residref="tag:reuters.com,2008:newsml_WNEI6QNH" version="1"

contenttype="application/vnd.iptc.g2.packageitem+xml"
rtr:id="WNEI6QNH" rtr:type="idType:USN"/>
				<rtr:versionedId guid="tag:reuters.com,2008:newsml_WNEI6QNH:2"/>
			</itemMeta>
		</packageItem>
		<!-- ========================================================= -->
		<!-- PRIMARY ITEM : SNI-Text -->
		<newsItem standard="NewsML-G2" standardversion="2.1"
conformance="power"

guid="tag:reuters.com,2008:newsml_WNEI6QNI" version="2" xml:lang="en">
			<itemMeta>
				<itemClass qcode="icls:text"/>
				<versionCreated>2008-07-26T15:55:37Z</versionCreated>
				<fileName>20080726954SP-FRANCE-EVIAN_GOLF.xml</fileName>
				<link rel="irel:prevVersion"

residref="tag:reuters.com,2008:newsml_WNEI6QNI" version="1"

contenttype="application/vnd.iptc.g2.newsitem+xml" rtr:id="WNEI6QNI"
rtr:type="idType:USN"/>
				<rtr:versionedId guid="tag:reuters.com,2008:newsml_WNEI6QNI:2"/>
			</itemMeta>
		</newsItem>
		<!-- ========================================================= -->
		<!-- PRIMARY ITEM : SNI -Video -->
		<newsItem standard="NewsML-G2" standardversion="2.1"
conformance="power"

guid="tag:reuters.com,2008:newsml_LWNEI6Q1CDHNJ" version="1"
xml:lang="en">
			<itemMeta>
				<itemClass qcode="icls:video"/>
				<versionCreated>2008-07-26T15:55:37Z</versionCreated>
				<rtr:versionedId

guid="tag:reuters.com,2008:newsml_LWNEI6Q1CDHNJ:1"/>
			</itemMeta>
		</newsItem>
	</itemSet>
</newsMessage>



  If the "newsMessage" node has the three namespaces (xmlns:xsi,
xmlns:rtr & xmlns), my XPath

expressions like '/newsMessage/header/priority/text()' returns
nothing. But if I delete the third

namespace (xmlns), all my XPath expressions find the nodes and return
the text content except the

expression '/newsMessage/itemSet/packageItem/itemMeta/rtr:versionedId/
@guid' that returns the error:

'Reference to undeclared namespace prefix: 'rtr'.'

  Any ideas about the problem?

  Best regards
  Reyes




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent