public class OdfFileDom extends DocumentImpl implements NamespaceContext
| Modifier and Type | Field and Description |
|---|---|
protected Map<Node,org.apache.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, iteratorReferenceQueue, iterators, mutationEvents, rangeReferenceQueue, rangesactualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChangedfirstChild, fNodeListCache, ownerDocumentnextSibling, previousSiblingDOCUMENT_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_NODEATTRIBUTE_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
|
org.apache.jena.rdf.model.Model |
getBookmarkRDFMetadata() |
OdfPackageDocument |
getDocument()
Retrieves the
OdfPackageDocument of the XML file. |
Map<Node,org.apache.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, setEventListenersabort, adoptNode, callUserDataHandlers, canRenameElements, 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, undeferChildrengetChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildrengetNextSibling, getParentNode, getPreviousSiblingaddEventListener, 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, synchronizeDataequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, compareDocumentPosition, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setUserDataprotected String mPackagePath
protected OdfPackageDocument mPackageDocument
protected OdfPackage mPackage
protected XPath mXPath
protected Map<String,Set<String>> mDuplicatePrefixesByUri
protected Map<Node,org.apache.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 DocumentcreateElement in class CoreDocumentImplname - The element nameDOMExceptionpublic OdfElement createElementNS(String nsuri, String qname) throws DOMException
createElementNS in interface DocumentcreateElementNS in class CoreDocumentImplnsuri - The namespace uriqname - The element qnameDOMExceptionpublic OdfElement createElementNS(OdfName name) throws DOMException
name - The OdfNameOdfElementDOMExceptionpublic OdfAttribute createAttribute(String name) throws DOMException
createAttribute in interface DocumentcreateAttribute in class CoreDocumentImplname - the attribute qnameOdfAttributeDOMExceptionpublic OdfAttribute createAttributeNS(String nsuri, String qname) throws DOMException
createAttributeNS in interface DocumentcreateAttributeNS in class CoreDocumentImplnsuri - The namespace uriqname - the attribute qnameOdfAttributeDOMExceptionpublic OdfAttribute createAttributeNS(OdfName name) throws DOMException
name - The OdfNameOdfAttributeDOMExceptionpublic <T extends OdfElement> T newOdfElement(Class<T> clazz)
public XPath getXPath()
public String getNamespaceURI(String prefix)
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 NamespaceContextprefix - prefix to look upIllegalArgumentException - When prefix is nullpublic String getPrefix(String namespaceURI)
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 NamespaceContextnamespaceURI - URI of Namespace to lookupIllegalArgumentException - When namespaceURI is nullpublic Iterator<String> getPrefixes(String namespaceURI)
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 NamespaceContextnamespaceURI - URI of Namespace to lookupIterator for all prefixes bound to the Namespace URI in the current scopeIllegalArgumentException - When namespaceURI is nullpublic 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,org.apache.jena.rdf.model.Model> getInContentMetadataCache()
public void updateInContentMetadataCache(Node node)
the - node, whose in content metadata will be updatedpublic org.apache.jena.rdf.model.Model getBookmarkRDFMetadata()
public JenaSink getSink()
Copyright © 2008–2018 Apache Software Foundation; Copyright © 2018–2020 The Document Foundation. All rights reserved.