| java.lang.Object org.mmbase.util.xml.DocumentReader
All known Subclasses: org.mmbase.util.xml.ModuleReader, org.mmbase.storage.util.StorageReader, org.mmbase.storage.search.implementation.database.informix.excalibur.XmlEtxIndicesReader, org.mmbase.storage.implementation.database.DatabaseStorageLookup, org.mmbase.util.magicfile.MagicXMLReader, org.mmbase.util.XMLNodeReader, org.mmbase.util.xml.BuilderReader, org.mmbase.util.xml.DocumentWriter, org.mmbase.util.xml.ApplicationReader, org.mmbase.util.XMLBasicReader,
DocumentReader | public class DocumentReader (Code) | | 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.
author: Case Roule author: Rico Jansen author: Pierre van Rooden author: Michiel Meeuwissen version: $Id: DocumentReader.java,v 1.39 2008/03/11 11:45:28 michiel Exp $ since: MMBase-1.7 |
Constructor Summary | |
protected | DocumentReader() Creates an empty document reader. | public | DocumentReader(InputSource source) Constructs the document by reading it from a source. | public | DocumentReader(InputSource source, boolean validating) Constructs the document by reading it from a source. | public | DocumentReader(InputSource source, Class> resolveBase) Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. | public | DocumentReader(InputSource source, boolean validating, Class> resolveBase) Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. | public | DocumentReader(Document doc) |
Method Summary | |
public static void | appendChild(Element parent, Element newChild, String path) Appends a child to a parent at the right position. | public static String | getAttribute(Element element, String nameSpace, String localName) | public List<Element> | getChildElements(String path) | public List<Element> | getChildElements(Element e) | public List<Element> | getChildElements(String path, String tag) | public List<Element> | getChildElements(Element e, String tag) | public static DocumentBuilder | getDocumentBuilder() Creates a DocumentBuilder with default settings for handler, resolver, or validation,
obtaining it from the cache if available. | 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) Creates a DocumentBuilder. | public String | getElementAttributeValue(String path, String attr) | public String | getElementAttributeValue(Element e, String attr) | public Element | getElementByPath(String path) Parameters: 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 Element | getElementByPath(Element e, String path) | public String | getElementName(Element e) | public String | getElementValue(String path) | public String | getElementValue(Element e) | public static String | getNodeTextValue(Node n) Return the text value of a node. | public static String | getNodeTextValue(Node n, boolean trim) | public Element | getRootElement() | public String | getSystemId() Returns the systemID of the InputSource used to read the document. | public static boolean | hasAttribute(Element element, String nameSpace, String localName) | public static void | main(String argv) | public static void | registerPublicIDs() Register the Public Ids for DTDs used by XMLBasicReader
This method is called by XMLEntityResolver. | public static void | setNodeTextValue(Node n, String value) | public static void | setPrefix(Document d, String ns, String prefix) | public void | setSystemId(String url) | public static Document | toDocument(Element element) Utility method to make a document of an element. | final protected static boolean | validate() Returns the default setting for validation for DocumentReaders. | final protected static boolean | validate(boolean requested) Whether to validate given a request for that. |
DTD_ERROR | final public static String DTD_ERROR(Code) | | DTD respource filename of the most recent Error DTD
|
DTD_ERROR_1_0 | final public static String DTD_ERROR_1_0(Code) | | DTD resource filename of the Error DTD version 1.0
|
FILENOTFOUND | final protected static String FILENOTFOUND(Code) | | |
PUBLIC_ID_ERROR | final public static String PUBLIC_ID_ERROR(Code) | | Public ID of the most recent Error DTD
|
PUBLIC_ID_ERROR_1_0 | final public static String PUBLIC_ID_ERROR_1_0(Code) | | Public ID of the Error DTD version 1.0
|
DocumentReader | protected DocumentReader()(Code) | | Creates an empty document reader.
|
DocumentReader | public DocumentReader(InputSource source)(Code) | | Constructs the document by reading it from a source.
Parameters: source - the input source from which to read the document |
DocumentReader | public DocumentReader(InputSource source, boolean validating)(Code) | | Constructs the document by reading it from a source.
Parameters: source - the input source from which to read the document Parameters: validating - whether to validate the document |
DocumentReader | public DocumentReader(InputSource source, Class> resolveBase)(Code) | | Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. The dtd sould be in the resources package under the package of the class passed.
Parameters: source - the input source from which to read the document Parameters: resolveBase - the base class whose package is used to resolve dtds, set to null if unknown |
DocumentReader | public DocumentReader(InputSource source, boolean validating, Class> resolveBase)(Code) | | Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. The dtd sould be in the resources package under the package of the class passed.
Parameters: source - the input source from which to read the document Parameters: validating - whether to validate the document Parameters: resolveBase - the base class whose package is used to resolve dtds, set to null if unknown |
DocumentReader | public DocumentReader(Document doc)(Code) | | since: MMBase-1.8 |
appendChild | public static void appendChild(Element parent, Element newChild, String path)(Code) | | Appends a child to a parent at the right position. The right position is defined by a comma
separated list of regular expressions. If the the child matches the last element of the
path, then the child is appended after similer childs, if not, then it will be appended
before them.
Parameters: parent - The parent element, to which a new child will be added Parameters: newChild - this new child Parameters: path - The beforementioned comma separated list of regexps. See also java.util.regex.Pattern;Namespace prefixes are ignored. since: MMBase-1.8 |
getAttribute | public static String getAttribute(Element element, String nameSpace, String localName)(Code) | | Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the
passed namespace
|
getChildElements | public List<Element> getChildElements(String path)(Code) | | Parameters: path - Path to the element a List of child elements |
getChildElements | public List<Element> getChildElements(String path, String tag)(Code) | | Parameters: path - Path to the element Parameters: tag - tag to match ("*" means all tags") a List of child elements with the given tag |
getChildElements | public List<Element> getChildElements(Element e, String tag)(Code) | | Parameters: e - Element Parameters: tag - tag to match ("*" means all tags") a List of child elements with the given tag |
getDocumentBuilder | public static DocumentBuilder getDocumentBuilder()(Code) | | Creates a DocumentBuilder with default settings for handler, resolver, or validation,
obtaining it from the cache if available.
a DocumentBuilder instance, or null if none could be created |
getDocumentBuilder | public static DocumentBuilder getDocumentBuilder(boolean validating)(Code) | | Obtain a DocumentBuilder
|
getDocumentBuilder | public static DocumentBuilder getDocumentBuilder(boolean validating, boolean xsd, ErrorHandler handler, EntityResolver resolver)(Code) | | Creates a DocumentBuilder.
DocumentBuilders that use the default error handler or entity resolver are cached (one for validating,
one for non-validating document buidlers).
Parameters: validating - if true, the documentbuilder will validate documents read Parameters: xsd - if true, validating will be done by an XML schema definiton. Parameters: handler - a ErrorHandler class to use for catching parsing errors, pass null to use the default handler Parameters: resolver - a EntityResolver class used for resolving the document's dtd, pass null to use the default resolver a DocumentBuilder instance, or null if none could be created since: MMBase-1.8. |
getElementAttributeValue | public String getElementAttributeValue(String path, String attr)(Code) | | Parameters: path - Path to the element Parameters: attr - Attribute name Value of attribute |
getElementAttributeValue | public String getElementAttributeValue(Element e, String attr)(Code) | | Parameters: e - Element Parameters: attr - Attribute name Value of attribute |
getElementByPath | public Element getElementByPath(String path)(Code) | | Parameters: 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. Leaf element of the path |
getElementByPath | public Element getElementByPath(Element e, String path)(Code) | | Parameters: e - Element from which the "relative" path is starting.NB the path starts with the name of the root element. Parameters: path - Dot-separated list of tags describing path from root element to requested element Leaf element of the path |
getElementName | public String getElementName(Element e)(Code) | | Parameters: e - Element Tag name of the element |
getElementValue | public String getElementValue(String path)(Code) | | Parameters: path - Path to the element Text value of element |
getElementValue | public String getElementValue(Element e)(Code) | | Parameters: e - Element Text value of element |
getNodeTextValue | public static String getNodeTextValue(Node n)(Code) | | Return the text value of a node.
It includes the contents of all child textnodes and CDATA sections, but ignores
everything else (such as comments)
The code trims excessive whitespace unless it is included in a CDATA section.
Parameters: n - the Node whose value to determine a String representing the node's textual value |
getNodeTextValue | public static String getNodeTextValue(Node n, boolean trim)(Code) | | since: MMBase-1.8.5 |
getRootElement | public Element getRootElement()(Code) | | Determine the root element of the contained document
root element |
getSystemId | public String getSystemId()(Code) | | Returns the systemID of the InputSource used to read the document.
This is generally the document's file path.
the systemID as a String since: MMBase-1.8 |
hasAttribute | public static boolean hasAttribute(Element element, String nameSpace, String localName)(Code) | | Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the
passed namespace
|
registerPublicIDs | public static void registerPublicIDs()(Code) | | Register the Public Ids for DTDs used by XMLBasicReader
This method is called by XMLEntityResolver.
|
setNodeTextValue | public static void setNodeTextValue(Node n, String value)(Code) | | since: MMBase-1.8.1 |
setSystemId | public void setSystemId(String url)(Code) | | since: MMBase-1.8 |
toDocument | public static Document toDocument(Element element)(Code) | | Utility method to make a document of an element.
since: MMBase-1.8 |
validate | final protected static boolean validate()(Code) | | Returns the default setting for validation for DocumentReaders.
true if validation is on |
validate | final protected static boolean validate(boolean requested)(Code) | | Whether to validate given a request for that. So, the request is followed, unless it is configured to 'never' validate.
since: MMBase-1.8 |
|
|