public class DocumentReader extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Document |
document |
static String |
DTD_ERROR
DTD respource filename of the most recent Error DTD
|
static String |
DTD_ERROR_1_0
DTD resource filename of the Error DTD version 1.0
|
protected static String |
FILENOTFOUND |
static String |
PUBLIC_ID_ERROR
Public ID of the most recent Error DTD
|
static String |
PUBLIC_ID_ERROR_1_0
Public ID of the Error DTD version 1.0
|
(package private) static UtilReader.PropertiesMap<String> |
utilProperties |
| Modifier | Constructor and Description |
|---|---|
protected |
DocumentReader()
Creates an empty document reader.
|
|
DocumentReader(Document doc) |
|
DocumentReader(InputSource source)
Constructs the document by reading it from a source.
|
|
DocumentReader(InputSource source,
boolean validating)
Constructs the document by reading it from a source.
|
|
DocumentReader(InputSource source,
boolean xsd,
boolean validating,
Class<?> resolveBase)
Constructs the document by reading it from a source.
|
|
DocumentReader(InputSource source,
boolean validating,
Class<?> resolveBase) |
|
DocumentReader(InputSource source,
Class<?> resolveBase)
Constructs the document by reading it from a source.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
appendChild(Element parent,
Element newChild,
String path)
Appends a child to a parent at the right position.
|
static String |
getAttribute(Element element,
String nameSpace,
String localName)
Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the
passed namespace
|
static List<Element> |
getChildElements(Element e) |
static List<Element> |
getChildElements(Element e,
String tag) |
List<Element> |
getChildElements(String path) |
List<Element> |
getChildElements(String path,
String tag) |
Document |
getDocument() |
static DocumentBuilder |
getDocumentBuilder()
Creates a DocumentBuilder with default settings for handler, resolver, or validation,
obtaining it from the cache if available.
|
static DocumentBuilder |
getDocumentBuilder(boolean validating)
Obtain a DocumentBuilder
|
static DocumentBuilder |
getDocumentBuilder(boolean validating,
boolean xsd,
ErrorHandler handler,
EntityResolver resolver)
Creates a DocumentBuilder.
|
static DocumentBuilder |
getDocumentBuilder(boolean validating,
ErrorHandler handler,
EntityResolver resolver)
|
String |
getElementAttributeValue(Element e,
String attr) |
String |
getElementAttributeValue(String path,
String attr) |
static Element |
getElementByPath(Element e,
String path) |
Element |
getElementByPath(String path) |
String |
getElementName(Element e) |
static String |
getElementValue(Element e) |
String |
getElementValue(String path) |
static String |
getNodeTextValue(Node n)
Return the text value of a node.
|
static String |
getNodeTextValue(Node n,
boolean trim) |
Element |
getRootElement()
Deprecated.
|
String |
getSystemId()
Returns the systemID of the InputSource used to read the document.
|
static boolean |
hasAttribute(Element element,
String nameSpace,
String localName)
Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the
passed namespace
|
static void |
main(String[] argv) |
static void |
registerPublicIDs()
Register the Public Ids for DTDs used by XMLBasicReader
This method is called by EntityResolver.
|
static void |
setNodeTextValue(Node n,
String value) |
static void |
setPrefix(Document d,
String ns,
String prefix) |
void |
setSystemId(String url) |
static Document |
toDocument(Element element)
Utility method to make a document of an element.
|
static boolean |
validate()
Returns the default setting for validation for DocumentReaders.
|
protected static boolean |
validate(boolean requested)
Whether to validate given a request for that.
|
protected static final String FILENOTFOUND
public static final String PUBLIC_ID_ERROR_1_0
public static final String DTD_ERROR_1_0
public static final String PUBLIC_ID_ERROR
public static final String DTD_ERROR
protected Document document
static UtilReader.PropertiesMap<String> utilProperties
protected DocumentReader()
public DocumentReader(InputSource source)
source - the input source from which to read the documentpublic DocumentReader(InputSource source, boolean validating)
source - the input source from which to read the documentvalidating - whether to validate the documentpublic DocumentReader(InputSource source, Class<?> resolveBase)
source - the input source from which to read the documentresolveBase - the base class whose package is used to resolve dtds, set to null if unknownpublic DocumentReader(InputSource source, boolean xsd, boolean validating, Class<?> resolveBase)
source - the input source from which to read the documentvalidating - whether to validate the documentresolveBase - the base class whose package is used to resolve dtds, set to null if unknownpublic DocumentReader(InputSource source, boolean validating, Class<?> resolveBase)
public DocumentReader(Document doc)
public static void registerPublicIDs()
public static final boolean validate()
protected static final boolean validate(boolean requested)
public static DocumentBuilder getDocumentBuilder()
public static DocumentBuilder getDocumentBuilder(boolean validating)
public static DocumentBuilder getDocumentBuilder(boolean validating, ErrorHandler handler, EntityResolver resolver)
public static DocumentBuilder getDocumentBuilder(boolean validating, boolean xsd, ErrorHandler handler, EntityResolver resolver)
validating - if true, the documentbuilder will validate documents readxsd - if true, validating will be done by an XML schema definiton.handler - a ErrorHandler class to use for catching parsing errors, pass null to use the default handlerresolver - a EntityResolver class used for resolving the document's dtd, pass null to use the default resolverpublic static String getNodeTextValue(Node n)
n - the Node whose value to determinepublic static boolean hasAttribute(Element element, String nameSpace, String localName)
public static String getAttribute(Element element, String nameSpace, String localName)
public static Document toDocument(Element element)
public static void appendChild(Element parent, Element newChild, String path)
parent - The parent element, to which a new child will be addednewChild - this new childpath - The beforementioned comma separated list of regexps. See also Pattern;
Namespace prefixes are ignored.public String getSystemId()
public void setSystemId(String url)
public String getElementName(Element e)
e - Elementpublic String getElementAttributeValue(String path, String attr)
path - Path to the elementattr - Attribute namepublic String getElementAttributeValue(Element e, String attr)
e - Elementattr - Attribute namepublic Element getRootElement()
public Element getElementByPath(String path)
path - Dot-separated list of tags describing path from root element to requested element.
NB the path starts with the name of the root element.public static Element getElementByPath(Element e, String path)
e - Element from which the "relative" path is starting.
NB the path starts with the name of the root element.path - Dot-separated list of tags describing path from root element to requested elementpublic String getElementValue(String path)
path - Path to the elementpublic static String getElementValue(Element e)
e - Elementpublic List<Element> getChildElements(String path)
path - Path to the elementList of child elementspublic static List<Element> getChildElements(Element e)
e - ElementList of child elementspublic List<Element> getChildElements(String path, String tag)
path - Path to the elementtag - tag to match ("*" means all tags")List of child elements with the given tagpublic static List<Element> getChildElements(Element e, String tag)
e - Elementtag - tag to match ("*" means all tags")List of child elements with the given tagpublic Document getDocument()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}