public static Document newDocument(Node firstElement, boolean deepcopy) { Document newDoc = new DocumentImpl(); newDoc.appendChild(newDoc.importNode(firstElement, deepcopy)); return newDoc; }
/** @param tag Will be treated as lower-case. */ @Override public final NodeList getElementsByTagName( String tag ){ tag=tag.toLowerCase(ENGLISH); return super.getElementsByTagName( tag); }
public final void addWithID(String id, Element node) { wordDOM.putIdentifier(id, node); }
/** * Deep-clone a document, including fixing ownerDoc for the cloned * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR * protection. I've chosen to implement it by calling importNode * which is DOM Level 2. * * @return org.w3c.dom.Node * @param deep boolean, iff true replicate children */ public Node cloneNode(boolean deep) { DocumentImpl newdoc = new DocumentImpl(); callUserDataHandlers(this, newdoc, UserDataHandler.NODE_CLONED); cloneNode(newdoc, deep); // experimental newdoc.mutationEvents = mutationEvents; return newdoc; } // cloneNode(boolean):Node
/** @param key will be converted to lower-case */ @Override public final NodeList getElementsByTagNameNS( String namespace, String key){ key=key.toLowerCase(ENGLISH); if ( namespace != null && 0<namespace.length() ) return super.getElementsByTagNameNS( namespace, key); return super.getElementsByTagName( key); }
protected DocumentImpl getDocumentImpl() { DocumentTypeImpl docType = new DocumentTypeImpl(null, "database", null, getSystemId()); DocumentImpl doc = new DocumentImpl(docType); doc.appendChild(doc.createComment(" " + getComment() + " ")); return doc; }
frag = fDocument.createDocumentFragment(); frag.appendChild(fDocument.createTextNode(sub)); frag.appendChild(fDocument.createCDATASection(sub)); frag.appendChild(fDocument.createComment(sub)); frag.appendChild(fDocument.createProcessingInstruction(fStartContainer.getNodeName(), sub));
ElementImpl node =(ElementImpl) markableDOM.createElementNS(markableNameSpace,"markable"); Node root= markableDOM.getElementsByTagName("markables").item(0); root.insertBefore((Node)node,root.getFirstChild()); for (int i=0;i<mmaxAttributes.length;i++)
encoding = _markableDOM.getEncoding(); if (encoding == null) if (markableDOM.getElementsByTagName("markables").item(0).getAttributes().getNamedItem("xmlns") == null) markableNameSpace = markableDOM.getElementsByTagName("markables").item(0).getAttributes().getNamedItem("xmlns").getNodeValue(); if (markableDOM.getDoctype() == null) if (markableDOM.getDoctype().getPublicId() != null) dtdReference = "<!DOCTYPE markables PUBLIC \""+markableDOM.getDoctype().getPublicId()+"\">"; else if (markableDOM.getDoctype().getSystemId() != null) dtdReference = "<!DOCTYPE markables SYSTEM \""+markableDOM.getDoctype().getSystemId()+"\">";
private final static Node getWordNodeOrClosestSuccessor(DocumentImpl dom, String id) result = dom.getElementById(id); if (result == null) Node node = dom.getDocumentElement(); node = node.getFirstChild();
/** Returns the Node representation of the discourse element with id ID.*/ public final Node getDiscourseElementNode(String ID) { Node result = null; try { result = wordDOM.getElementById(ID); } catch (java.lang.NullPointerException ex) { ex.printStackTrace(); } return result; }
protected void processSequences(Platform platform, DatabaseMetaData dbMetaData) throws SQLException { if (!processSequences) { return; } List<String> sequenceNames = getSequenceNames(dbMetaData); for (String sequenceName : sequenceNames) { Element sequence = doc.createElement("sequence"); sequence.setAttribute("name", sequenceName); /* * <view name="" nextval="" /> */ Long nextVal = platform.getSequenceNextVal(dbMetaData.getConnection(), schema, sequenceName); sequence.setAttribute("nextval", nextVal.toString()); databaseNode.appendChild(sequence); } doc.appendChild(databaseNode); }
((DocumentImpl) oDoc).adoptNode(oNode); return;
/** First adopts the new child, then appends it. * * I do this so that we can insert elements that were created with a * different owner document or no owner document, such as from * "new Image()" in javascript. * * @param newChild the new child * @see org.apache.xerces.dom.NodeImpl#appendChild(org.w3c.dom.Node) */ @Override public Node appendChild(Node newChild) throws DOMException { //We don't need adoptChild(newChild) because super.appendChild() calls insertBefore(n,r). //adoptNode(newChild); return super.appendChild(newChild); }
/** * Return the XML Document object that we will serialize to disk */ protected DocumentImpl getDocument(final TableHelper helper, final String tableName) throws SQLException { // Generate the document type DocumentTypeImpl docType = new DocumentTypeImpl(null, "dataset", null, getSystemId()); // Generate an empty document DocumentImpl doc = new DocumentImpl(docType); // Append a comment doc.appendChild(doc.createComment(" " + getComment() + " ")); // Extract the data from the table Element datasetNode = getDatasetNode(helper, doc, tableName); if (datasetNode == null) { // There was no data (zero rows), we are done return null; } // Add the dataset to the document doc.appendChild(datasetNode); // Return what we found return doc; }
ElementImpl node =(ElementImpl) markableDOM.createElementNS(markableNameSpace,"markable"); Node root= markableDOM.getElementsByTagName("markables").item(0); root.insertBefore((Node)node,root.getFirstChild()); for (int i=0;i<mmaxAttributes.length;i++)
@Override public synchronized HTMLElement getElementById(String id){ Element e=super.getElementById(id); if(e!=null)return (HTMLElement)e; return getElementById(id, this); }
*/ /** * Attempts to adopt the node into the document */ public static void bestEffortAdopt(Document oDoc, Node oNode) { // do nothing if there is nothing to do if ( (oDoc == null) || (oNode == null) || (oNode.getOwnerDocument() == oDoc)) { return; } // if we are using DOM3, use the adoptNode API if (hasDOM3Support()) { oDoc.adoptNode(oNode); return; } // if it is an DocumentImpl, steal its adoption if (isXercesDocument(oDoc)) { ((DocumentImpl) oDoc).adoptNode(oNode); return; } // otherwise just import and live with the copying oDoc.importNode(oNode, true); } // bestEffortAdopt()
/** * Non-preferred: use the getDOMImplementation() method instead of this * one to get a DOM Level 2 DOMImplementation object and then use DOM * Level 2 methods to create a DOM Document object. */ public Document newDocument() { return new org.apache.xerces.dom.DocumentImpl(); }
public final void registerAllDiscourseElements() { NodeList allWords = wordDOM.getElementsByTagName("word"); for (int z=0;z<allWords.getLength();z++) { registerDiscourseElement(allWords.item(z).getAttributes().getNamedItem("id").getNodeValue()); } }