Package com.adobe.xfa

Class 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 Document interface also contains the factory methods needed to create these objects. Each Node objects created have an ownerDocument attribute which associates them with the Document in which they were created.

  • Field Details

    • Encoding

      public static final String Encoding
      XFA always encodes Documents as UTF-8 when serializing.
      See Also:
    • 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 Details

    • Document

      public Document(AppModel appModel)
      Instantiates a document node with the given app model.
      Parameters:
      appModel - an AppModel
  • Method Details

    • 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 - an AppModel
      Returns:
      a new Document
    • appendChild

      public void appendChild(Node child)
      Overrides:
      appendChild in class Element
    • 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(String idValue)
    • getElementByXFAId

      public final Element getElementByXFAId(String aNameSpaceURI, 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(String aElementNameSpaceURI, String aElementName, String aIdAttributeName)
    • declareGlobalXMLId

      public final void declareGlobalXMLId(String aIdAttrNameSpaceURI, String aIdAttrName)
    • declareXFAId

      public final void declareXFAId(String aNameSpaceURI, String aIdAttributeName)
    • declarePKey

      public final void declarePKey(String aElementNameSpaceURI, String aElementName, String aPKeyNodeAddressList, Element namespaceContextNode)
      Defines a primary key on an element.
      Parameters:
      aElementNameSpaceURI - The element's namespace URI
      aElementName - The element's local name
      aPKeyNodeAddressList - A comma separated list of XPaths which identify the nodes to be used as primary key for this element
    • isId

      public final boolean isId(String aElementNameSpaceURI, String aElementName, String aAttrNameSpaceURI, String aAttrLocalName)
    • clone

      public final Node clone(Element parent)
      Overrides:
      clone in class Element
    • cloneNode

      public final Node cloneNode(boolean bDeep)
    • createElementNS

      public final Element createElementNS(String sNameSpaceURI, String sQualifiedName, Element parent)
    • getFirstXMLChild

      public Node getFirstXMLChild()
      Description copied from class: Element
      Gets this element's first XML child.
      Overrides:
      getFirstXMLChild in class Element
      Returns:
      the first XML child.
    • getAppModel

      public AppModel getAppModel()
      Gets this document's app model.
      Overrides:
      getAppModel in class Element
      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 String getName()
      Gets this document's name.
      Overrides:
      getName in class Element
      Returns:
      the document name which is the constant value "#document".
    • getParseFile

      public URL getParseFile()
      Gets an absolute URL that represents the source of the document, or null if the source is unknown.
    • getParseFileName

      public 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:
      getWillDirty in class Node
      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 copied
      bDeep - 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(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:
      true if the ID value is currently used in the document
    • isIncrementalLoad

      public final boolean isIncrementalLoad()
    • load

      public final void load(InputStream is, 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. If null, the encoding is detected automatically.
      parseExternalDTD - parse any external DTD when true.
      Throws:
      ExFull - exceptions upon parse errors.
    • load

      public final void load(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(InputStream is, String source, 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. If null, the encoding is detected automatically.
      parseExternalDTD - parse any external DTD when true.
      Throws:
      ExFull - exceptions upon parse errors.
    • loadIntoDocument

      public final Element loadIntoDocument(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(OutputStream os, DOMSaveOptions options)
    • preSave

      public void preSave()
    • saveXML

      @Deprecated public final void saveXML(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.

      Overrides:
      saveXML in class Element
      Parameters:
      os - an output stream.
      options - the XML save options
    • saveAs

      public final void saveAs(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(OutputStream outFile, DOMSaveOptions options, int level, Node prevSibling) throws IOException
      Deprecated.
      Description copied from class: Node
      The helper function used by saveXML()
      Overrides:
      serialize in class Element
      Parameters:
      outFile - Streamfile to write to
      options - save options
      level - the indent level
      prevSibling - our previous sibling -- needed for some markup options.
      Throws:
      IOException
      See Also:
    • 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(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:
      setWillDirty in class Node
      Parameters:
      bWillDirty - true if changes within this document should cause the namespace dirty check flag to be set.