@Override Object getDocumentType(Object node) { return node instanceof Document ? ((Document) node).getDocType() : null; }
public List operate(Object node) { if (node instanceof Document) { DocType doctype = ((Document) node).getDocType(); return doctype == null ? Collections.EMPTY_LIST : Collections.singletonList(doctype); } else // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_doctype can not be applied on " + node.getClass()); } }
@Override Object getDocumentType(Object node) { return node instanceof Document ? ((Document) node).getDocType() : null; }
@Override Object getDocumentType(Object node) { return node instanceof Document ? ((Document) node).getDocType() : null; }
Object getDocumentType(Object node) { return node instanceof Document ? ((Document)node).getDocType() : null; }
public List operate(Object node) { if (node instanceof Document) { DocType doctype = ((Document) node).getDocType(); return doctype == null ? Collections.EMPTY_LIST : Collections.singletonList(doctype); } else // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_doctype can not be applied on " + node.getClass()); } }
public List operate(Object node) { if (node instanceof Document) { DocType doctype = ((Document) node).getDocType(); return doctype == null ? Collections.EMPTY_LIST : Collections.singletonList(doctype); } else // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_doctype can not be applied on " + node.getClass()); } }
/** * This signifies that the reading of the DTD is complete. * * @throws SAXException */ public void endDTD() throws SAXException { document.getDocType().setInternalSubset(internalSubset.toString()); inDTD = false; inInternalSubset = false; }
public List operate(Object node) { if (node instanceof Document) { DocType doctype = ((Document)node).getDocType(); return doctype == null ? Collections.EMPTY_LIST : Collections12.singletonList(doctype); } else // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_doctype can not be applied on " + node.getClass()); } }
/** * @return The J2EE API version. */ public ApplicationXmlVersion getVersion() { ApplicationXmlVersion version = null; DocType docType = getDocument().getDocType(); if (docType != null) { version = ApplicationXmlVersion.valueOf(docType); } return version; }
/** * @return The J2EE API version. */ public ApplicationXmlVersion getVersion() { ApplicationXmlVersion version = null; DocType docType = getDocument().getDocType(); if (docType != null) { version = ApplicationXmlVersion.valueOf(docType); } return version; }
/** * This returns a <code>String</code> representation of the * <code>Document</code>, suitable for debugging. If the XML * representation of the <code>Document</code> is desired, * {@link org.jdom.output.XMLOutputter#outputString(Document)} * should be used. * * @return <code>String</code> - information about the * <code>Document</code> */ public String toString() { StringBuffer stringForm = new StringBuffer() .append("[Document: "); DocType docType = getDocType(); if (docType != null) { stringForm.append(docType.toString()) .append(", "); } else { stringForm.append(" No DOCTYPE declaration, "); } if (hasRootElement()) { stringForm.append("Root is ") .append(getRootElement().toString()); } else { stringForm.append(" No root element"); // shouldn't happen } stringForm.append("]"); return stringForm.toString(); }
public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) { ok = false; Attribute version = rssRoot.getAttribute("version"); if (version!=null) { ok = version.getValue().equals(getRSSVersion()); if (ok) { ok = false; DocType docType = document.getDocType(); if (docType!=null) { ok = ELEMENT_NAME.equals(docType.getElementName()); ok = ok && PUBLIC_ID.equals(docType.getPublicID()); ok = ok && SYSTEM_ID.equals(docType.getSystemID()); } } } } return ok; }
public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) { ok = false; Attribute version = rssRoot.getAttribute("version"); if (version!=null) { ok = version.getValue().equals(getRSSVersion()); if (ok) { ok = false; DocType docType = document.getDocType(); if (docType!=null) { ok = ELEMENT_NAME.equals(docType.getElementName()); ok = ok && PUBLIC_ID.equals(docType.getPublicID()); ok = ok && SYSTEM_ID.equals(docType.getSystemID()); } } } } return ok; }
DocType docType = document.getDocType();
try { DocType dt = document.getDocType(); domDoc = createDOMDocument(dt);
printDocType(out, doc.getDocType());
printDocType(out, doc.getDocType());
printDocType( out, doc.getDocType() );
/** * <p> * This method tells you the line of the XML file being parsed. * For an in-memory document, it's meaningless. The location * is only valid for the current parsing lifecycle, but * the document has already been parsed. Therefore, it returns * -1 for both line and column numbers. * </p> * * @param document JDOM <code>Document</code>. */ private void documentLocator(Document document) { locator = new JDOMLocator(); String publicID = null; String systemID = null; if (document != null) { DocType docType = document.getDocType(); if (docType != null) { publicID = docType.getPublicID(); systemID = docType.getSystemID(); } } locator.setPublicId(publicID); locator.setSystemId(systemID); locator.setLineNumber(-1); locator.setColumnNumber(-1); contentHandler.setDocumentLocator(locator); }