@Test public void siblingTests() throws XPathExpressionException { DOMDocument document = DOMParser.getInstance().parse("<a><b><c>XXXX</c><c>YYYY</c></b></a>", "test", null); DOMNode a = document.getDocumentElement(); assertNotNull(a); DOMNode b = a.getFirstChild(); assertNotNull(b); DOMNode c1 = b.getFirstChild(); assertNotNull(c1); DOMNode t1 = c1.getFirstChild(); assertTrue(t1.isText()); DOMText text1 = (DOMText) t1; assertEquals("XXXX", text1.getData()); DOMNode c2 = c1.getNextSibling(); assertNotNull(c2); DOMNode t2 = c2.getFirstChild(); assertTrue(t2.isText()); DOMText text2 = (DOMText) t2; assertEquals("YYYY", text2.getData()); DOMNode c1Previous = c2.getPreviousSibling(); assertNotNull(c1Previous); assertEquals(c1, c1Previous); }
@Override public DOMElement getDocumentElement() { List<DOMNode> roots = getRoots(); if (roots != null) { for (DOMNode node : roots) { if (node.isElement()) { return (DOMElement) node; } } } return null; }
DOMDocument extends DOMNode implements Document { @Override public DOMElement getDocumentElement() { List<DOMNode> roots = getRoots(); if (roots != null) { for (DOMNode node : roots) { if (node.isElement()) { return (DOMElement) node; } } } return null; } }
DOMDocument extends DOMNode implements Document { @Override public DOMElement getDocumentElement() { List<DOMNode> roots = getRoots(); if (roots != null) { for (DOMNode node : roots) { if (node.isElement()) { return (DOMElement) node; } } } return null; } DOMDocument(TextDocument textDocument, URIResolverExtensionManager resolverExtensionManager); }
DOMDocument extends DOMNode implements Document { @Override public DOMElement getDocumentElement() { List<DOMNode> roots = getRoots(); if (roots != null) { for (DOMNode node : roots) { if (node.isElement()) { return (DOMElement) node; } } } return null; } DOMDocument(TextDocument textDocument, URIResolverExtensionManager resolverExtensionManager); void setCancelChecker(CancelChecker cancelChecker); CancelChecker getCancelChecker(); List<DOMNode> getRoots(); Position positionAt(int offset); int offsetAt(Position position); String lineText(int lineNumber); String lineDelimiter(int lineNumber); LineIndentInfo getLineIndentInfo(int lineNumber); Range getElementNameRangeAt(int textOffset); @Override String getNamespaceURI(); String getText(); TextDocument getTextDocument(); boolean hasGrammar(); SchemaLocation getSchemaLocation(); boolean hasSchemaLocation(); NoNamespaceSchemaLocation getNoNamespaceSchemaLocation(); boolean hasNoNamespaceSchemaLocation(); boolean hasNamespaces(); String getSchemaInstancePrefix(); boolean hasSchemaInstancePrefix(); boolean hasProlog(); DOMNode getProlog(); boolean isBeforeProlog(int offset); boolean hasDTD(); boolean hasXMLModel(); List<XMLModel> getXMLModels(); boolean hasExternalGrammar(); Map<String, String> getExternalGrammarLocation(); String getExternalGrammarFromNamespaceURI(); DOMElement createElement(int start, int end); DOMCDATASection createCDataSection(int start, int end); DOMProcessingInstruction createProcessingInstruction(int start, int end); DOMComment createComment(int start, int end); DOMText createText(int start, int end); DOMDocumentType createDocumentType(int start, int end); @Override short getNodeType(); @Override String getNodeName(); @Override DOMElement getDocumentElement(); @Override DOMDocumentType getDoctype(); @Override DOMDocument getOwnerDocument(); @Override String getDocumentURI(); @Override void setDocumentURI(String documentURI); @Override DOMNode adoptNode(org.w3c.dom.Node source); @Override DOMAttr createAttribute(String name); @Override DOMAttr createAttributeNS(String namespaceURI, String qualifiedName); @Override CDATASection createCDATASection(String data); @Override DOMComment createComment(String data); @Override DocumentFragment createDocumentFragment(); @Override DOMElement createElement(String tagName); @Override DOMElement createElementNS(String namespaceURI, String qualifiedName); @Override EntityReference createEntityReference(String name); @Override DOMProcessingInstruction createProcessingInstruction(String target, String data); @Override DOMText createTextNode(String data); @Override DOMConfiguration getDomConfig(); @Override DOMElement getElementById(String elementId); @Override NodeList getElementsByTagName(String tagname); @Override NodeList getElementsByTagNameNS(String namespaceURI, String localName); @Override DOMImplementation getImplementation(); @Override String getInputEncoding(); @Override boolean getStrictErrorChecking(); @Override String getXmlEncoding(); @Override boolean getXmlStandalone(); @Override String getXmlVersion(); @Override DOMNode importNode(org.w3c.dom.Node importedNode, boolean deep); @Override void normalizeDocument(); @Override DOMNode renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName); @Override void setStrictErrorChecking(boolean strictErrorChecking); @Override void setXmlStandalone(boolean xmlStandalone); @Override void setXmlVersion(String xmlVersion); void resetGrammar(); URIResolverExtensionManager getResolverExtensionManager(); boolean isDTD(); boolean isWithinInternalDTD(int offset); Range getTrimmedRange(Range range); Range getTrimmedRange(int start, int end); Collection<DOMNode> findDTDAttrList(String elementName); String getSchemaPrefix(); }
DOMDocument extends DOMNode implements Document { @Override public DOMElement getDocumentElement() { List<DOMNode> roots = getRoots(); if (roots != null) { for (DOMNode node : roots) { if (node.isElement()) { return (DOMElement) node; } } } return null; } DOMDocument(TextDocument textDocument, URIResolverExtensionManager resolverExtensionManager); void setCancelChecker(CancelChecker cancelChecker); CancelChecker getCancelChecker(); List<DOMNode> getRoots(); Position positionAt(int offset); int offsetAt(Position position); String lineText(int lineNumber); String lineDelimiter(int lineNumber); LineIndentInfo getLineIndentInfo(int lineNumber); Range getElementNameRangeAt(int textOffset); @Override String getNamespaceURI(); String getText(); TextDocument getTextDocument(); boolean hasGrammar(); SchemaLocation getSchemaLocation(); boolean hasSchemaLocation(); NoNamespaceSchemaLocation getNoNamespaceSchemaLocation(); boolean hasNoNamespaceSchemaLocation(); boolean hasNamespaces(); String getSchemaInstancePrefix(); boolean hasSchemaInstancePrefix(); boolean hasProlog(); DOMNode getProlog(); boolean isBeforeProlog(int offset); boolean hasDTD(); boolean hasXMLModel(); List<XMLModel> getXMLModels(); boolean hasExternalGrammar(); Map<String, String> getExternalGrammarLocation(); String getExternalGrammarFromNamespaceURI(); DOMElement createElement(int start, int end); DOMCDATASection createCDataSection(int start, int end); DOMProcessingInstruction createProcessingInstruction(int start, int end); DOMComment createComment(int start, int end); DOMText createText(int start, int end); DOMDocumentType createDocumentType(int start, int end); @Override short getNodeType(); @Override String getNodeName(); @Override DOMElement getDocumentElement(); @Override DOMDocumentType getDoctype(); @Override DOMDocument getOwnerDocument(); @Override String getDocumentURI(); @Override void setDocumentURI(String documentURI); @Override DOMNode adoptNode(org.w3c.dom.Node source); @Override DOMAttr createAttribute(String name); @Override DOMAttr createAttributeNS(String namespaceURI, String qualifiedName); @Override CDATASection createCDATASection(String data); @Override DOMComment createComment(String data); @Override DocumentFragment createDocumentFragment(); @Override DOMElement createElement(String tagName); @Override DOMElement createElementNS(String namespaceURI, String qualifiedName); @Override EntityReference createEntityReference(String name); @Override DOMProcessingInstruction createProcessingInstruction(String target, String data); @Override DOMText createTextNode(String data); @Override DOMConfiguration getDomConfig(); @Override DOMElement getElementById(String elementId); @Override NodeList getElementsByTagName(String tagname); @Override NodeList getElementsByTagNameNS(String namespaceURI, String localName); @Override DOMImplementation getImplementation(); @Override String getInputEncoding(); @Override boolean getStrictErrorChecking(); @Override String getXmlEncoding(); @Override boolean getXmlStandalone(); @Override String getXmlVersion(); @Override DOMNode importNode(org.w3c.dom.Node importedNode, boolean deep); @Override void normalizeDocument(); @Override DOMNode renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName); @Override void setStrictErrorChecking(boolean strictErrorChecking); @Override void setXmlStandalone(boolean xmlStandalone); @Override void setXmlVersion(String xmlVersion); void resetGrammar(); URIResolverExtensionManager getResolverExtensionManager(); boolean isDTD(); boolean isWithinInternalDTD(int offset); Range getTrimmedRange(Range range); Range getTrimmedRange(int start, int end); Collection<DOMNode> findDTDAttrList(String elementName); String getSchemaPrefix();  }