Package com.adobe.xfa
Class Document
- java.lang.Object
-
- com.adobe.xfa.Obj
-
- com.adobe.xfa.Node
-
- com.adobe.xfa.Element
-
- com.adobe.xfa.Document
-
- All Implemented Interfaces:
Peer
public class Document extends Element
A container class to hold the XML document node of the DOM.Conceptually, a DOM document node is the root of the document tree, and provides the primary access to the document's data.
Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a document, the
Documentinterface also contains the factory methods needed to create these objects. EachNodeobjects created have anownerDocumentattribute which associates them with theDocumentin which they were created.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adobe.xfa.Element
Element.DualDomNode, Element.ReplaceContent
-
Nested classes/interfaces inherited from class com.adobe.xfa.Node
Node.ChangeLogger
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEncodingXFA always encodes Documents as UTF-8 when serializing.static byte[]MarkupAttrMiddlestatic byte[]MarkupAttrMiddleQuotestatic byte[]MarkupCDATAEndstatic byte[]MarkupCDATAStartstatic byte[]MarkupCloseTagstatic byte[]MarkupDocTypestatic byte[]MarkupDQuoteStringstatic byte[]MarkupEndEntitystatic byte[]MarkupEndParen2static byte[]MarkupEndTagstatic byte[]MarkupEntitystatic byte[]MarkupPIEndstatic byte[]MarkupPIStartstatic byte[]MarkupQuoteStringstatic byte[]MarkupReturnstatic byte[]MarkupSpacestatic byte[]MarkupStartParenstatic byte[]MarkupStartTagstatic byte[]MarkupSystem-
Fields inherited from class com.adobe.xfa.Element
AttrIsDefault, AttrIsFragment, AttrIsTransient, CREATEACTION
-
Fields inherited from class com.adobe.xfa.Node
CREATE_ALWAYS_NEW, CREATE_IF_NOT_EXIST, CREATE_MUST_NOT_EXIST, CREATE_REPLACE, gsXFANamespacePrefix
-
Fields inherited from interface com.adobe.xfa.ut.Peer
ATTR_CHANGED, CHILD_ADDED, CHILD_REMOVED, DESCENDENT_ADDED, DESCENDENT_ATTR_CHANGED, DESCENDENT_REMOVED, DESCENDENT_VALUE_CHANGED, PARENT_CHANGED, PERMS_LOCK_CLEARED, PERMS_LOCK_SET, PROTO_ATTR_CHANGED, PROTO_CHILD_ADDED, PROTO_CHILD_REMOVED, PROTO_DESCENDENT_ADDED, PROTO_DESCENDENT_ATTR_CHANGED, PROTO_DESCENDENT_REMOVED, PROTO_DESCENDENT_VALUE_CHANGED, PROTO_VALUE_CHANGED, UPDATED, VALUE_CHANGED
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidappendChild(Node child)booleanautoUniquifyIDs()voidautoUniquifyIDs(boolean bAutoUniquifyIDs)voidclearIdMap()Clears all elements from the ID look up table.Nodeclone(Element parent)NodecloneNode(boolean bDeep)static DocumentcreateDocument(AppModel appModel)Creates a new Document that is separate from any default Document associated with the app model.ElementcreateElementNS(java.lang.String sNameSpaceURI, java.lang.String sQualifiedName, Element parent)voiddeclareGlobalXMLId(java.lang.String aIdAttrNameSpaceURI, java.lang.String aIdAttrName)voiddeclarePKey(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aPKeyNodeAddressList, Element namespaceContextNode)Defines a primary key on an element.voiddeclareXFAId(java.lang.String aNameSpaceURI, java.lang.String aIdAttributeName)voiddeclareXMLId(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aIdAttributeName)voiddeindexSubtree(Element source, boolean bInDocumentCheckCompleted)AppModelgetAppModel()Gets this document's app model.ElementgetDocumentElement()Gets this document's first element.ElementgetElementByPKey(Key key)Returns an element specified by its primary key.ElementgetElementByXFAId(java.lang.String aNameSpaceURI, java.lang.String aIdValue)ElementgetElementByXMLId(java.lang.String idValue)NodegetFirstXMLChild()Gets this element's first XML child.GeneratorgetGenerator()java.lang.StringgetName()Gets this document's name.java.net.URLgetParseFile()Gets an absolute URL that represents the source of the document, ornullif the source is unknown.java.lang.StringgetParseFileName()Gets the parse file name for reporting purposes.com.adobe.xfa.SaveNameSpaceCheckergetSaveChecker()booleangetWillDirty()Indicates whether changes should cause the namespace dirty flag to be set on changes within this document.booleanhasChanged()Determines if this document has changed since being last loaded.booleanidValueInUse(java.lang.String idValue)Indicates whether or not an ID value is currently in use in the document.NodeimportNode(Node source, boolean bDeep)Imports a copy of a Node from another document into this document.voidindexSubtree(Element source, boolean bInDocumentCheckCompleted)booleanisDefaultDocument()voidisDefaultDocument(boolean bIsDefault)booleanisId(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aAttrNameSpaceURI, java.lang.String aAttrLocalName)booleanisIncrementalLoad()voidload(java.io.File file)Loads a document from a file.voidload(java.io.InputStream is, java.lang.String encoding, boolean parseExternalDTD)Loads a document from an input stream.voidload(java.io.InputStream is, java.lang.String source, java.lang.String encoding, boolean parseExternalDTD)Loads a document from an input stream.ElementloadIntoDocument(java.io.InputStream is)This method loads an XML file into a unattached branch of the current document it is up to the class user to attach this branch to the current documentElementloadToNextElement(IntegerHolder depth)Retrieves an element from the DOM, using lazy loading.voidpreSave()voidsaveAs(java.io.OutputStream os, Node startNode, DOMSaveOptions options)Serializes the given starting node (and all its children) to an output stream.voidsavePreamble(java.io.OutputStream os, DOMSaveOptions options)voidsaveXML(java.io.OutputStream os, DOMSaveOptions options)Deprecated.voidserialize(java.io.OutputStream outFile, DOMSaveOptions options, int level, Node prevSibling)Deprecated.voidsetContext(Model model, Element parent, boolean bIgnoreAggregating)Sets this document's context for loading so that we can import XML into an existing DOM.voidsetParseFileName(java.lang.String source)voidsetWillDirty(boolean bWillDirty)Sets the flag that indicates whether changes within this document should cause the namespace dirty check flag to be set.booleanuniquifyIDsOnParse()voiduniquifyIDsOnParse(boolean bUniquifyIDsOnParse)-
Methods inherited from class com.adobe.xfa.Element
appendChild, appendPI, appendPI, assignNode, clone, connectPeerToDocument, constructKey, constructKeys, copyContent, defaultAttribute, defaultElement, defaultElement, establishID, evaluate, explodeQName, findAttr, findSchemaAttr, foundBadAttribute, foundBadAttribute, getAll, getAtom, getAttr, getAttribute, getAttribute, getAttributeByName, getAttrIndex, getAttrName, getAttrNS, getAttrProp, getAttrQName, getAttrVal, getChildReln, getClassAll, getClassIndex, getClassName, getDeltas, getElement, getElement, getElementClass, getElementLocal, getEnum, getEnum, getEventTable, getFirstXFAChild, getID, getIndex, getInheritedNS, getInstalledLocale, getIsNull, getLastXMLChild, getLineNumber, getLocalName, getModel, getNode, getNodes, getNodeSchema, getNS, getNumAttrs, getOneOfChild, getOneOfChild, getPI, getPI, getPrefix, getProperty, getProperty, getSaveXMLSaveTransient, getSchemaType, getScriptMethodInfo, getScriptTable, getSibling, getText, getXFAChild, getXMLChild, getXMLName, getXPath, getXsiNilAttribute, inhibitPrettyPrint, inhibitPrettyPrint, insertChild, isContainer, isFragment, isHidden, isHidden, isIndexed, isInstalledLocaleAmbient, isLeaf, isNameSpaceAttr, isPropertySpecified, isPropertySpecified, isPropertyValid, isSpecified, isSpecified, isSpecified, isTransient, isTransparent, isValidAttr, isValidChild, isValidElement, loadXML, loadXML, makeDefault, makeNonDefault, newAttribute, optimizeNameSpace, peekAttribute, peekElement, peekOneOfChild, peekProperty, peekProperty, postSave, preSave, privateSetName, processTextChildrenDuringParse, removeAttr, removeAttr, removeChild, removePI, removePI, removeWhiteSpace, removeXsiNilAttribute, replaceChild, resetPostLoadXML, resolveAndEnumerateChildren, resolveNodeCreate, resolvePrefix, saveFilteredXML, saveXML, setAttribute, setAttribute, setAttribute, setAttribute, setAttrProp, setDefaultFlag, setDOMProperties, setElement, setIsDataWindowRoot, setIsIndexed, setLineNumber, setLocalName, setModel, setName, setNS, setOneOfChild, setProperty, setProperty, setQName, setSaveXMLSaveTransient, setTransparent, setXMLName, setXsiNilAttribute, updateFromPeer
-
Methods inherited from class com.adobe.xfa.Node
checkAncestorPerms, checkDescendentPerms, checkPerms, cleanDirtyFlags, compareVersions, getData, getFirstXMLChildElement, getLocked, getNextXFASibling, getNextXMLSibling, getNextXMLSiblingElement, getNodeAsXML, getOwnerDocument, getPIAsXML, getPIName, getPreviousXMLSibling, getPrivateName, getPropName, getSOMExpression, getSOMExpression, getSomName, getUniqueSOMName, getXFAChildCount, getXFAParent, getXfaPeer, getXMLChildCount, getXMLParent, hasChanged, isDefault, isDirty, isMapped, isPermsLockSet, isTransient, locateChildByClass, locateChildByName, logValueChangeHelper, notifyPeers, performSOMAssignment, remove, resolveNode, resolveNode, resolveNode, resolveNodes, resolveNodes, sendMessenge, setDirty, setDocument, setLocked, setMapped, setPermsLock, setPrivateName, setXfaPeer, unLock, validateSchema, validateUsage, validateUsageFailedIsFatal
-
Methods inherited from class com.adobe.xfa.Obj
addPeer, addPeeredNode, clearPeers, deafen, getClassAtom, getClassTag, getPeer, getScriptProperty, getScriptThis, invokeFunction, isDeaf, isMute, isSameClass, isSameClass, isSameClass, mute, peerRemoved, removePeer, removePeeredNode, setClass, setClassTag, setScriptProperty, unDeafen, unMute
-
-
-
-
Field Detail
-
Encoding
public static final java.lang.String Encoding
XFA always encodes Documents as UTF-8 when serializing.- See Also:
- Constant Field Values
-
MarkupAttrMiddle
public static final byte[] MarkupAttrMiddle
-
MarkupAttrMiddleQuote
public static final byte[] MarkupAttrMiddleQuote
-
MarkupDQuoteString
public static final byte[] MarkupDQuoteString
-
MarkupQuoteString
public static final byte[] MarkupQuoteString
-
MarkupCDATAStart
public static final byte[] MarkupCDATAStart
-
MarkupCDATAEnd
public static final byte[] MarkupCDATAEnd
-
MarkupCloseTag
public static final byte[] MarkupCloseTag
-
MarkupDocType
public static final byte[] MarkupDocType
-
MarkupEndEntity
public static final byte[] MarkupEndEntity
-
MarkupEndParen2
public static final byte[] MarkupEndParen2
-
MarkupEndTag
public static final byte[] MarkupEndTag
-
MarkupEntity
public static final byte[] MarkupEntity
-
MarkupPIStart
public static final byte[] MarkupPIStart
-
MarkupPIEnd
public static final byte[] MarkupPIEnd
-
MarkupReturn
public static final byte[] MarkupReturn
-
MarkupSpace
public static final byte[] MarkupSpace
-
MarkupStartParen
public static final byte[] MarkupStartParen
-
MarkupStartTag
public static final byte[] MarkupStartTag
-
MarkupSystem
public static final byte[] MarkupSystem
-
-
Constructor Detail
-
Document
public Document(AppModel appModel)
Instantiates a document node with the given app model.- Parameters:
appModel- anAppModel
-
-
Method Detail
-
createDocument
public static Document createDocument(AppModel appModel)
Creates a new Document that is separate from any default Document associated with the app model.- Parameters:
appModel- anAppModel- Returns:
- a new Document
-
appendChild
public void appendChild(Node child)
- Overrides:
appendChildin classElement
-
autoUniquifyIDs
public final boolean autoUniquifyIDs()
-
autoUniquifyIDs
public final void autoUniquifyIDs(boolean bAutoUniquifyIDs)
-
uniquifyIDsOnParse
public final boolean uniquifyIDsOnParse()
-
uniquifyIDsOnParse
public final void uniquifyIDsOnParse(boolean bUniquifyIDsOnParse)
-
clearIdMap
public final void clearIdMap()
Clears all elements from the ID look up table.
-
getElementByXMLId
public final Element getElementByXMLId(java.lang.String idValue)
-
getElementByXFAId
public final Element getElementByXFAId(java.lang.String aNameSpaceURI, java.lang.String aIdValue)
-
getElementByPKey
public final Element getElementByPKey(Key key)
Returns an element specified by its primary key.- Parameters:
key- The primary key value to search on. Often constructed with the use of Element.constructKey.
-
declareXMLId
public final void declareXMLId(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aIdAttributeName)
-
declareGlobalXMLId
public final void declareGlobalXMLId(java.lang.String aIdAttrNameSpaceURI, java.lang.String aIdAttrName)
-
declareXFAId
public final void declareXFAId(java.lang.String aNameSpaceURI, java.lang.String aIdAttributeName)
-
declarePKey
public final void declarePKey(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aPKeyNodeAddressList, Element namespaceContextNode)Defines a primary key on an element.- Parameters:
aElementNameSpaceURI- The element's namespace URIaElementName- The element's local nameaPKeyNodeAddressList- A comma separated list of XPaths which identify the nodes to be used as primary key for this element
-
isId
public final boolean isId(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aAttrNameSpaceURI, java.lang.String aAttrLocalName)
-
cloneNode
public final Node cloneNode(boolean bDeep)
-
createElementNS
public final Element createElementNS(java.lang.String sNameSpaceURI, java.lang.String sQualifiedName, Element parent)
-
getFirstXMLChild
public Node getFirstXMLChild()
Description copied from class:ElementGets this element's first XML child.- Overrides:
getFirstXMLChildin classElement- Returns:
- the first XML child.
-
getAppModel
public AppModel getAppModel()
Gets this document's app model.- Overrides:
getAppModelin classElement- Returns:
- the app model.
-
getDocumentElement
public final Element getDocumentElement()
Gets this document's first element.- Returns:
- the first element.
-
getGenerator
public Generator getGenerator()
-
getName
public java.lang.String getName()
Gets this document's name.
-
getParseFile
public java.net.URL getParseFile()
Gets an absolute URL that represents the source of the document, ornullif the source is unknown.
-
getParseFileName
public java.lang.String getParseFileName()
Gets the parse file name for reporting purposes. For backwards compatibility, URL prefix is removed
-
getWillDirty
public boolean getWillDirty()
Indicates whether changes should cause the namespace dirty flag to be set on changes within this document.- Overrides:
getWillDirtyin classNode- Returns:
- true if changes should cause the namespace dirty flag to be set.
-
getSaveChecker
public final com.adobe.xfa.SaveNameSpaceChecker getSaveChecker()
-
isDefaultDocument
public final boolean isDefaultDocument()
-
isDefaultDocument
public final void isDefaultDocument(boolean bIsDefault)
-
importNode
public final Node importNode(Node source, boolean bDeep)
Imports a copy of a Node from another document into this document. The source node, which may belong to a different document, is copied, with the copy belonging to this document. The copy is not placed into the document (the parent node is null).- Parameters:
source- the node (subtree) to be copiedbDeep- if true, recursively import the subtree under the specified node; if false, import only the node itself (and its attributes, if if is an Element- Returns:
- the newly created copy of the source node, belonging to this document
-
hasChanged
public final boolean hasChanged()
Determines if this document has changed since being last loaded.- Returns:
- the document state.
-
indexSubtree
public final void indexSubtree(Element source, boolean bInDocumentCheckCompleted)
-
deindexSubtree
public final void deindexSubtree(Element source, boolean bInDocumentCheckCompleted)
-
idValueInUse
public final boolean idValueInUse(java.lang.String idValue)
Indicates whether or not an ID value is currently in use in the document. It is not ID-type-specific; it will check all XFA IDs, XML IDs, etc.- Parameters:
idValue- the ID in question- Returns:
trueif the ID value is currently used in the document
-
isIncrementalLoad
public final boolean isIncrementalLoad()
-
load
public final void load(java.io.InputStream is, java.lang.String encoding, boolean parseExternalDTD)Loads a document from an input stream. This overload should only be used in the case where the source is not known, or is not relevant (e.g., loading from an in-memory stream).- Parameters:
is- an input stream.encoding- the input stream's encoding if known. Ifnull, the encoding is detected automatically.parseExternalDTD- parse any external DTD whentrue.- Throws:
ExFull- exceptions upon parse errors.
-
load
public final void load(java.io.File file)
Loads a document from a file. The lead bytes of the file are read to determine its encoding.- Parameters:
file- an input file.- Throws:
ExFull- exceptions upon parse errors.
-
load
public final void load(java.io.InputStream is, java.lang.String source, java.lang.String encoding, boolean parseExternalDTD)Loads a document from an input stream.- Parameters:
is- an input stream.source- the source location, formatted as a file or URL.encoding- the input stream's encoding if known. Ifnull, the encoding is detected automatically.parseExternalDTD- parse any external DTD whentrue.- Throws:
ExFull- exceptions upon parse errors.
-
loadIntoDocument
public final Element loadIntoDocument(java.io.InputStream is)
This method loads an XML file into a unattached branch of the current document it is up to the class user to attach this branch to the current document
-
loadToNextElement
public final Element loadToNextElement(IntegerHolder depth)
Retrieves an element from the DOM, using lazy loading. When using lazy loading, no XSL processing is available.- Parameters:
depth- optional parameter which returns the depth of the returned element in the DOM tree being constructed.
-
savePreamble
public final void savePreamble(java.io.OutputStream os, DOMSaveOptions options)
-
preSave
public void preSave()
-
saveXML
@Deprecated public final void saveXML(java.io.OutputStream os, DOMSaveOptions options)Deprecated.Serializes this document (and all its children) to an output stream. This method does not perform any maintenance (e.g., namespace normalization) on any models contained within the document before saving.
-
saveAs
public final void saveAs(java.io.OutputStream os, Node startNode, DOMSaveOptions options)Serializes the given starting node (and all its children) to an output stream. This method does not perform any maintenance (e.g., namespace normalization) on any models contained within the document before saving.- Parameters:
os- an output stream.startNode- the starting node.options- the XML save options
-
serialize
public void serialize(java.io.OutputStream outFile, DOMSaveOptions options, int level, Node prevSibling) throws java.io.IOExceptionDeprecated.Description copied from class:NodeThe helper function used by saveXML()- Overrides:
serializein classElement- Parameters:
outFile- Streamfile to write tooptions- save optionslevel- the indent levelprevSibling- our previous sibling -- needed for some markup options.- Throws:
java.io.IOException- See Also:
Node.serialize(OutputStream, DOMSaveOptions, int, Node)
-
setContext
public final void setContext(Model model, Element parent, boolean bIgnoreAggregating)
Sets this document's context for loading so that we can import XML into an existing DOM.- Parameters:
model- the model we're loading this data into.parent- the parent element to load the XML under.bIgnoreAggregating- indicates whether we're to load the aggregating element or only its children.
-
setParseFileName
public final void setParseFileName(java.lang.String source)
-
setWillDirty
public void setWillDirty(boolean bWillDirty)
Sets the flag that indicates whether changes within this document should cause the namespace dirty check flag to be set.- Overrides:
setWillDirtyin classNode- Parameters:
bWillDirty- true if changes within this document should cause the namespace dirty check flag to be set.
-
-