public Node adoptNode(Node node) throws DOMException { //OK... I'm cheating here, a BIG TODO return this.importNode(node, true); }
/** * Returns a new document impl. * * @see javax.xml.parsers.DocumentBuilder#newDocument() */ public Document newDocument() { OMDOMFactory factory = new OMDOMFactory(); DocumentImpl documentImpl = new DocumentImpl(factory); documentImpl.setComplete(true); return documentImpl; }
/** * Updates the id state of the attr and notifies the document * * @param isId * @param tempAttr */ private void updateIsId(boolean isId, AttrImpl tempAttr) { tempAttr.isId = isId; if (isId) { this.ownerNode.addIdAttr(tempAttr); } else { this.ownerNode.removeIdAttr(tempAttr); } }
Element newElement; if (importedNode.getLocalName() == null) { newElement = this.createElement(importedNode.getNodeName()); } else { newElement = createElementNS(ns, importedNode.getNodeName()); && !attr.getNamespaceURI().equals( OMConstants.XMLNS_NS_URI)) { Attr newAttr = (Attr) importNode(attr, true); newElement.setAttributeNodeNS(newAttr); } else { // if (attr.getLocalName() == null) { Attr newAttr = (Attr) importNode(attr, true); newElement.setAttributeNode(newAttr); if ("".equals(importedNode.getNamespaceURI()) || importedNode.getNamespaceURI() == null) { newNode = createAttribute(importedNode.getNodeName()); } else { newNode = createAttribute(importedNode.getNodeName()); } else { String ns = importedNode.getNamespaceURI(); ns = (ns != null) ? ns.intern() : null; newNode = createAttributeNS(ns , importedNode.getNodeName()); newNode = createTextNode(importedNode.getNodeValue()); break;
public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException { String localName = DOMUtil.getLocalName(qualifiedName); String prefix = DOMUtil.getPrefix(qualifiedName); if (!OMConstants.XMLNS_NS_PREFIX.equals(localName)) { this.checkQName(prefix, localName); } else { return this.createAttribute(localName); } return new AttrImpl(this, localName, new NamespaceImpl( namespaceURI, prefix), this.factory); }
public OMDocument createOMDocument() { if (this.document == null) this.document = new DocumentImpl(this); return this.document; }
public Element createElementNS(String ns, String qualifiedName) throws DOMException { if (ns == null) ns = ""; String localName = DOMUtil.getLocalName(qualifiedName); String prefix = DOMUtil.getPrefix(qualifiedName); if(prefix == null) { prefix = ""; } //When the namespace is a default namespace if (prefix != null && !"".equals(prefix)) { this.checkQName(prefix, localName); } NamespaceImpl namespace = new NamespaceImpl(ns, prefix); return new ElementImpl(this, localName, namespace, this.factory); }
/** Creates an OMElement with the builder. */ public OMElement createOMElement(String localName, OMNamespace ns, OMContainer parent, OMXMLParserWrapper builder) { switch (((ParentNode) parent).getNodeType()) { case Node.ELEMENT_NODE: // We are adding a new child to an elem ElementImpl parentElem = (ElementImpl) parent; ElementImpl elem = new ElementImpl((DocumentImpl) parentElem .getOwnerDocument(), localName, (NamespaceImpl) ns, builder, this); parentElem.appendChild(elem); return elem; case Node.DOCUMENT_NODE: DocumentImpl docImpl = (DocumentImpl) parent; ElementImpl elem2 = new ElementImpl(docImpl, localName, (NamespaceImpl) ns, builder, this); docImpl.appendChild(elem2); return elem2; case Node.DOCUMENT_FRAGMENT_NODE: DocumentFragmentImpl docFragImpl = (DocumentFragmentImpl) parent; return new ElementImpl((DocumentImpl) docFragImpl .getOwnerDocument(), localName, (NamespaceImpl) ns, builder, this); default: throw new OMDOMException( "The parent container can only be an ELEMENT, DOCUMENT " + "or a DOCUMENT FRAGMENT"); } }
public OMDocument createOMDocument(OMXMLParserWrapper builder) { this.document = new DocumentImpl(builder, this); return this.document; }
public void addChild(OMNode omNode) { if (omNode.getOMFactory() instanceof OMDOMFactory) { Node domNode = (Node) omNode; if (this.ownerNode != null && !domNode.getOwnerDocument().equals(this.ownerNode)) { this.appendChild(this.ownerNode.importNode(domNode, true)); } else { this.appendChild(domNode); } } else { addChild(importNode(omNode)); } }
public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) throws DOMException { // TODO Handle docType stuff OMDOMFactory fac = new OMDOMFactory(); DocumentImpl doc = new DocumentImpl(fac); fac.setDocument(doc); new ElementImpl(doc, DOMUtil.getLocalName(qualifiedName), new NamespaceImpl(namespaceURI, DOMUtil .getPrefix(qualifiedName)), fac); return doc; }
public void applyPolicy(AxisDescription axisDescription, Element policy) { try { OMElement policyElement = (OMElement) new OMDOMFactory().getDocument().importNode(policy, true); axisDescription.applyPolicy(PolicyEngine.getPolicy(policyElement)); } catch (Exception e) { // TODO Handle exception properly throw new AssertionError(e); } }
OMElement receivedKeyInfoElem = (OMElement) new OMDOMFactory().getDocument().importNode(keyInfo, true);
OMElement receivedKeyInfoElem = (OMElement) new OMDOMFactory().getDocument().importNode(keyInfo, true);
rsaKey = val.getRSAKeyValue(); elem = rsaKey.getDOM(); omElem = (OMElement) new OMDOMFactory().getDocument().importNode(elem, true); modElem = (Element) omElem.getFirstChildWithName(Modulus.DEFAULT_ELEMENT_NAME); expElem = (Element) omElem.getFirstChildWithName(Exponent.DEFAULT_ELEMENT_NAME);
.getDocumentElement(); newElement.build(); return (OMNode) this.ownerNode.importNode((Element) newElement, true);