GetElementsByTagName returns namespace of parent node?

Advertisement
November 30

So, is this expected behaviour?
I have the case were we have a parent node that is basically an XSD:anyType. We then store XML fragments under this node. However, when searching and retrieving various fragments using getEelementsByTagName that do not have a namespace associated with them, the namespace of the parent is associated to the returned element?
Is there anyway to suppress this or is there a better way to search and retrieve particular nodes?
I am using the XDK shipped with JDeveloper 10.1.3.1.
Thanks,
BradW

Advertisement

Replay

So, there is no default namespace specified. Here is the content of the XML:
<payload xmlns="http://xmlns.oracle.com/bpel/workflow/task">
<Location>kalwona</Location>
<ns1:VacationRequestProcessRequest xmlns:ns1="http://xmlns.oracle.com/VacationRequest">
<ns1:location>kalwona</ns1:location>
<ns1:creator>jstein</ns1:creator>
<ns1:fromDate/>
<ns1:toDate/>
<ns1:reasons>
<ns1:who/>
<ns1:what/>
<ns1:when/>
</ns1:reasons>
</ns1:VacationRequestProcessRequest>
<Errors xmlns="http://xmlns.oracle.com/VacationRequest"/>
</payload>
So, when grabbing a node with no namespace, it defaults to the parent nodes namespace. I have been able to rename the node with a different namespace, but it just makes things more complicated. Would be nice to get a plain node / fragment of an XML document.
Here is the code I am using to grab the node:
DOMParser parser = new DOMParser();
java.io.File file =
new java.io.File("C:\\payloadtest.xml");
XMLDocument doc;
InputStream is = new FileInputStream(file);
parser.setDebugMode(true);
parser.parse(is);
doc = parser.getDocument();
NodeList list = doc.getElementsByTagName("Location");
Element element = (Element)list.item(0);
System.out.println(xmlutils.elementToXMLString(element));
The output I get from this is:
<Location xmlns="http://xmlns.oracle.com/bpel/workflow/task">kalwona</Location>
The elementToXMLString just uses the XMLPrintDriver.
So, I am kind of hoping I can copy a node with no associated namespace information related to it. Kind of like just leaving it alone if there is no namespace specified in the actual document. Any ideas on how to do this???
Thanks,
BradW

View 10 Replies

Tags:

  1. macbook pro osx10.6.8 hdmi display on tv
  2. windonw 8 graphics card dw
  3. MacBook 5,4 windows
  4. cardumj
  5. lasteka
  6. reviewrwz
  7. spinx1l
  8. steel6s3
  9. killpi8
  10. ibooks 3.1 ipa
Copyrights 2019 Fcffair BigData Resource, All rights reserved