|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.mmbase.util.xml.DocumentReader
public class DocumentReader
The DocumentReader class provides methods for loading a xml document in memory. It serves as the base class for DocumentWriter (which adds ways to write a document), and XMLBasicReader, which adds path-like methods with which to retrieve elements. This can also be a class for general static dom utilities.
| Field Summary | |
|---|---|
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
|
| Constructor Summary | |
|---|---|
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. |
| Method Summary | |
|---|---|
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)
See getDocumentBuilder(boolean, ErrorHandler, EntityResolver) |
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()
Determine the root element of the contained document |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
protected DocumentReader()
public DocumentReader(InputSource source)
source - the input source from which to read the document
public DocumentReader(InputSource source,
boolean validating)
source - the input source from which to read the documentvalidating - whether to validate the document
public 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 unknown
public DocumentReader(InputSource source,
boolean xsd,
boolean validating,
Class<?> resolveBase)
source - the input source from which to read the documentxsd - 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 unknown
public DocumentReader(InputSource source,
boolean validating,
Class<?> resolveBase)
public DocumentReader(Document doc)
| Method Detail |
|---|
public static void registerPublicIDs()
public static boolean validate()
protected static boolean validate(boolean requested)
public static DocumentBuilder getDocumentBuilder()
public static DocumentBuilder getDocumentBuilder(boolean validating)
public static DocumentBuilder getDocumentBuilder(boolean validating,
ErrorHandler handler,
EntityResolver resolver)
getDocumentBuilder(boolean, ErrorHandler, EntityResolver)
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 resolver
public static String getNodeTextValue(Node n)
n - the Node whose value to determine
public static String getNodeTextValue(Node n,
boolean trim)
public static void setNodeTextValue(Node n,
String value)
public static void setPrefix(Document d,
String ns,
String prefix)
public 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 - Element
public String getElementAttributeValue(String path,
String attr)
path - Path to the elementattr - Attribute name
public String getElementAttributeValue(Element e,
String attr)
e - Elementattr - Attribute name
public 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 element
public String getElementValue(String path)
path - Path to the element
public static String getElementValue(Element e)
e - Element
public List<Element> getChildElements(String path)
path - Path to the element
List of child elementspublic static List<Element> getChildElements(Element e)
e - Element
List of child elements
public 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 tag
public 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()
public static void main(String[] argv)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||