[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: How to select nodes with explicitly set default n
Subject: RE: How to select nodes with explicitly set default namespace - DOM4J
From: "Barbara Worwood" <bworwood@xxxxxxxxxxxxx>
Date: Thu, 24 Mar 2005 09:46:32 -0000
|
The elements are not bound to any namespace prefix - as you can see from the
example, so a default namespace of null or "" is used. The namespace
"urn:hl7-org:v3" has no prefix, so the sub elements do not need the prefix,
how to I access such elements in code??
<PRSC_IN080000UK06 xmlns="urn:hl7-org:v3"
<device>
<id root="2.16.840.1.113883.2.1.3.2.4.10" extension="RJR-0000217" />
</device>
</PRSC_IN080000UK06>
Subject: RE: How to select nodes with explicitly set default
namespace - DOM4J
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 23 Mar 2005 15:54:31 -0000
In XPath 1.0, if you want to select an element that's in a namespace, you
need to bind a prefix to that namespace and use a prefixed QName in the path
expression. The fact that the namespace is the default namespace in the
source document makes no difference.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Barbara Worwood [mailto:bworwood@xxxxxxxxxxxxx]
Sent: 23 March 2005 15:26
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: How to select nodes with explicitly set
default namespace - DOM4J
Hi,
I am having a problem selecting nodes that are part of a
default namespace.
The xml format cannot be modified as it is part of an NHS UK standard.
For Example: xmlns=="urn:hl7-org:v3" is the default
namespace, though a
call to selectSingleNode from the root element will not
return anything for
me. See code below...
==============================================================
=========
==============================================================
=========
<?xml version="1.0" encoding="UTF-8" ?>
<!-- The element below is the content of the first payload
container -->
<PRSC_IN080000UK06 xmlns="urn:hl7-org:v3"
xmlns:fo="http://www.w3.org/1999/XSL/Format";
xmlns:voc="urn:hl7-org:v3/voc"xmlns:xsi="http://www.w3.org/200
1/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3../Schemas/PRSC_IN080000UK06.xsd">
<id root="A6C66142-1DD1-11B2-9062-8F5E91AA2DD7"/>
<creationTime value="20040913030014" />
<versionCode code="V3NPfIT2.0" />
<interactionId root="2.16.840.1.113883.2.1.3.2.4.12"
extension="PRSC_IN080000UK06" />
<processingCode code="P" />
<processingModeCode code="T" />
<acceptAckCode code="NE" />
<communicationFunctionRcv>
<device>
<id root="2.16.840.1.113883.2.1.3.2.4.10" extension="RJR-0000217" />
</device>
</communicationFunctionRcv>
<communicationFunctionSnd>
<device>
<id root="2.16.840.1.113883.2.1.3.2.4.10" extension="T141A-0000202" />
</device>
</communicationFunctionSnd>
<ControlActEvent>
<subject>
<RequestAvailableSlots classCode="SPLY" moodCode="RQO">
<id root="A6C66142-1DD1-11B2-9062-8F5E91AA2DD7" />
<effectiveTime>
<low value="200411090000" inclusive="true" />
<high value="200412100000" inclusive="false" />
</effectiveTime>
<location typeCode="LOC">
<clinic classCode="SDLOC">
<id root="2.16.840.1.113883.2.1.3.2.4.2" extension="DAVID"
displayable="true" />
</clinic>
</location>
</RequestAvailableSlots>
</subject>
</ControlActEvent>
</PRSC_IN080000UK06>
==============================================================
=========
==============================================================
=========
/* Code */
InputStream is =
CabCfg.class.getClassLoader().getResourceAsStream("testdoc.xml"); //
testdoc.xml is doc above
Document doc = new SAXReader().read(is);
Element el = doc.getRootElement();
el.add(new Namespace("", "urn:hl7-org:v3"));
Element interIdEl = (Element)(el.selectSingleNode("//interactionId"));
==============================================================
=========
==============================================================
=========
interIdEl returns null.
Any help with this would be greatly appreciated!
Thanks,
Barbara
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|