org.odftoolkit.odfdom.pkg
public class OdfFileDom extends DocumentImpl implements NamespaceContext
Modifier and Type | Field and Description |
---|---|
protected Map<Node,com.hp.hpl.jena.rdf.model.Model> |
inCententMetadataCache
The cache of in content metadata: key: a Node in the dom ; value: the
Jena RDF model of triples of the Node
|
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 |
protected JenaSink |
sink |
eventListeners, iterators, mutationEvents, ranges
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChanged
firstChild, fNodeListCache, ownerDocument
nextSibling, previousSibling
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, ID, IGNORABLEWS, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODE
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Modifier | Constructor and Description |
---|---|
protected |
OdfFileDom(OdfPackageDocument packageDocument,
String packagePath)
Creates the DOM representation of an XML file of an Odf document.
|
protected |
OdfFileDom(OdfPackage pkg,
String packagePath)
Creates the DOM representation of an XML file of an Odf document.
|
Modifier and Type | Method and Description |
---|---|
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
|
com.hp.hpl.jena.rdf.model.Model |
getBookmarkRDFMetadata() |
OdfPackageDocument |
getDocument()
Retrieves the
OdfPackageDocument of the XML file. |
Map<Node,com.hp.hpl.jena.rdf.model.Model> |
getInContentMetadataCache()
Get in-content metadata cache model
|
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.
|
JenaSink |
getSink()
The end users needn't to care of this method, which is used by
BookmarkRDFMetadataExtractor
|
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) |
static OdfFileDom |
newFileDom(OdfPackage pkg,
String packagePath) |
<T extends OdfElement> |
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() |
void |
updateInContentMetadataCache(Node node)
Update the in content metadata of the node.
|
addEventListener, cloneNode, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, dispatchingEventToSubtree, getEventListeners, getImplementation, removeEventListener, saveEnclosingAttr, setEventListeners
abort, adoptNode, callUserDataHandlers, changed, changes, checkDOMNSErr, checkNamespaceWF, checkQName, clearIdentifiers, clone, cloneNode, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElementDefinition, createElementNS, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, getAsync, getBaseURI, getDoctype, getDocumentElement, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getErrorChecking, getFeature, getIdentifier, getIdentifiers, getInputEncoding, getNodeName, getNodeNumber, getNodeNumber, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getTextContent, getUserData, getUserData, getUserDataRecord, getVersion, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, insertBefore, isKidOK, isValidQName, isXMLName, load, loadXML, normalizeDocument, putIdentifier, removeChild, removeIdentifier, renameNode, replaceChild, saveXML, setAsync, setDocumentURI, setEncoding, setErrorChecking, setInputEncoding, setStandalone, setStrictErrorChecking, setTextContent, setUserData, setUserData, setVersion, setXmlEncoding, setXmlStandalone, setXmlVersion, undeferChildren
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildren
getNextSibling, getParentNode, getPreviousSibling
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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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
protected String mPackagePath
protected OdfPackageDocument mPackageDocument
protected OdfPackage mPackage
protected XPath mXPath
protected Map<String,Set<String>> mDuplicatePrefixesByUri
protected Map<Node,com.hp.hpl.jena.rdf.model.Model> inCententMetadataCache
protected JenaSink sink
protected OdfFileDom(OdfPackageDocument packageDocument, String packagePath)
packageDocument
- the document the XML files belongs topackagePath
- the internal package path to the XML fileprotected OdfFileDom(OdfPackage pkg, String packagePath)
pkg
- the package the XML files belongs topackagePath
- the internal package path to the XML filepublic static OdfFileDom newFileDom(OdfPackageDocument packageDocument, String packagePath)
public static OdfFileDom newFileDom(OdfPackage pkg, 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 Pathpublic 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 nameDOMException
public OdfElement createElementNS(String nsuri, String qname) throws DOMException
createElementNS
in interface Document
createElementNS
in class CoreDocumentImpl
nsuri
- The namespace uriqname
- The element qnameDOMException
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 qnameOdfAttribute
DOMException
public OdfAttribute createAttributeNS(String nsuri, String qname) throws DOMException
createAttributeNS
in interface Document
createAttributeNS
in class CoreDocumentImpl
nsuri
- The namespace uriqname
- the attribute qnameOdfAttribute
DOMException
public OdfAttribute createAttributeNS(OdfName name) throws DOMException
name
- The OdfName
OdfAttribute
DOMException
public <T extends OdfElement> T newOdfElement(Class<T> clazz)
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 upIllegalArgumentException
- 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 lookupIllegalArgumentException
- 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 lookupIterator
for all prefixes bound to the
Namespace URI in the current scopeIllegalArgumentException
- 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 DOMpublic 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 setpublic Map<Node,com.hp.hpl.jena.rdf.model.Model> getInContentMetadataCache()
public void updateInContentMetadataCache(Node node)
the
- node, whose in content metadata will be updatedpublic com.hp.hpl.jena.rdf.model.Model getBookmarkRDFMetadata()
public JenaSink getSink()
Copyright © 2008-2014 The Apache Software Foundation. All Rights Reserved.