@Override public <N, E extends N, T extends N> boolean apply(ReadableDocument<N, E, T> doc, N node) { return node == doc.getDocumentElement(); } };
@Override public E getDocumentElement() { return inner.getDocumentElement(); }
/** * Returns the first element in the doc with the given tag name. The root * element will never match. * * @param doc document to look in * @param tagName tag name to find * @return the first element in the doc with tagName, or null if none exist */ public static <N, E extends N> E getElementWithTagName( ReadableDocument<N, E, ?> doc, String tagName) { return getElementWithTagName(doc, tagName, doc.getDocumentElement()); }
/** * Appends a document to builder * * @param doc */ private <E extends N, T extends N> void appendDocument(ReadableDocument<N, E, T> doc) { appendElement(doc, doc.getDocumentElement()); }
private static <N, E extends N, T extends N> XmlStringBuilderDoc<N, E, T> innerXml1(ReadableDocument<N, E, T> doc) { return createChildren(doc, doc.getDocumentElement()); }
/** * Returns the last element in the doc with the given tag name. The subtree root * element will never match. * * @param doc document to look in * @param tagName tag name to find * @return the last element in the doc with tagName, or null if none exist */ public static <N, E extends N> E getLastElementWithTagName( ReadableDocument<N, E, ?> doc, String tagName) { return getLastElementWithTagName(doc, tagName, doc.getDocumentElement()); }
/** * Iterates through elements in the document and returns the first with the * matching name value pair amongst its attributes. */ public static <N, E extends N, T extends N> E findElementByAttr( ReadableDocument<N, E, T> doc, String name, String value) { return findElementByAttr(doc, doc.getDocumentElement(), name, value); }
private static <N, E extends N, T extends N> XmlStringBuilderDoc<N, E, T> outerXml1( ReadableDocument<N, E, T> doc) { return createNode(doc, doc.getDocumentElement()); }
private static <N, E extends N, T extends N> XmlStringBuilderDoc<N, E, T> innerXmlHelper( ReadableDocument<N, E, T> doc, PermittedCharacters permittedChars) { return XmlStringBuilderDoc.createEmptyWithCharConstraints(doc, permittedChars) .appendChildXmlFragment(doc.getDocumentElement()); }
/** * @param doc * @return true if the given document is an old-style-paragraph document */ @Deprecated private static <N, E extends N, T extends N> boolean isUnsupportedParagraphDocument( ReadableDocument<N, E, T> doc) { if (doc.getFirstChild(doc.getDocumentElement()) == null) { // If the document is empty, check what the default global option is return !USE_LINE_CONTAINERS_BY_DEFAULT; } // Testing all children in the case of special <input> tags N root = doc.getDocumentElement(); for (N child = doc.getFirstChild(root); child != null; child = doc.getNextSibling(child)) { if (isUnsupportedParagraphElement(doc, child)) { return true; } } return false; }
private static boolean checkDomEqual( ReadableDocument<ContentNode, ContentElement, ContentTextNode> A, ReadableDocument<ContentNode, ContentElement, ContentTextNode> B) { return new ReadableTreeWalker<ContentNode, ContentElement, ContentTextNode>( A, A.getDocumentElement()).checkWalk(B, B.getDocumentElement()); }
private static boolean checkDomEqual( ReadableDocument<ContentNode, ContentElement, ContentTextNode> A, ReadableDocument<ContentNode, ContentElement, ContentTextNode> B) { return new ReadableTreeWalker<ContentNode, ContentElement, ContentTextNode>( A, A.getDocumentElement()).checkWalk(B, B.getDocumentElement()); }
private static <N, E extends N, T extends N> String extractAll1(ReadableDocument<N, E, T> doc) { return TextExtractor.extractInnerText(doc, doc.getDocumentElement()); } }
private static <N, E extends N, T extends N> String extractAll1(ReadableDocument<N, E, T> doc) { return TextExtractor.extractInnerText(doc, doc.getDocumentElement()); } }
private <E> List<E> elements(ReadableDocument<? super E, E, ?> doc) { return elementsInner(doc, doc.getDocumentElement()); }
private <E> List<E> elements(ReadableDocument<? super E, E, ?> doc) { return elementsInner(doc, doc.getDocumentElement()); }
private static String toSimpleString(ReadableDocument<ContentNode, ?, ?> doc) { DocOpBuffer opBuffer = new DocOpBuffer(); DomOperationUtil.buildDomInitializationFromSubtree(doc, doc.getDocumentElement(), opBuffer); return DocOpUtil.toXmlString(DocOpUtil.asInitialization(opBuffer.finish())); } }
private static String toSimpleString(ReadableDocument<ContentNode, ?, ?> doc) { DocOpBuffer opBuffer = new DocOpBuffer(); DomOperationUtil.buildDomInitializationFromSubtree(doc, doc.getDocumentElement(), opBuffer); return DocOpUtil.toXmlString(DocOpUtil.asInitialization(opBuffer.finish())); } }
stopAt = doc.getDocumentElement();
Element container = doc.getFirstChild(doc.getDocumentElement()).asElement(); assertNull(DocHelper.getElementWithTagName(doc, "x", container)); Element container = doc.getFirstChild(doc.getDocumentElement()).asElement(); Element expectedZ = doc.getLastChild(container).asElement(); assertSame(expectedZ, DocHelper.getElementWithTagName(doc, "z")); Element container = doc.getFirstChild(doc.getDocumentElement()).asElement(); Element y = doc.getFirstChild(container).asElement(); assertNull(DocHelper.getElementWithTagName(doc, "x", y)); Element x = doc.getFirstChild(doc.getDocumentElement()).asElement(); assertNull(DocHelper.getElementWithTagName(doc, "z", x)); doc.getDocumentElement())).asElement(); assertSame(expectedX, DocHelper.getElementWithTagName(doc, "x"));