< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java
Print this page
@@ -218,12 +218,12 @@
final Node newNode = document.importNode(domNode, deep);
if (importedNode instanceof javax.xml.soap.Node) {
Node newSoapNode = createSoapNode(importedNode.getClass(), newNode);
newNode.setUserData(SAAJ_NODE, newSoapNode, null);
- if (deep && importedNode.hasChildNodes()) {
- NodeList childNodes = importedNode.getChildNodes();
+ if (deep && newSoapNode.hasChildNodes()) {
+ NodeList childNodes = newSoapNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
registerChildNodes(childNodes.item(i), deep);
}
}
return newSoapNode;
@@ -231,12 +231,16 @@
registerChildNodes(newNode, deep);
return findIfPresent(newNode);
}
- //If the parentNode is not registered to domToSoap, create soap wapper for parentNode and register it to domToSoap
- //If deep = true, also register all children of parentNode to domToSoap map.
+ /**
+ * If the parentNode is not registered to domToSoap, create soap wapper for parentNode and register it to domToSoap
+ * If deep = true, also register all children transitively of parentNode to domToSoap map.
+ * @param parentNode node to wrap
+ * @param deep wrap child nodes transitively
+ */
public void registerChildNodes(Node parentNode, boolean deep) {
if (parentNode.getUserData(SAAJ_NODE) == null) {
if (parentNode instanceof Element) {
ElementFactory.createElement(this, (Element) parentNode);
} else if (parentNode instanceof CharacterData) {
@@ -249,10 +253,12 @@
break;
case TEXT_NODE:
new SOAPTextImpl(this, (CharacterData) parentNode);
break;
}
+ } else if (parentNode instanceof DocumentFragment) {
+ new SOAPDocumentFragment(this, (DocumentFragment) parentNode);
}
}
if (deep) {
NodeList nodeList = parentNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
@@ -410,11 +416,15 @@
return findIfPresent(document.getNextSibling());
}
@Override
public NamedNodeMap getAttributes() {
- return new NamedNodeMapImpl(document.getAttributes(), this);
+ NamedNodeMap attributes = document.getAttributes();
+ if (attributes == null) {
+ return null;
+ }
+ return new NamedNodeMapImpl(attributes, this);
}
@Override
public Document getOwnerDocument() {
return document.getOwnerDocument();
@@ -622,10 +632,12 @@
return ((SOAPTextImpl)node).getDomElement();
} else if (node instanceof SOAPCommentImpl) {
return ((SOAPCommentImpl)node).getDomElement();
} else if (node instanceof CDATAImpl) {
return ((CDATAImpl) node).getDomElement();
+ } else if (node instanceof SOAPDocumentFragment) {
+ return ((SOAPDocumentFragment)node).getDomNode();
}
return node;
}
@@ -634,10 +646,12 @@
return new SOAPTextImpl(this, (Text) node);
} else if (SOAPCommentImpl.class.isAssignableFrom(nodeType)) {
return new SOAPCommentImpl(this, (Comment) node);
} else if (CDATAImpl.class.isAssignableFrom(nodeType)) {
return new CDATAImpl(this, (CDATASection) node);
+ } else if (SOAPDocumentFragment.class.isAssignableFrom(nodeType)) {
+ return new SOAPDocumentFragment(this, (DocumentFragment) node);
}
try {
Constructor<Node> constructor = nodeType.getConstructor(SOAPDocumentImpl.class, Element.class);
return constructor.newInstance(this, node);
} catch (Exception e) {
< prev index next >