|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.framework.xml.XMLFragment
public class XMLFragment
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):
XMLFragment
can resolve relative URLs during parsing by
calling the resolve()
method
XMLTools
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
DEFAULT_URL
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! |
protected static NamespaceContext |
nsContext
The namespace map containing the prefixes mapped to the namespaces. |
protected static java.net.URI |
XLNNS
The xlink namespace |
Constructor Summary | |
---|---|
XMLFragment()
Creates a new XMLFragment which is not initialized. |
|
XMLFragment(org.w3c.dom.Document doc,
java.lang.String systemId)
Creates a new XMLFragment instance based on the submitted Document . |
|
XMLFragment(org.w3c.dom.Element element)
Creates a new XMLFragment instance based on the submitted Element . |
|
XMLFragment(java.io.File file)
Creates a new XMLFragment which is loaded from the given File . |
|
XMLFragment(QualifiedName elementName)
Constructs an empty document with the given QualifiedName as root node. |
|
XMLFragment(java.io.Reader reader,
java.lang.String systemId)
Creates a new XMLFragment which is loaded from the given Reader . |
|
XMLFragment(java.net.URL url)
Creates a new XMLFragment which is loaded from the given URL . |
Method Summary | |
---|---|
java.lang.String |
getAsPrettyString()
Returns a string representation of the XML Document, pretty printed. |
java.lang.String |
getAsString()
Returns a string representation of the XML Document |
java.util.Map<java.net.URI,java.net.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(org.w3c.dom.Element element)
Returns the qualified name of the given element. |
org.w3c.dom.Element |
getRootElement()
|
java.net.URL |
getSystemId()
Returns the systemId (the URL of the XMLFragment ). |
boolean |
hasSchema()
Returns whether the document has a schema reference. |
void |
load(java.io.InputStream istream,
java.lang.String systemId)
Initializes the XMLFragment with the content from the given InputStream . |
void |
load(java.io.Reader reader,
java.lang.String systemId)
Initializes the XMLFragment with the content from the given Reader . |
void |
load(java.net.URL url)
Initializes the XMLFragment with the content from the given URL . |
static QualifiedName |
parseQualifiedName(org.w3c.dom.Node node)
Parses the value of the submitted Node as a QualifiedName . |
protected SimpleLink |
parseSimpleLink(org.w3c.dom.Element element)
Parses the submitted Element as a SimpleLink . |
void |
prettyPrint(java.io.OutputStream os)
Writes the XMLFragment instance to the given OutputStream using indentation so it may
be read easily. |
void |
prettyPrint(java.io.Writer writer)
Writes the XMLFragment instance to the given Writer using indentation so it may be read
easily. |
java.net.URL |
resolve(java.lang.String url)
Resolves the given URL (which may be relative) against the SystemID of the XMLFragment into a
URL (which is always absolute). |
void |
setRootElement(org.w3c.dom.Element rootElement)
|
void |
setSystemId(java.lang.String systemId)
|
void |
setSystemId(java.net.URL systemId)
|
java.lang.String |
toString()
Returns a string representation of the object. |
void |
write(java.io.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. |
void |
write(java.io.OutputStream os,
java.util.Properties outputProperties)
Writes the XMLFragment instance to the given OutputStream using the specified
OutputKeys which allow complete control of the generated output. |
void |
write(java.io.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. |
void |
write(java.io.Writer writer,
java.util.Properties outputProperties)
Writes the XMLFragment instance to the given Writer using the specified
OutputKeys . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static NamespaceContext nsContext
protected static final java.net.URI XLNNS
public static final java.lang.String DEFAULT_URL
XMLFragment
cannot be pinpointed to a URL - in this case it may
not use any relative references!
Constructor Detail |
---|
public XMLFragment()
XMLFragment
which is not initialized.
public XMLFragment(java.net.URL url) throws java.io.IOException, org.xml.sax.SAXException
XMLFragment
which is loaded from the given URL
.
url
-
java.io.IOException
org.xml.sax.SAXException
public XMLFragment(java.io.File file) throws java.net.MalformedURLException, java.io.IOException, org.xml.sax.SAXException
XMLFragment
which is loaded from the given File
.
file
- the file to load from
org.xml.sax.SAXException
- if the document could not be parsed
java.io.IOException
- if the document could not be read
java.net.MalformedURLException
- if the file cannot be transposed to a valid urlpublic XMLFragment(java.io.Reader reader, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOException
XMLFragment
which is loaded from the given Reader
.
reader
- systemId
- this string should represent a URL that is related to the passed reader. If this URL is not available
or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
org.xml.sax.SAXException
java.io.IOException
public XMLFragment(org.w3c.dom.Document doc, java.lang.String systemId) throws java.net.MalformedURLException
XMLFragment
instance based on the submitted Document
.
doc
- systemId
- this string should represent a URL that is the source of the passed doc. If this URL is not available
or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
java.net.MalformedURLException
- if systemId is no valid and absolute URL
public XMLFragment(org.w3c.dom.Element element)
XMLFragment
instance based on the submitted Element
.
element
- public XMLFragment(QualifiedName elementName)
QualifiedName
as root node.
elementName
- if the name's namespace is set, the prefix should be set as well.Method Detail |
---|
public java.net.URL getSystemId()
XMLFragment
).
public void setSystemId(java.lang.String systemId) throws java.net.MalformedURLException
systemId
- The systemId (physical location) to set (may be null).
java.net.MalformedURLException
public void setSystemId(java.net.URL systemId)
systemId
- The systemId (physical location) to set.public boolean hasSchema()
public java.util.Map<java.net.URI,java.net.URL> getAttachedSchemas() throws XMLParsingException
URI
s and the bound schema URL
s from the 'xsi:schemaLocation'
attribute of the document element.
XMLParsingException
public void load(java.net.URL url) throws java.io.IOException, org.xml.sax.SAXException
XMLFragment
with the content from the given URL
. Sets the SystemId,
too.
url
-
java.io.IOException
org.xml.sax.SAXException
public void load(java.io.InputStream istream, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOException, XMLException
XMLFragment
with the content from the given InputStream
. Sets the
SystemId, too.
istream
- systemId
- cannot be null. This string should represent a URL that is related to the passed istream. If this URL
is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
org.xml.sax.SAXException
java.io.IOException
XMLException
java.lang.NullPointerException
public void load(java.io.Reader reader, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOException
XMLFragment
with the content from the given Reader
. Sets the SystemId,
too.
reader
- systemId
- can not be null. This string should represent a URL that is related to the passed reader. If this URL
is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
org.xml.sax.SAXException
java.io.IOException
java.lang.NullPointerException
public void setRootElement(org.w3c.dom.Element rootElement)
rootElement
- public org.w3c.dom.Element getRootElement()
public java.net.URL resolve(java.lang.String url) throws java.net.MalformedURLException
XMLFragment
into a
URL
(which is always absolute).
url
-
java.net.MalformedURLException
public void write(java.io.Writer writer)
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.
writer
- public void write(java.io.Writer writer, java.util.Properties outputProperties)
XMLFragment
instance to the given Writer
using the specified
OutputKeys
.
writer
- cannot be nulloutputProperties
- output properties for the Transformer
that is used to serialize the document
see javax.xml.OutputKeyspublic void write(java.io.OutputStream os)
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.
os
- public void write(java.io.OutputStream os, java.util.Properties outputProperties)
XMLFragment
instance to the given OutputStream
using the specified
OutputKeys
which allow complete control of the generated output.
os
- cannot be nulloutputProperties
- output properties for the Transformer
used to serialize the documentOutputKeys
public void prettyPrint(java.io.OutputStream os) throws javax.xml.transform.TransformerException
XMLFragment
instance to the given OutputStream
using indentation so it may
be read easily.
os
-
javax.xml.transform.TransformerException
public void prettyPrint(java.io.Writer writer) throws javax.xml.transform.TransformerException
XMLFragment
instance to the given Writer
using indentation so it may be read
easily.
writer
-
javax.xml.transform.TransformerException
protected SimpleLink parseSimpleLink(org.w3c.dom.Element element) throws XMLParsingException
Element
as a SimpleLink
.
Possible escaping of the attributes "xlink:href", "xlink:role" and "xlink:arcrole" is performed automatically.
element
-
XMLParsingException
public static QualifiedName parseQualifiedName(org.w3c.dom.Node node) throws XMLParsingException
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.
node
-
XMLParsingException
protected QualifiedName getQualifiedName(org.w3c.dom.Element element) throws XMLParsingException
element
-
XMLParsingException
public java.lang.String getAsString()
public java.lang.String getAsPrettyString()
public java.lang.String toString()
toString
in class java.lang.Object
|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org