| java.lang.Object org.deegree.framework.xml.XMLFragment
All known Subclasses: org.deegree.ogcbase.OGCDocument, org.deegree.ogcwebservices.wass.wss.operation.WSSGetCapabilitiesDocument, org.deegree.model.metadata.iso19115.ISO19115Document, org.deegree.framework.xml.schema.XSDocument, org.deegree.io.IODocument, org.deegree.security.AuthenticationDocument, org.deegree.owscommon_1_1_0.operations.GetCapabilitiesDocument, org.deegree.ogcwebservices.wass.common.AuthenticationDocument, org.deegree.ogcwebservices.wps.describeprocess.ProcessDescriptionDocument, org.deegree.ogcwebservices.wcts.operation.WCTSRequestBaseDocument, org.deegree.framework.xml.XSLTDocument, org.deegree.ogcwebservices.csw.discovery.GetRecordsResultDocument, org.deegree.owscommon_new.OWSCommonCapabilitiesDocument, org.deegree.ogcwebservices.wass.was.operation.WASGetCapabilitiesDocument, org.deegree.ogcwebservices.ExceptionDocument, org.deegree.ogcwebservices.csw.manager.TransactionResultDocument, org.deegree.ogcbase.GMLDocument, org.deegree.model.filterencoding.capabilities.FilterCapabilities100Fragment, org.deegree.ogcwebservices.wass.wss.operation.DoServiceDocument, org.deegree.ogcwebservices.wass.was.operation.DescribeUserResponse, org.deegree.ogcwebservices.csw.discovery.GetRecordByIdResultDocument, org.deegree.model.filterencoding.capabilities.FilterCapabilities110Fragment, org.deegree.ogcwebservices.wass.saml.SAMLDocument, org.deegree.framework.trigger.TriggerConfigurationDocument, org.deegree.owscommon_1_1_0.CommonsDocument, org.deegree.owscommon_1_1_0.operations.GetResourceByIDDocument,
XMLFragment | public class XMLFragment implements Serializable(Code) | | An instance of XMLFragment encapsulates an underlying
Element which acts
as the root element of the document (which may be a fragment or a whole document).
Basically, XMLFragment provides easy loading and proper saving (automatically
generated CDATA-elements for text nodes that need to be escaped) and acts as base class for all
XML parsers in deegree.
TODO: automatically generated CDATA-elements are not implemented yet
Additionally, XMLFragment tries to make the handling of relative paths inside the
document's content as painless as possible. This means that after initialization of the
XMLFragment with the correct SystemID (i.e. the URL of the document):
- external parsed entities (in the DOCTYPE part) can use relative URLs; e.g. <!ENTITY local
SYSTEM "conf/wfs/wfs.cfg">
- application specific documents which extend
XMLFragment can resolve relative
URLs during parsing by calling the resolve() method
author: Torsten Friebe author: Markus Schneider author: last edited by: $Author: rbezema $ version: $Revision: 10106 $, $Date: 2008-02-18 04:58:04 -0800 (Mon, 18 Feb 2008) $ See Also: org.deegree.framework.xml.XMLTools |
Constructor Summary | |
public | XMLFragment() Creates a new XMLFragment which is not initialized. | public | XMLFragment(URL url) Creates a new XMLFragment which is loaded from the given URL . | public | XMLFragment(File file) Creates a new XMLFragment which is loaded from the given File . | public | XMLFragment(Reader reader, String systemId) Creates a new XMLFragment which is loaded from the given Reader .
Parameters: reader - Parameters: systemId - this string should represent a URL that is related to the passed reader. | public | XMLFragment(Document doc, String systemId) Creates a new XMLFragment instance based on the submitted
Document .
Parameters: doc - Parameters: systemId - this string should represent a URL that is the source of the passed doc. | public | XMLFragment(Element element) Creates a new XMLFragment instance based on the submitted Element . | public | XMLFragment(QualifiedName elementName) Constructs an empty document with the given QualifiedName as root node. |
Method Summary | |
public String | getAsPrettyString() Returns a string representation of the XML Document, pretty printed. | public String | getAsString() | public Map<URI, URL> | getAttachedSchemas() Determines the namespace URI s and the bound schema URL s from
the 'xsi:schemaLocation' attribute of the document element. | protected QualifiedName | getQualifiedName(Element element) Returns the qualified name of the given element. | public Element | getRootElement() | public URL | getSystemId() Returns the systemId (the URL of the XMLFragment ). | public boolean | hasSchema() Returns whether the document has a schema reference. | public void | load(URL url) Initializes the XMLFragment with the content from the given URL . | public void | load(InputStream istream, String systemId) Initializes the XMLFragment with the content from the given
InputStream . | public void | load(Reader reader, String systemId) Initializes the XMLFragment with the content from the given
Reader . | public static QualifiedName | parseQualifiedName(Node node) Parses the value of the submitted Node as a QualifiedName . | protected SimpleLink | parseSimpleLink(Element element) Parses the submitted Element as a SimpleLink . | public void | prettyPrint(OutputStream os) Writes the XMLFragment instance to the given OutputStream using
indentation so it may be read easily. | public void | prettyPrint(Writer writer) Writes the XMLFragment instance to the given Writer using
indentation so it may be read easily. | public URL | resolve(String url) Resolves the given URL (which may be relative) against the SystemID of the
XMLFragment into a URL (which is always absolute). | public void | setRootElement(Element rootElement) | public void | setSystemId(String systemId) | public void | setSystemId(URL systemId) | public String | toString() Returns a string representation of the object. | public void | write(Writer writer) Writes the XMLFragment instance to the given Writer using the
default system encoding and adding CDATA-sections in for text-nodes where needed. | public void | write(Writer writer, Properties outputProperties) Writes the XMLFragment instance to the given Writer using the
specified OutputKeys . | public void | write(OutputStream os) Writes the XMLFragment instance to the given OutputStream using
the default system encoding and adding CDATA-sections in for text-nodes where needed. | public void | write(OutputStream os, Properties outputProperties) Writes the XMLFragment instance to the given OutputStream using
the specified OutputKeys which allow complete control of the generated output. |
DEFAULT_URL | final public static String DEFAULT_URL(Code) | | Use this URL as SystemID only if an XMLFragment cannot be pinpointed to a URL -
in this case it may not use any relative references!
|
XMLFragment | public XMLFragment()(Code) | | Creates a new XMLFragment which is not initialized.
|
XMLFragment | public XMLFragment(Reader reader, String systemId) throws SAXException, IOException(Code) | | Creates a new XMLFragment which is loaded from the given Reader .
Parameters: reader - Parameters: systemId - this string should represent a URL that is related to the passed reader. If thisURL is not available or unknown, the string should contain the value ofXMLFragment.DEFAULT_URL throws: SAXException - throws: IOException - |
XMLFragment | public XMLFragment(Document doc, String systemId) throws MalformedURLException(Code) | | Creates a new XMLFragment instance based on the submitted
Document .
Parameters: doc - Parameters: systemId - this string should represent a URL that is the source of the passed doc. If thisURL is not available or unknown, the string should contain the value ofXMLFragment.DEFAULT_URL throws: MalformedURLException - if systemId is no valid and absolute URL |
XMLFragment | public XMLFragment(Element element)(Code) | | Creates a new XMLFragment instance based on the submitted Element .
Parameters: element - |
XMLFragment | public XMLFragment(QualifiedName elementName)(Code) | | Constructs an empty document with the given QualifiedName as root node.
Parameters: elementName - if the name's namespace is set, the prefix should be set as well. |
getAsPrettyString | public String getAsPrettyString()(Code) | | Returns a string representation of the XML Document, pretty printed. Note that pretty
printing can mess up XML documents in some cases (GML, for instance).
the string |
getAsString | public String getAsString()(Code) | | Returns a string representation of the XML Document
the string |
getAttachedSchemas | public Map<URI, URL> getAttachedSchemas() throws XMLParsingException(Code) | | Determines the namespace URI s and the bound schema URL s from
the 'xsi:schemaLocation' attribute of the document element.
keys are URIs (namespaces), values are URLs (schema locations) throws: XMLParsingException - |
getSystemId | public URL getSystemId()(Code) | | Returns the systemId (the URL of the XMLFragment ).
the systemId |
hasSchema | public boolean hasSchema()(Code) | | Returns whether the document has a schema reference.
true, if the document has a schema reference, false otherwise |
load | public void load(Reader reader, String systemId) throws SAXException, IOException(Code) | | Initializes the XMLFragment with the content from the given
Reader . Sets the SystemId, too.
Parameters: reader - Parameters: systemId - can not be null. This string should represent a URL that is related to the passedreader. If this URL is not available or unknown, the string should contain thevalue of XMLFragment.DEFAULT_URL throws: SAXException - throws: IOException - throws: NullPointerException - |
parseQualifiedName | public static QualifiedName parseQualifiedName(Node node) throws XMLParsingException(Code) | | Parses the value of the submitted Node as a QualifiedName .
To parse the text contents of an Element node, the actual text node must be
given, not the Element node itself.
Parameters: node - object representation of the element throws: XMLParsingException - |
parseSimpleLink | protected SimpleLink parseSimpleLink(Element element) throws XMLParsingException(Code) | | Parses the submitted Element as a SimpleLink .
Possible escaping of the attributes "xlink:href", "xlink:role" and "xlink:arcrole" is
performed automatically.
Parameters: element - the object representation of the element throws: XMLParsingException - |
setRootElement | public void setRootElement(Element rootElement)(Code) | | Parameters: rootElement - |
setSystemId | public void setSystemId(URL systemId)(Code) | | Parameters: systemId - The systemId (physical location) to set. |
toString | public String toString()(Code) | | Returns a string representation of the object.
a string representation of the object. |
write | public void write(Writer writer)(Code) | | Writes the XMLFragment instance to the given Writer using the
default system encoding and adding CDATA-sections in for text-nodes where needed.
TODO: Add code for CDATA safety.
Parameters: writer - |
write | public void write(Writer writer, Properties outputProperties)(Code) | | Writes the XMLFragment instance to the given Writer using the
specified OutputKeys .
Parameters: writer - cannot be null Parameters: outputProperties - output properties for the Transformer that is used to serialize thedocumentsee javax.xml.OutputKeys |
write | public void write(OutputStream os)(Code) | | Writes the XMLFragment instance to the given OutputStream using
the default system encoding and adding CDATA-sections in for text-nodes where needed.
TODO: Add code for CDATA safety.
Parameters: os - |
write | public void write(OutputStream os, Properties outputProperties)(Code) | | Writes the XMLFragment instance to the given OutputStream using
the specified OutputKeys which allow complete control of the generated output.
Parameters: os - cannot be null Parameters: outputProperties - output properties for the Transformer used to serialize thedocument See Also: javax.xml.transform.OutputKeys |
|
|