Class OdfFileDom
- All Implemented Interfaces:
Serializable,Cloneable,NamespaceContext,Document,DocumentEvent,EventTarget,Node,NodeList,DocumentRange,DocumentTraversal
- Direct Known Subclasses:
OdfContentOrStylesDomBase,OdfManifestDom,OdfMetaDom,OdfSettingsDom
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe cache of in content metadata: key: a Node in the dom ; value: the Jena RDF model of triples of the NodeContains only the duplicate prefix.protected OdfPackageprotected OdfPackageDocumentprotected Stringprotected XPathprotected JenaSinkFields inherited from class org.apache.xerces.dom.DocumentImpl
eventListeners, iteratorReferenceQueue, iterators, mutationEvents, rangeReferenceQueue, rangesFields inherited from class org.apache.xerces.dom.CoreDocumentImpl
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChangedFields inherited from class org.apache.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocumentFields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSiblingFields inherited from class org.apache.xerces.dom.NodeImpl
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_NODEFields inherited from interface org.w3c.dom.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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOdfFileDom(OdfPackageDocument packageDocument, String packagePath) Creates the DOM representation of an XML file of an ODF document.protectedOdfFileDom(OdfPackage pkg, String packagePath) Creates the DOM representation of an XML file of an Odf document. -
Method Summary
Modifier and TypeMethodDescriptioncreateAttribute(String name) Create the ODF attribute with its namecreateAttributeNS(String nsuri, String qname) Create the ODF attribute with namespace uri and qnamecreateAttributeNS(OdfName name) Create the ODF attribute with ODF namecreateElement(String name) Create ODF element with namespace uri and qnamecreateElementNS(String nsuri, String qname) Create ODF element with namespace uri and qnamecreateElementNS(OdfName name) Create ODF element with ODF nameorg.apache.jena.rdf.model.ModelRetrieves theOdfPackageDocumentof the XML file.Get in-content metadata cache modelgetNamespaceURI(String prefix) Get Namespace URI bound to a prefix in the current scope (the XML file).Retrieves theStringof Package PathGet prefix bound to Namespace URI in the current scope (the XML file).getPrefixes(String namespaceURI) Get all prefixes bound to a Namespace URI in the current scope.Retrieves the ODF root element.getSink()The end users needn't to care of this method, which is used by BookmarkRDFMetadataExtractorgetXPath()Create an XPath instance to select one or more nodes from an ODF document.protected voidprotected voidinitialize(DefaultHandler handler, OdfFileDom dom) static OdfFileDomnewFileDom(OdfPackage pkg, String packagePath) <T extends OdfElement>
TnewOdfElement(Class<T> clazz) setNamespace(String prefix, String uri) Adds a new Namespace to the DOM.setNamespace(NamespaceName name) Adds a new Namespace to the DOM.toString()voidUpdate the in content metadata of the node.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, setEventListenersMethods inherited from class org.apache.xerces.dom.CoreDocumentImpl
abort, 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, undeferChildrenMethods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildrenMethods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSiblingMethods 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, synchronizeDataMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 Details
-
mPackagePath
-
mPackageDocument
-
mPackage
-
mXPath
-
mUriByPrefix
-
mPrefixByUri
-
mDuplicatePrefixesByUri
Contains only the duplicate prefix. The primary hold by mPrefixByUri still have to be added -
inCententMetadataCache
The cache of in content metadata: key: a Node in the dom ; value: the Jena RDF model of triples of the Node -
sink
-
-
Constructor Details
-
OdfFileDom
Creates the DOM representation of an XML file of an ODF document.- Parameters:
packageDocument- the document the XML files belongs topackagePath- the internal package path to the XML file
-
OdfFileDom
Creates the DOM representation of an XML file of an Odf document.- Parameters:
pkg- the package the XML files belongs topackagePath- the internal package path to the XML file
-
-
Method Details
-
newFileDom
-
initialize
-
initialize
protected void initialize(DefaultHandler handler, OdfFileDom dom) throws SAXException, IOException, ParserConfigurationException -
getDocument
Retrieves theOdfPackageDocumentof the XML file. A package document is usually represented as a directory with a media type.- Returns:
- The document holding the XML file.
-
getPackagePath
Retrieves theStringof Package Path- Returns:
- The path of the XML file relative to the package root
-
getRootElement
Retrieves the ODF root element.- Returns:
- The
OdfElementbeing the root of the document.
-
createElement
Create ODF element with namespace uri and qname- Specified by:
createElementin interfaceDocument- Overrides:
createElementin classCoreDocumentImpl- Parameters:
name- The element name- Throws:
DOMException
-
createElementNS
Create ODF element with namespace uri and qname- Specified by:
createElementNSin interfaceDocument- Overrides:
createElementNSin classCoreDocumentImpl- Parameters:
nsuri- The namespace uriqname- The element qname- Throws:
DOMException
-
createElementNS
Create ODF element with ODF name- Parameters:
name- TheOdfName- Returns:
- The
OdfElement - Throws:
DOMException
-
createAttribute
Create the ODF attribute with its name- Specified by:
createAttributein interfaceDocument- Overrides:
createAttributein classCoreDocumentImpl- Parameters:
name- the attribute qname- Returns:
- The
OdfAttribute - Throws:
DOMException
-
createAttributeNS
Create the ODF attribute with namespace uri and qname- Specified by:
createAttributeNSin interfaceDocument- Overrides:
createAttributeNSin classCoreDocumentImpl- Parameters:
nsuri- The namespace uriqname- the attribute qname- Returns:
- The
OdfAttribute - Throws:
DOMException
-
createAttributeNS
Create the ODF attribute with ODF name- Parameters:
name- TheOdfName- Returns:
- The
OdfAttribute - Throws:
DOMException
-
newOdfElement
-
toString
-
getXPath
Create an XPath instance to select one or more nodes from an ODF document. Therefore the namespace context is set to the OdfNamespace- Returns:
- an XPath instance with namespace context set to include the standard ODFDOM prefixes.
-
getNamespaceURI
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 prefixesprefix 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 scopeXMLConstants.NULL_NS_URI("")bound prefix Namespace URI bound to prefix in current scope unbound prefix XMLConstants.NULL_NS_URI("")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/")nullIllegalArgumentExceptionis thrown- Specified by:
getNamespaceURIin interfaceNamespaceContext- Parameters:
prefix- prefix to look up- Returns:
- Namespace URI bound to prefix in the current scope
- Throws:
IllegalArgumentException- Whenprefixisnull
-
getPrefix
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 URIsNamespace 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 nullXMLConstants.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")nullIllegalArgumentExceptionis thrown- Specified by:
getPrefixin interfaceNamespaceContext- Parameters:
namespaceURI- URI of Namespace to lookup- Returns:
- prefix bound to Namespace URI in current context
- Throws:
IllegalArgumentException- WhennamespaceURIisnull
-
getPrefixes
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
Iteratoris not modifiable. e.g. theremove()method will throwUnsupportedOperationException.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 URIsNamespace URI parameter prefixes value returned bound Namespace URI, including the <default Namespace URI> Iteratorover prefixes bound to Namespace URI in the current scope in an arbitrary, implementation dependent, orderunbound Namespace URI empty IteratorXMLConstants.XML_NS_URI("http://www.w3.org/XML/1998/namespace")Iteratorwith one element set toXMLConstants.XML_NS_PREFIX("xml")XMLConstants.XMLNS_ATTRIBUTE_NS_URI("http://www.w3.org/2000/xmlns/")Iteratorwith one element set toXMLConstants.XMLNS_ATTRIBUTE("xmlns")nullIllegalArgumentExceptionis thrown- Specified by:
getPrefixesin interfaceNamespaceContext- Parameters:
namespaceURI- URI of Namespace to lookup- Returns:
Iteratorfor all prefixes bound to the Namespace URI in the current scope- Throws:
IllegalArgumentException- WhennamespaceURIisnull
-
setNamespace
Adds a new Namespace to the DOM. Making the prefix usable with JDKXPath. All namespace attributes will be written to the root element during later serialization of the DOM by theOdfPackage.- Parameters:
prefix- of the namespace to be set to this DOMuri- of the namespace to be set to this DOM- Returns:
- the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken. In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted. The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
-
setNamespace
Adds a new Namespace to the DOM. Making the prefix usable with JDKXPath. All namespace attributes will be written to the root element during later serialization of the DOM by theOdfPackage.- Parameters:
name- the namespace to be set- Returns:
- the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken. In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted. The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
-
getInContentMetadataCache
Get in-content metadata cache model- Returns:
- in-content metadata cache model
-
updateInContentMetadataCache
Update the in content metadata of the node. It should be called whenever the xhtml:xxx attributes values of the node are changed.- Parameters:
the- node, whose in content metadata will be updated
-
getBookmarkRDFMetadata
public org.apache.jena.rdf.model.Model getBookmarkRDFMetadata()- Returns:
- the RDF metadata of all the bookmarks within the dom
-
getSink
The end users needn't to care of this method, which is used by BookmarkRDFMetadataExtractor- Returns:
- the JenaSink
-
getNextMarkupId
- Returns:
- counter for ids that are not allowed to be saved (otherwise it is not guaranteed that this id is unique)
-