Subject: RE: [xsl] How to select nodes with explicitly set default namespace - DOM4J From: omprakash.v@xxxxxxxxxxxxx Date: Thu, 24 Mar 2005 16:06:22 +0530 |
Hi, What Mike wants you to do is assign a prefix and use it to select the node that you want. Just refer dom4j API documentation to select a node in a namespace. The following 2 lines may need changing: el.add(new Namespace("", "urn:hl7-org:v3")); // include prefix here Element interIdEl = (Element)(el.selectSingleNode("//interactionId")); // use prefix here If you need further justification, just read any of the threads relating to namespace that has been posted the past few days. Cheers, Omprakash.V "Barbara Worwood" To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> <bworwood@imsm cc: (bcc: omprakash.v/Polaris) axims.com> Subject: RE: [xsl] How to select nodes with explicitly set default namespace - DOM4J 03/24/2005 03:16 PM Please respond to xsl-list 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: [xsl] 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: [xsl] 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 This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit Us at http://www.polaris.co.in
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to select nodes with , Michael Kay | Thread | [xsl] Grouping elements and summing, michella |
RE: [xsl] How to select nodes with , Barbara Worwood | Date | RE: [xsl] How to select nodes with , Michael Kay |
Month |