Title: Message
From a colleague of mine:
 
I played with this a bit. His XPath, /plm:PLMXML/plm:ManufacturingData/Item/@id, does not work but /plm:PLMXML/plm:ManufacturingData/cME:Item/@id does. From Michael Kay's book:
If a name has no prefix, then its namespace URI is considered to be the default namespace URIin the case of an element name, or a null URI in the case of an attribute name or any other kind of name (such as XSLT variable names and template names). However, within an XPath _expression_, the default namespace URI is never used for unprefixed names, even if the name is an element name.
(Kay, Michael, XSLT Programmer's Reference, 2nd Edition, Wrox Press, 2000, p 66)
So, in the XML file proper, Item has a namespace URI of http://www.plmxml.org/Schemas/PLMXMLcMESchema assigned by the "xmlns=" on the document element. From the last sentence of the quoted paragraph, no namespace URI associated is in the XPath to item because it is unprefixed. Therefore, "" does not match "http://www.plmxml.org/Schemas/PLMXMLcMESchema" and Item is not found.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Thielen
Sent: Tuesday, January 27, 2004 11:30 PM
To: [EMAIL PROTECTED]
Subject: [dom4j-user] namespaces & XPath

Hi;

 

If I have the xml:

 

<?xml version="1.0" encoding="UTF-8" ?>

<plm:PLMXML date="2004-1-18" time="19:6:9" xmlns="http://www.plmxml.org/Schemas/PLMXMLcMESchema" author="infodba" language="en" xmlns:cME="http://www.plmxml.org/Schemas/PLMXMLcMESchema" xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema" schemaVersion="1.0">

<plm:ManufacturingData id="id1">

<Item id="id3"/>

</plm:ManufacturingData>

</plm:PLMXML>

 

 

Why does "/plm:PLMXML/plm:ManufacturingData/Item/@id" not work? I understand it has something to do with namespaces – but what? And what is the solution?

 

Thanks - dave

Reply via email to