Class DOM


  • public class DOM
    extends java.lang.Object
    W3C DOM wrapper access.

    The W3C DOM wrapper allows part or all of an XFA DOM (certain com.adobe.xfa classes) to be wrapped in a standard W3C DOM interface. This is handy if some portion of an XFA DOM needs to be passed to a package that expects W3C DOM objects.

    The general mode of operation is to create a wrapper node or document, pass it to the package that processes the W3C DOM interface, and then (implicitly) discard any wrapper objects created. This package does not currently support DOM update operations, nor does it respond to events generated by the underlying XFA DOM.

    This package is faithful in its mirroring of the XFA DOM structure. In particular, if an XDP is loaded into an XFA DOM and then wrapped, the document element in the wrapping W3C DOM corresponds to the root XDP element of the loaded document. However, if a non-XFA XML file is loaded into an XFA DOM and then wrapped, the document element is the XDP implicitly created by the XFA DOM, and the root element of the document is a child.

    Because this package wraps XFA DOM object instances with objects that implement the W3C DOM interface, there is the potential for a large number of wrapper objects to be created. Note, however, that wrapper object instances are created dynamically as the caller walks the DOM. In other words, it the caller inspects only a small part of the DOM, only a small number of wrapper instances will be created.

    Depending on how this package is used, it is possible to create multiple separate wrapper sets (documents) on a single XFA DOM, or have a single wrapper set (document) on the underlying XFA DOM. Both might be desirable, though the latter is likely more common.

    To create a single wrapper set, first use attach (com.adobe.xfa.Node) with any node from the XFA DOM. This returns a W3C DOM node. For subsequent nodes, call attach (Document, com.adobe.xfa.Node) passing in the document returned by Node.getOwnerDocument() for any node returned by either attach() overload. To create multiple wrapper sets, repeat the single wrapper set steps for each wrapper set required.

    Note that this is the only public class in the DOM wrapper package. There is no access to wrapper internals.

    • Constructor Summary

      Constructors 
      Constructor Description
      DOM()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.w3c.dom.Node attach​(Node xfaNode)
      Create a W3C DOM wrapper node instance associated with the given XFA DOM node.
      static org.w3c.dom.Node attach​(org.w3c.dom.Document document, Node xfaNode)
      Find or create a W3C DOM wrapper node instance associated with the given XFA DOM node.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DOM

        public DOM()
    • Method Detail

      • attach

        public static org.w3c.dom.Node attach​(Node xfaNode)
        Create a W3C DOM wrapper node instance associated with the given XFA DOM node.

        Given an XFA DOM node, this method returns an object implementing the W3C DOM node interface, corresponding to the XFA node. The result can be passed to any package expecting a W3C DOM node as input.

        Note that a new wrapper instance is always created, even if the application has previously called this method on the given XFA node. The new instance will have a new document, and navigation from the result will yield new wrapper instances for those nodes.

        Parameters:
        xfaNode - XFA DOM node to be wrapped.
        Returns:
        Corresponding W3C DOM node wrapper.
      • attach

        public static org.w3c.dom.Node attach​(org.w3c.dom.Document document,
                                              Node xfaNode)
        Find or create a W3C DOM wrapper node instance associated with the given XFA DOM node.

        Given a W3C DOM document instance and an XFA DOM node, this method returns an object implementing the W3C DOM node interface, corresponding to the XFA node. The result can be passed to any package expecting a W3C DOM node as input.

        If the given XFA node has already been wrapped for this document (either explicitly or implicitly through navigation), the existing wrapper instance is returned. Otherwise, a new instance is created, and that instance will be associated with the given document.

        Parameters:
        document - W3C DOM document in which to wrap the XFA node.
        xfaNode - XFA DOM node to be wrapped.
        Returns:
        Corresponding W3C DOM node wrapper.