com.ihr.xbrl.om

## Class XBRLDocument

- java.lang.Object
- - com.ihr.xbrl.om.XMLFragment
  - - com.ihr.xbrl.om.XMLDocumentURI
    - - com.ihr.xbrl.om.XBRLDocument

- All Implemented Interfaces:
    HasAdditionalEqualityForReassignation, XBRLRelationshipPoint, Thinable, XBRLDTSDocument, XBRLHasDTSTarget, XBRLValidation, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext
  Direct Known Subclasses:
    XBRLInstance, XBRLLinkbase, XBRLTaxonomy

      public abstract class XBRLDocument
      extends XMLDocumentURI

  Contains the Properties of the object 2.2.2 XBRL Document Information Item The [Document URI] property is provided by the parent class XMLDocumentURI The [Document Information Item] property is provided by the root class XMLFragment The [Additional Properties] Properties are provided by classes derived by extension of this class
  Author:
    Ignacio

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.ihr.xbrl.om.XBRLValidation

      `XBRLValidation.Direction`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `INSTANCE` The Constant INSTANCE.
    `static int` | `IXBRL` The Constant IXBRL.
    `static int` | `LINKBASE` The Constant LINKBASE.
    `static int` | `TAXONOMY` The Constant TAXONOMY.

    - ### Fields inherited from class com.ihr.xbrl.om.XMLFragment

      `CONCEPT_LABEL, CONCEPT_QNAME, EASY_TO_READ, ELEMENT_LABEL, EMPTYRELATIONSHIPSITERATORINSTANCE, EMPTYXMLFRAGMENTITERATORINSTANCE, FACT_CONCEPT_DATATYPE, FACT_CONCEPT_LABEL, FACT_QNAME, HIDE_COMMON_ACCURACY, idQName, NO_POSITION, OrderComparator, OrderComparator2, PERIOD_TYPE, PERIOD_VALUE, SHORT_TEXT, SOURCE_DOCUMENT, XPATH, XPOINTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLDocument(DTSContainer dts, javax.xml.transform.Source xmlSource)` Creates an XBRLDocument form a Source object that can be used to obtain the XML nodes of the document content.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addExtendedLink(XBRLExtendedLink newExtendedLink)` Adds the extended link.
    `boolean` | `addIdOfElement(XMLFragment newElement)` Adds the id of newElement to the set of IDs stored in this document.
    `boolean` | `addIdOfElement(XMLFragment newElement, java.lang.String id)` Adds the id of newElement to the set of IDs stored in this document.
    `void` | `addParent(XBRLDocument parent)` Add a new XBRLDocument as parent of this document.
    `void` | `changeElementId(XMLFragment newEl, java.lang.String oldId, java.lang.String newId)` Changes the key of an element in the internal itemsById hashtable but does not change the id on the target element.
    `void` | `changeExtendedLinkKey(net.sf.saxon.s9api.XdmNode oldKey, net.sf.saxon.s9api.XdmNode newKey, XBRLExtendedLink link)` Change extended link key.
    `void` | `clear()` Frees-up used memory This method should not be invoqued on live objects in the DTS.
    `static XMLDocumentURI` | `createDocument(DTSContainer dts, java.net.URI baseURI, java.net.URI theURI, javax.xml.transform.Source source, boolean addToCache, XBRLDTSDocument parent)` Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type if the document is not a linkbase, schema or xbrl instance returns null.
    `static XMLDocumentURI` | `createDocument(XMLDocumentURI node, boolean addToCache)` Transforms the XMLDocumentURI in the node parameter into a XBRLDocument Linkbase, Taxonomy or Instance depending on the root node .
    `void` | `delParent(XBRLDocument parent)` Del parent.
    `abstract void` | `discoverDTS(XBRLDTSDocument parent)` All derived classes MUST implement this method and provide the functionality according to section 3.2 of the XBRL 2.1 specification
    `boolean` | `equals(java.lang.Object oe)` Sets a new XPathFunctionResolver for this object.
    `abstract org.jdom.Document` | `generateDocNode(boolean relativize, java.net.URI base)` This class has to be implemented by objects derived from XBRLDocument and must return a org.jdom.Document node with the content of this XBRLDocument object
    `java.util.Iterator<java.lang.String>` | `getAllUsedIds()` This method returns an iterator over all ids used by elements in this document.
    `java.util.Collection<java.lang.String>` | `getComments()` Access to the comments in the file.
    `net.sf.saxon.s9api.XdmNode` | `getDocument()` Returns the surrounding XML Node.
    `void` | `getDTS()` Launches the rules for DTSDiscovery process that will eventually add more objects to the DTSContainer.
    `abstract int` | `getDTSDocumentType()` Returns the type of DTS Document.
    `abstract java.lang.String` | `getDTSDocumentTypeName()` Gets the DTS document type name.
    `XMLFragment` | `getElementById(java.lang.String id)` This method returns the XMLFragment associated to the id received as a parameter.
    `XBRLExtendedLink` | `getExtendedLink(net.sf.saxon.s9api.XdmNode key)` Gets the extended link.
    `java.util.Iterator<XBRLExtendedLink>` | `getExtendedLinks()` Returns an iterator over all extended links on this container.
    `java.util.Iterator<XBRLExtendedLink>` | `getExtendedLinks(XBRLRoleType role)` Returns an iterator over all extended links on this container filtered by the specific role type indicated in the role parameter.
    `java.util.Iterator<XBRLDocument>` | `getParents()` Access to the [Parents] property.
    `int` | `hashCode()`
    `boolean` | `isContentModified()` Returns true if the document content has been modified.
    `boolean` | `isDocumentModified()` Returns true if the content is in sync with the surrounding XML and the document matches the content of the documentURI (the document has not been changed or has been saved)
    `boolean` | `isIdUsed(java.lang.String id)` This method returns true if the id indicated as a parameter corresponds to an XMLFragment in this XBRLDocument.
    `static void` | `moveNamespacesUp(org.jdom.Document jdomDocument)` Internal method used during serialization of XML files.
    `static void` | `moveNamespacesUp(net.sf.saxon.tree.linked.DocumentImpl document)` Internal method used during serialization of XML files.
    `abstract void` | `readInfoset()` Read all structures that builds the infoset.
    `void` | `removeExtendedLink(XBRLExtendedLink link)` Removes the extended link.
    `void` | `removeIdOfElement(XMLFragment element)` Removes the id of element.
    `void` | `save(boolean relativize)` Save the file to the indicated document URI Directories in the path of the file name are created automatically .
    `void` | `setComments(java.util.Collection<java.lang.String> fileComments)` Sets a new collection of comments for this file.
    `void` | `setDocumentAndReload(net.sf.saxon.s9api.XdmNode node)` This method is called by the XMLFragment object each time the surrounding XdmNode object is set.
    `boolean` | `updateXML(boolean relativize)` Updates the XML content of the XBRLDocument so the next call to save or to XdmNode getDocument() will obtain a fresh copy with all changes made in the object library.

    - ### Methods inherited from class com.ihr.xbrl.om.XMLDocumentURI

      `addChild, delChild, generateLocatorToDocument, getBase, getChildren, getDocumentURI, getDTSKey, getLocalFile, getValidationReport, invalidate, invalidate, isInDTS, isOnValidation, setURI, validate`

    - ### Methods inherited from class com.ihr.xbrl.om.XMLFragment

      `addAttribute, addChild, addFromRelationship, addNamespace, addNamespace, addToRelationship, addXMLChild, changeBase, checkBase, clone, clone, delAttribute, delAttribute, equalXdmValues, evaluateBoolean, evaluateList, evaluateNode, evaluateNumber, evaluateString, generateId, generateNode, generateNodeNamespacesAndAttributes, generateNodeValue, generatePrefix, getAllAttributes, getAttribute, getAttributeBooleanValue, getAttributeQNameValue, getAttributes, getAttributes, getAttributeStringValue, getAttributeValue, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getContainerDocumentURI, getDeclaredNamespaces, getElements, getElementsHashCode, getFragment, getFriendlyName, getFriendlyName, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getGenericLabelText, getId, getLang, getNamespaceURI, getNodeName, getNumberOfAttributes, getNumberOfElements, getNumberOfFromRelationships, getNumberOfToRelationships, getOrGenerateId, getParent, getPrefix, getPrefixes, getQNameValue, getRelationshipsBases, getRelationshipsChain, getRelationshipTypes, getStaticContext, getStaticNamespace, getStringValue, getToolTipText, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getValue, getXPathExecutable, getXPathNamespaceContext, getXPathToNode, getXPathToRoot, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isDead, isNamespaceDefined, isXdmDocumentAttached, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, removeXMLChild, resetElements, resetHash, resolve_equal2, resolveHRef, resolveHRef, s_equal2, s_equal2, s_equal2, setAttributes, setBase, setDocument, setElements, setId, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setParent, setRegenerateNodeIfnotFound, setValue, setValue, setVariablesDefined, size, thin, toString, valueEquals, xEqual`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final int INSTANCE

      The Constant INSTANCE.
      See Also:
        Constant Field Values

    - #### TAXONOMY

          public static final int TAXONOMY

      The Constant TAXONOMY.
      See Also:
        Constant Field Values

    - #### LINKBASE

          public static final int LINKBASE

      The Constant LINKBASE.
      See Also:
        Constant Field Values

    - #### IXBRL

          public static final int IXBRL

      The Constant IXBRL.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XBRLDocument

          public XBRLDocument(DTSContainer dts,
                      javax.xml.transform.Source xmlSource)
                       throws net.sf.saxon.s9api.SaxonApiException

      Creates an XBRLDocument form a Source object that can be used to obtain the XML nodes of the document content.

      This creator just creates the XBRLDocument and passes sets the document content to the nodes read from the Source

      Parameters:
        `dts` - The DTSContainer under which the document will be created
        `xmlSource` - the XML Source
      Throws:
        `net.sf.saxon.s9api.SaxonApiException` - in case of problems reading the source document

  - ### Method Detail

    - #### getDocument

          public net.sf.saxon.s9api.XdmNode getDocument()

      Description copied from class: `XMLFragment`
      Returns the surrounding XML Node.
      Overrides:
        `getDocument` in class `XMLFragment`
      Returns:
        NodeInfo

    - #### setDocumentAndReload

          public void setDocumentAndReload(net.sf.saxon.s9api.XdmNode node)
                                    throws XBRLInconsistentDTSException,
                                           com.rs.lic.LicenseVerificationException

      Description copied from class: `XMLFragment`
      This method is called by the XMLFragment object each time the surrounding XdmNode object is set. This happens internally by the XBRL API after XML Schema validation is performed so the surrounding XML nodes acquire type information.

      Overwrite this method in parent objects in order to refresh objects that depends on the surrounding XML nodes.

      Overrides:
        `setDocumentAndReload` in class `XMLFragment`
      Parameters:
        `node` - the new XdmNode
      Throws:
        `XBRLInconsistentDTSException` - the XBRL inconsistent dts exception
        `com.rs.lic.LicenseVerificationException` - the license verification exception

    - #### equals

          public boolean equals(java.lang.Object oe)

      Description copied from class: `XMLFragment`
      Sets a new XPathFunctionResolver for this object.
      Overrides:
        `equals` in class `XMLDocumentURI`
      Parameters:
        `oe` - the other
      Returns:
        true, if successful

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `XMLDocumentURI`

    - #### createDocument

          public static XMLDocumentURI createDocument(DTSContainer dts,
                                      java.net.URI baseURI,
                                      java.net.URI theURI,
                                      javax.xml.transform.Source source,
                                      boolean addToCache,
                                      XBRLDTSDocument parent)
                                               throws DTSDiscoveryException,
                                                      com.rs.lic.LicenseVerificationException

      Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type if the document is not a linkbase, schema or xbrl instance returns null.

      The Document may not be part of any DTS.

      The Document is first obtained from the cache. If it is not there, then it is loaded from the URI and stored into the cache.

      the source parameter is an javax.xml.transform.Source object from which the document will be generated

      Parameters:
        `dts` - the dts
        `baseURI` - the base uri
        `theURI` - the the uri
        `source` - the source
        `addToCache` - the add to cache
        `parent` - the parent
      Returns:
        XMLDocumentURI object
      Throws:
        `DTSDiscoveryException` - the DTS discovery exception
        `com.rs.lic.LicenseVerificationException` - the license verification exception
      Since:
        2.6.4

    - #### createDocument

          public static XMLDocumentURI createDocument(XMLDocumentURI node,
                                      boolean addToCache)
                                               throws com.rs.lic.LicenseVerificationException,
                                                      DTSDiscoveryException

      Transforms the XMLDocumentURI in the node parameter into a XBRLDocument Linkbase, Taxonomy or Instance depending on the root node .
      Parameters:
        `node` - the XMLDocumentURI object to transform
        `addToCache` - true if the document MUST be added to the cache
      Returns:
        a XMLDocumentURI
      Throws:
        `com.rs.lic.LicenseVerificationException` - the license verification exception
        `DTSDiscoveryException` - the DTS discovery exception

    - #### getDTSDocumentType

          public abstract int getDTSDocumentType()

      Returns the type of DTS Document.
      Returns:
        DTSDocument.INSTANCE, DTSDocument.TAXONOMY or DTSDocument.LINKBASE

    - #### getDTSDocumentTypeName

          public abstract java.lang.String getDTSDocumentTypeName()

      Gets the DTS document type name.
      Returns:
        the DTS document type name

    - #### discoverDTS

          public abstract void discoverDTS(XBRLDTSDocument parent)
                                    throws DTSDiscoveryException,
                                           com.rs.lic.LicenseVerificationException

      All derived classes MUST implement this method and provide the functionality according to section 3.2 of the XBRL 2.1 specification
      Specified by:
        `discoverDTS` in interface `XBRLDTSDocument`
      Overrides:
        `discoverDTS` in class `XMLDocumentURI`
      Parameters:
        `parent` - the parent
      Throws:
        `DTSDiscoveryException` - the DTS discovery exception
        `com.rs.lic.LicenseVerificationException` - the license verification exception

    - #### readInfoset

          public abstract void readInfoset()
                                    throws XBRLValidationException

      Read all structures that builds the infoset.
      Throws:
        `XBRLValidationException` - the XBRL validation exception

    - #### getDTS

          public void getDTS()
                      throws DTSDiscoveryException,
                             com.rs.lic.LicenseVerificationException

      Launches the rules for DTSDiscovery process that will eventually add more objects to the DTSContainer.
      Throws:
        `DTSDiscoveryException` - the DTS discovery exception
        `com.rs.lic.LicenseVerificationException` - the license verification exception

    - #### getExtendedLinks

          public java.util.Iterator<XBRLExtendedLink> getExtendedLinks()

      Returns an iterator over all extended links on this container. If the container may be an XBRLInstance, an XBRLTaxonomy or an XBRLLinkbase.
      Returns:
        Iterator<XBRLExtendedLink> instance

    - #### getExtendedLinks

          public java.util.Iterator<XBRLExtendedLink> getExtendedLinks(XBRLRoleType role)

      Returns an iterator over all extended links on this container filtered by the specific role type indicated in the role parameter. If the container may be an XBRLInstance, an XBRLTaxonomy or an XBRLLinkbase.
      Parameters:
        `role` - the XBRLRoleType for filtering
      Returns:
        Iterator<XBRLExtendedLink> instance

    - #### getExtendedLink

          public XBRLExtendedLink getExtendedLink(net.sf.saxon.s9api.XdmNode key)
                                           throws DTSDiscoveryException

      Gets the extended link.
      Parameters:
        `key` - the key
      Returns:
        the extended link
      Throws:
        `DTSDiscoveryException` - the DTS discovery exception

    - #### changeExtendedLinkKey

          public void changeExtendedLinkKey(net.sf.saxon.s9api.XdmNode oldKey,
                                   net.sf.saxon.s9api.XdmNode newKey,
                                   XBRLExtendedLink link)

      Change extended link key.
      Parameters:
        `oldKey` - the old key
        `newKey` - the new key
        `link` - the link

    - #### addExtendedLink

          public void addExtendedLink(XBRLExtendedLink newExtendedLink)

      Adds the extended link.
      Parameters:
        `newExtendedLink` - the new extended link

    - #### removeExtendedLink

          public void removeExtendedLink(XBRLExtendedLink link)

      Removes the extended link.
      Parameters:
        `link` - the link

    - #### getParents

          public java.util.Iterator<XBRLDocument> getParents()

      Access to the [Parents] property.
      Returns:
        Iterator

    - #### addParent

          public void addParent(XBRLDocument parent)

      Add a new XBRLDocument as parent of this document.
      Parameters:
        `parent` - the parent

    - #### delParent

          public void delParent(XBRLDocument parent)

      Del parent.
      Parameters:
        `parent` - the parent

    - #### addIdOfElement

          public boolean addIdOfElement(XMLFragment newElement)

      Adds the id of newElement to the set of IDs stored in this document. Two elements cannot have the same ID because this is forbidden according to XML rules.

      Don't call this method from inside XMLFragment.getId() or methods overridden by subclasses. Call the `addIdOfElement(XMLFragment, String)` method instead.

      Parameters:
        `newElement` - element from which the ID will be obtained
      Returns:
        boolean, true if the element is new or is a substitute of previous element and contains an id and and has been added or has replaced previous element. false if the element already exist and is the same element or has no id

    - #### addIdOfElement

          public boolean addIdOfElement(XMLFragment newElement,
                               java.lang.String id)

      Adds the id of newElement to the set of IDs stored in this document. Two elements cannot have the same ID because this is forbidden according to XML rules.
      Parameters:
        `newElement` - element to be added. The ID will not be obtained from the node
        `id` - to be set for this XMLFragment. The ID must be the real id set on this element node in the id attribute
      Returns:
        boolean, true if the element is new or is a substitute of previous element and contains an id and and has been added or has replaced previous element. false if the element already exist and is the same element or has no id

    - #### removeIdOfElement

          public void removeIdOfElement(XMLFragment element)

      Removes the id of element.
      Parameters:
        `element` - the element

    - #### changeElementId

          public void changeElementId(XMLFragment newEl,
                             java.lang.String oldId,
                             java.lang.String newId)
                               throws XBRLInconsistentDTSException

      Changes the key of an element in the internal itemsById hashtable but does not change the id on the target element.
      Parameters:
        `newEl` - element definition
        `oldId` - the old id
        `newId` - the new ID of the element in the table
      Throws:
        `XBRLInconsistentDTSException` - the XBRL inconsistent dts exception

    - #### getAllUsedIds

          public java.util.Iterator<java.lang.String> getAllUsedIds()

      This method returns an iterator over all ids used by elements in this document.
      Returns:
        Iterator<String>
      Since:
        2.6.5

    - #### isIdUsed

          public boolean isIdUsed(java.lang.String id)

      This method returns true if the id indicated as a parameter corresponds to an XMLFragment in this XBRLDocument.
      Parameters:
        `id` - String
      Returns:
        boolean value
      Since:
        2.6.5

    - #### getElementById

          public XMLFragment getElementById(java.lang.String id)

      This method returns the XMLFragment associated to the id received as a parameter.

      Subclasses of this class may contain methods that returns the appropriate object for an id. Use this method as a last resort if you don't know or you don't care about the returned object type.

      Parameters:
        `id` - string, the id of the element to retrieve
      Returns:
        an XMLFragment or null if nothing in this document is indexed under that id
      Since:
        2.6.5

    - #### save

          public void save(boolean relativize)
                    throws XBRLSerializationException

      Save the file to the indicated document URI Directories in the path of the file name are created automatically .
      Parameters:
        `relativize` - true if elements inside the file would be relative to the file or base URI
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception

    - #### isContentModified

          public boolean isContentModified()

      Returns true if the document content has been modified. The modified status is set automatically by the API when a fact value is changed or a new fact is added or deleted to the instance etc. This flag is, therefore read only.

      When the content is modified the surrounding XML document might not be in sync with the object model. A call to `updateXML(boolean)` will synchronize both models.

      Returns:
        boolean value
      See Also:
        `updateXML(boolean)`, `isDocumentModified()`

    - #### isDocumentModified

          public boolean isDocumentModified()

      Returns true if the content is in sync with the surrounding XML and the document matches the content of the documentURI (the document has not been changed or has been saved)
      Returns:
        boolean value
      See Also:
        `isContentModified()`

    - #### updateXML

          public boolean updateXML(boolean relativize)
                            throws XBRLSerializationException

      Updates the XML content of the XBRLDocument so the next call to save or to XdmNode getDocument() will obtain a fresh copy with all changes made in the object library. note this method does not propagate the changes inside the object in the XBRL api that are down on this XBRLDocument. so formula validation accessing facts will not work.
      Parameters:
        `relativize` - boolean value indicating if URLs (in locators, linkbaseRefs, etc...) will be relativized using the document URL as a base URL.
      Returns:
        true if the document has been updated, false if the document has not been modified
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception
      Since:
        2.6.12

    - #### moveNamespacesUp

          public static void moveNamespacesUp(org.jdom.Document jdomDocument)

      Internal method used during serialization of XML files. Not intented to be used by applications Searches down the tree of nodes and move namespace declarations up to the root element if there are no conflicting namespace prefixes. Does not remove any namespace declaration because prefixes may be used inside text nodes
      Parameters:
        `jdomDocument` - the jdom document

    - #### moveNamespacesUp

          public static void moveNamespacesUp(net.sf.saxon.tree.linked.DocumentImpl document)

      Internal method used during serialization of XML files. Not intented to be used by applications Searches down the tree of nodes and move namespace declarations up to the root element if there are no conflicting namespace prefixes. Does not remove any namespace declaration because prefixes may be used inside text nodes
      Parameters:
        `document` - the document

    - #### generateDocNode

          public abstract org.jdom.Document generateDocNode(boolean relativize,
                                          java.net.URI base)
                                                     throws XBRLSerializationException

      This class has to be implemented by objects derived from XBRLDocument and must return a org.jdom.Document node with the content of this XBRLDocument object
      Parameters:
        `relativize` - boolean indicating if all URIs must be relativized
        `base` - URI the base uri to relativize other URIs
      Returns:
        org.jdom.Document
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception

    - #### getComments

          public java.util.Collection<java.lang.String> getComments()

      Access to the comments in the file.
      Returns:
        Collection

    - #### setComments

          public void setComments(java.util.Collection<java.lang.String> fileComments)

      Sets a new collection of comments for this file. The new comments will be serialized to the file during a call to the generateDocNode method.
      Parameters:
        `fileComments` - Collection

    - #### clear

          public void clear()
                     throws java.lang.Throwable

      Description copied from class: `XMLFragment`
      Frees-up used memory

      This method should not be invoqued on live objects in the DTS. It is automatically invoqued by the API when an object is no longer used and referenced by other objects. It is save not to call it directly.

      Specified by:
        `clear` in interface `XBRLDTSDocument`
      Overrides:
        `clear` in class `XMLDocumentURI`
      Throws:
        `java.lang.Throwable` - the throwable