|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xerces.dom.NodeImpl
org.apache.xerces.dom.ChildNode
org.apache.xerces.dom.ParentNode
org.apache.xerces.dom.CoreDocumentImpl
org.apache.xerces.dom.DocumentImpl
org.odftoolkit.odfdom.pkg.OdfFileDom
public class OdfFileDom
The DOM repesentation of an XML file within the ODF document.
Field Summary | |
---|---|
protected Map<String,Set<String>> |
mDuplicatePrefixesByUri
Contains only the duplicate prefix. |
protected OdfPackage |
mPackage
|
protected OdfPackageDocument |
mPackageDocument
|
protected String |
mPackagePath
|
protected Map<String,String> |
mPrefixByUri
|
protected Map<String,String> |
mUriByPrefix
|
protected XPath |
mXPath
|
Fields inherited from class org.apache.xerces.dom.DocumentImpl |
---|
eventListeners, iterators, mutationEvents, ranges |
Fields inherited from class org.apache.xerces.dom.CoreDocumentImpl |
---|
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChanged |
Fields inherited from class org.apache.xerces.dom.ParentNode |
---|
firstChild, fNodeListCache, ownerDocument |
Fields inherited from class org.apache.xerces.dom.ChildNode |
---|
nextSibling, previousSibling |
Constructor Summary | |
---|---|
protected |
OdfFileDom(OdfPackageDocument packageDocument,
String packagePath)
Creates the DOM representation of an XML file of an Odf document. |
Method Summary | ||
---|---|---|
OdfAttribute |
createAttribute(String name)
Create the ODF attribute with its name |
|
OdfAttribute |
createAttributeNS(OdfName name)
Create the ODF attribute with ODF name |
|
OdfAttribute |
createAttributeNS(String nsuri,
String qname)
Create the ODF attribute with namespace uri and qname |
|
OdfElement |
createElement(String name)
Create ODF element with namespace uri and qname |
|
OdfElement |
createElementNS(OdfName name)
Create ODF element with ODF name |
|
OdfElement |
createElementNS(String nsuri,
String qname)
Create ODF element with namespace uri and qname |
|
OdfPackageDocument |
getDocument()
Retrieves the OdfPackageDocument of the XML file. |
|
String |
getNamespaceURI(String prefix)
Get Namespace URI bound to a prefix in the current scope (the XML file). |
|
String |
getPackagePath()
Retrieves the String of Package Path |
|
String |
getPrefix(String namespaceURI)
Get prefix bound to Namespace URI in the current scope (the XML file). |
|
Iterator<String> |
getPrefixes(String namespaceURI)
Get all prefixes bound to a Namespace URI in the current scope. |
|
OdfElement |
getRootElement()
Retrieves the ODF root element. |
|
XPath |
getXPath()
Create an XPath instance to select one or more nodes from an ODF document. |
|
protected void |
initialize()
|
|
static OdfFileDom |
newFileDom(OdfPackageDocument packageDocument,
String packagePath)
|
|
|
newOdfElement(Class<T> clazz)
|
|
OdfNamespace |
setNamespace(NamespaceName name)
Adds a new Namespace to the DOM. |
|
OdfNamespace |
setNamespace(String prefix,
String uri)
Adds a new Namespace to the DOM. |
|
String |
toString()
|
Methods inherited from class org.apache.xerces.dom.DocumentImpl |
---|
addEventListener, cloneNode, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, dispatchingEventToSubtree, getEventListeners, getImplementation, removeEventListener, saveEnclosingAttr, setEventListeners |
Methods inherited from class org.apache.xerces.dom.ParentNode |
---|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildren |
Methods inherited from class org.apache.xerces.dom.ChildNode |
---|
getNextSibling, getParentNode, getPreviousSibling |
Methods inherited from class org.apache.xerces.dom.NodeImpl |
---|
addEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getContainer, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, getUserDataRecord, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Node |
---|
appendChild, compareDocumentPosition, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setUserData |
Field Detail |
---|
protected String mPackagePath
protected OdfPackageDocument mPackageDocument
protected OdfPackage mPackage
protected XPath mXPath
protected Map<String,String> mUriByPrefix
protected Map<String,String> mPrefixByUri
protected Map<String,Set<String>> mDuplicatePrefixesByUri
Constructor Detail |
---|
protected OdfFileDom(OdfPackageDocument packageDocument, String packagePath)
packageDocument
- the document the XML files belongs topackagePath
- the internal package path to the XML fileMethod Detail |
---|
public static OdfFileDom newFileDom(OdfPackageDocument packageDocument, String packagePath)
protected void initialize()
public OdfPackageDocument getDocument()
OdfPackageDocument
of the XML file.
A package document is usually represented as a directory with a mediatype.
public String getPackagePath()
String
of Package Path
public OdfElement getRootElement()
OdfElement
being the root of the document.public OdfElement createElement(String name) throws DOMException
createElement
in interface Document
createElement
in class CoreDocumentImpl
name
- The element name
DOMException
public OdfElement createElementNS(String nsuri, String qname) throws DOMException
createElementNS
in interface Document
createElementNS
in class CoreDocumentImpl
nsuri
- The namespace uriqname
- The element qname
DOMException
public OdfElement createElementNS(OdfName name) throws DOMException
name
- The OdfName
OdfElement
DOMException
public OdfAttribute createAttribute(String name) throws DOMException
createAttribute
in interface Document
createAttribute
in class CoreDocumentImpl
name
- the attribute qname
OdfAttribute
DOMException
public OdfAttribute createAttributeNS(String nsuri, String qname) throws DOMException
createAttributeNS
in interface Document
createAttributeNS
in class CoreDocumentImpl
nsuri
- The namespace uriqname
- the attribute qname
OdfAttribute
DOMException
public OdfAttribute createAttributeNS(OdfName name) throws DOMException
name
- The OdfName
OdfAttribute
DOMException
public <T extends OdfElement> T newOdfElement(Class<T> clazz)
public String toString()
toString
in class NodeImpl
public XPath getXPath()
public String getNamespaceURI(String prefix)
Get Namespace URI bound to a prefix in the current scope (the XML file).
When requesting a Namespace URI by prefix, the following table describes the returned Namespace URI value for all possible prefix values:
getNamespaceURI(prefix)
return value for specified prefixes
|
|
prefix parameter | Namespace URI return value |
DEFAULT_NS_PREFIX ("") |
default Namespace URI in the current scope or
when there is no default Namespace URI in the current scope |
bound prefix | Namespace URI bound to prefix in current scope |
unbound prefix |
|
XMLConstants.XML_NS_PREFIX ("xml") |
XMLConstants.XML_NS_URI
("http://www.w3.org/XML/1998/namespace") |
XMLConstants.XMLNS_ATTRIBUTE ("xmlns") |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI
("http://www.w3.org/2000/xmlns/") |
null |
IllegalArgumentException is thrown |
getNamespaceURI
in interface NamespaceContext
prefix
- prefix to look up
IllegalArgumentException
- When prefix
is
null
public String getPrefix(String namespaceURI)
Get prefix bound to Namespace URI in the current scope (the XML file).
Multiple prefixes bound to Namespace URI will be normalized to the first prefix defined.
When requesting a prefix by Namespace URI, the following table describes the returned prefix value for all Namespace URI values:
getPrefix(namespaceURI) return value for
specified Namespace URIs
|
|
---|---|
Namespace URI parameter | prefix value returned |
<default Namespace URI> | XMLConstants.DEFAULT_NS_PREFIX ("")
|
bound Namespace URI | prefix bound to Namespace URI in the current scope, if multiple prefixes are bound to the Namespace URI in the current scope, a single arbitrary prefix, whose choice is implementation dependent, is returned |
unbound Namespace URI | null |
XMLConstants.XML_NS_URI
("http://www.w3.org/XML/1998/namespace") |
XMLConstants.XML_NS_PREFIX ("xml") |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI
("http://www.w3.org/2000/xmlns/") |
XMLConstants.XMLNS_ATTRIBUTE ("xmlns") |
null |
IllegalArgumentException is thrown |
getPrefix
in interface NamespaceContext
namespaceURI
- URI of Namespace to lookup
IllegalArgumentException
- When namespaceURI
is
null
public Iterator<String> getPrefixes(String namespaceURI)
Get all prefixes bound to a Namespace URI in the current scope. (the XML file)
NOTE: Multiple prefixes bound to a similar Namespace URI will be normalized to the first prefix defined. Still the namespace attributes exist in the XML as inner value prefixes might be used.
The Iterator
is
not modifiable. e.g. the
remove()
method will throw
UnsupportedOperationException
.
When requesting prefixes by Namespace URI, the following table describes the returned prefixes value for all Namespace URI values:
getPrefixes(namespaceURI) return value for
specified Namespace URIs |
|
---|---|
Namespace URI parameter | prefixes value returned |
bound Namespace URI, including the <default Namespace URI> |
Iterator over prefixes bound to Namespace URI in
the current scope in an arbitrary,
implementation dependent,
order
|
unbound Namespace URI | empty Iterator |
XMLConstants.XML_NS_URI
("http://www.w3.org/XML/1998/namespace") |
Iterator with one element set to
XMLConstants.XML_NS_PREFIX ("xml") |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI
("http://www.w3.org/2000/xmlns/") |
Iterator with one element set to
XMLConstants.XMLNS_ATTRIBUTE ("xmlns") |
null |
IllegalArgumentException is thrown |
getPrefixes
in interface NamespaceContext
namespaceURI
- URI of Namespace to lookup
Iterator
for all prefixes bound to the
Namespace URI in the current scope
IllegalArgumentException
- When namespaceURI
is
null
public OdfNamespace setNamespace(String prefix, String uri)
XPath
.
All namespace attributes will be written to the root element during later serialization of the DOM by the OdfPackage
.
prefix
- of the namespace to be set to this DOMuri
- of the namespace to be set to this DOM
public OdfNamespace setNamespace(NamespaceName name)
XPath
.
All namespace attributes will be written to the root element during later serialization of the DOM by the OdfPackage
.
name
- the namespace to be set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |