Interface AuthorSchemaManager


  • @API(type=NOT_EXTENDABLE,
         src=PUBLIC)
    public interface AuthorSchemaManager
    Author schema manager. Provides support for obtaining information about what elements, attributes can be inserted in a given context.
    • Field Detail

      • VALIDATION_MODE_LAX

        static final short VALIDATION_MODE_LAX
        Defines LAX validation of the elements from a fragment in a given context (they are found in the list of possible children of the context element).
        See Also:
        Constant Field Values
      • VALIDATION_MODE_STRICT_FIRST_CHILD_LAX_OTHERS

        static final short VALIDATION_MODE_STRICT_FIRST_CHILD_LAX_OTHERS
        Defines STRICT validation for the first element from the fragment in a given context (it is accepted by the parent in the exact position he is about to be inserted) and LAX validation for all other siblings (they are found in the list of possible children of the context element).
        See Also:
        Constant Field Values
    • Method Detail

      • canInsertDocumentFragment

        boolean canInsertDocumentFragment​(AuthorDocumentFragment fragment,
                                          int offset,
                                          short validationMode)
        Check if the given fragment can be inserted at the given offset with respect to the given validation mode.
        Parameters:
        fragment - Author fragment.
        offset - The offset where to check if the fragment can be inserted.
        validationMode - VALIDATION_MODE_LAX or VALIDATION_MODE_STRICT_FIRST_CHILD_LAX_OTHERS.
        Returns:
        true if the fragment can be inserted with respect to the given validation mode.
      • canInsertDocumentFragments

        boolean canInsertDocumentFragments​(AuthorDocumentFragment[] fragments,
                                           int offset,
                                           short validationMode)
        Check if the given fragments can be inserted at the given offset with respect to the given validation mode.
        Parameters:
        fragments - Author fragment.
        offset - The offset where to check if the fragments can be inserted.
        validationMode - VALIDATION_MODE_LAX or VALIDATION_MODE_STRICT_FIRST_CHILD_LAX_OTHERS.
        Returns:
        true if the fragments can be inserted with respect to the given validation mode.
      • canInsertText

        boolean canInsertText​(int offset)
        Check if the element at the given offset accepts text (in other words element content type is not ELEMENT ONLY or EMPTY).
        Parameters:
        offset - The offset where to check if text can be inserted.
        Returns:
        true if text can be inserted at the given offset.
      • canInsertDocumentFragments

        boolean canInsertDocumentFragments​(AuthorDocumentFragment[] fragments,
                                           WhatElementsCanGoHereContext insertionContext,
                                           short validationMode)
        Check if the given fragments can be inserted in the given context with respect to the given validation mode. The insertion context will also be used for resolving namespaces for the nodes inside the fragment.
        Parameters:
        fragments - Author fragments.
        insertionContext - Insertion context.
        validationMode - VALIDATION_MODE_LAX or VALIDATION_MODE_STRICT_FIRST_CHILD_LAX_OTHERS.
        Returns:
        true if the fragment can be inserted with respect to the given validation mode.
      • createWhatElementsCanGoHereContext

        WhatElementsCanGoHereContext createWhatElementsCanGoHereContext​(int offset)
                                                                 throws javax.swing.text.BadLocationException
        Create an element context for the given offset.
        Parameters:
        offset - Offset in document for which to create an element context.
        Returns:
        The element context. null will be returned if node at given offset is not an element.
        Throws:
        javax.swing.text.BadLocationException - When the offset is below zero or greater than the content.
      • createWhatPossibleValuesHasAttributeContext

        WhatPossibleValuesHasAttributeContext createWhatPossibleValuesHasAttributeContext​(AuthorElement element,
                                                                                          java.lang.String attributeName)
        Create an attribute values context for the given element and attribute name.
        Parameters:
        element - The element whose attribute values interest us.
        attributeName - The name of attribute to create context.
        Returns:
        An attribute values context.
      • getAuthorSchemaAwareOptions

        ro.sync.ecss.component.AuthorSchemaAwareOptions getAuthorSchemaAwareOptions()
        Returns:
        Schema aware options values.
      • whatAttributesCanGoHere

        java.util.List<CIAttribute> whatAttributesCanGoHere​(WhatAttributesCanGoHereContext whatAttributesCanGoHereContext)
        Examines the grammar and decides what attributes can be inserted in the parent element. The returned list of attributes does not include attribute names which are already set on the element.
        Parameters:
        whatAttributesCanGoHereContext - the context for the call. It must have:
        • elementName the name of the element in which will be done the insertion.
        • proxyNamespaceMapping the proxy - uri mappings defined before the insertion point.
        • previousAttributesNames the names of the existing attributes in the element, attributes that are before the insertion point.
        Returns:
        a list of attributes or null if there is none. Null value is also returned when schema is not specified.
        See Also:
        createWhatAttributesCanGoHereContext(AuthorElement)
      • whatElementsCanGoHere

        java.util.List<CIElement> whatElementsCanGoHere​(WhatElementsCanGoHereContext whatElementsCanGoHereContext)
        Examines the grammar and decides what elements can be inserted in the parent element, after the list of child names.
        Parameters:
        whatElementsCanGoHereContext - the context for the call. It must have:
        • parentElementName the qName of the parent element
        • previousElementNames the list of qNames of the previous elements
        • previousElementNamespaces the list of qNames of the previous elements
        • proxyNamespaceMapping the proxy - uri mappings defined before the insertion point.
        Returns:
        a list of CIElement representing the elements, or null if there is none. Null value is also returned when schema is not specified.
      • whatPossibleValuesHasAttribute

        java.util.List<CIValue> whatPossibleValuesHasAttribute​(WhatPossibleValuesHasAttributeContext ctxt)
        Queries the possible values of an element attribute. If the attribute type was an enumeration, then a list with the tokens of the enumeration will be returned.
        Parameters:
        ctxt - The context WhatPossiBleValuesHasAttributeContext.
        Returns:
        the list of CIValue representing possible values of the attribute or null if they are not known. Null value is also returned when schema is not specified.
      • whatPossibleValuesHasElement

        java.util.List<CIValue> whatPossibleValuesHasElement​(WhatElementsCanGoHereContext ctxt)
        Queries the possible values of an element. If the element type was an enumeration, then a list with the tokens of the enumeration will be returned.
        Parameters:
        ctxt - The context.
        Returns:
        a list of attribute values as CIValue or null if there is none or no schema is specified. The list of values can contain duplicates.
      • getGrammarURLs

        java.net.URL[] getGrammarURLs()
        Get the array of URLs of the loaded DTD or XML Schema. These URLs were set using one of the update methods, and includes the URLs that were collected from the calls of the update(InputSource[]) methods.
        Returns:
        The URLs of the schemas loaded, or null if there was nothing loaded.
      • getAttributeDescription

        CIAttribute getAttributeDescription​(WhatPossibleValuesHasAttributeContext ctxt)
        Get the description of an attribute. This model must be human readable.
        Parameters:
        ctxt - the context describing the target attribute.
        Returns:
        a hash describing the model of the element.
      • getEntities

        java.util.List<NameValue> getEntities()
        Gets the context-independent list of entities declared in the document's DOCTYPE declaration.

        If the DOCTYPE declaration is not changed, the document should not be processed each time this method is called.

        Returns:
        a list of name value representing the entities, or null if there is none. The reference of the list is changed on update.
      • getElementDescription

        CIElement getElementDescription​(Context ctxt)
        Get the description of an element. This model must be human readable.
        Parameters:
        ctxt - the context describing the target element. It contains:
        • The element names stack, having at top the current element name.
        • The element namespaces stack, having at top the current element namespace.
        Returns:
        a description the model of the element, or null.
      • isElementDescriptionSupported

        boolean isElementDescriptionSupported()
        If true the element description(model) support is available, otherwise not.
        Returns:
        True if element description is supported by the SM.
      • getChildrenElements

        java.util.List<CIElement> getChildrenElements​(WhatElementsCanGoHereContext context)
        Get the elements that can be children of the element for which the context was built.
        Parameters:
        context - The element context.
        Returns:
        A list with CIElements that are allowed as children.
      • isLearnSchema

        boolean isLearnSchema()
        Returns true if schema was learned by Oxygen only from the structure of the XML document. This only happens when Oxygen does not detect an associated schema for the XML document and learns the structure of the XML file directly.
        Returns:
        Return true if schema was learned by Oxygen only from the structure of the XML document.
      • hasLoadingErrors

        boolean hasLoadingErrors()
        Returns:
        Return true if there were errors when loading schema document(missing, not wellformed, not valid schema).
      • createAuthorDocumentFragment

        AuthorDocumentFragment createAuthorDocumentFragment​(CIElement element)
                                                     throws javax.swing.text.BadLocationException
        Create an author document fragment from a CIElement
        Parameters:
        element - The CI Element from which to create a full fragment which can be inserted
        Returns:
        The created document fragment.
        Throws:
        javax.swing.text.BadLocationException
        Since:
        11.2
      • getGlobalElements

        java.util.List<CIElement> getGlobalElements()
        Get all the names of global elements defined in the associated grammar.
        Returns:
        A list of CIElements.
        Since:
        11.2
      • getAllPossibleElements

        java.util.List<CIElement> getAllPossibleElements()
        Get all the elements, including eventual local ones. We need this for instance if providing content completion proposals as a result schema manager for XSLT.
        Returns:
        A list of CIElement.
        Since:
        12.1
      • getElementToParentsMap

        java.util.Map<javax.xml.namespace.QName,​java.util.Collection<javax.xml.namespace.QName>> getElementToParentsMap​(NamespaceContext namespaceContext)
        Returns a graph with the links from a node to its potential parents.
        Parameters:
        namespaceContext - The namespace declarations active in the document context where this information is requested. Can be null.
        Returns:
        Returns a graph with the links from a node to its potential parents or null if this information is unavailable for this type of schema.
        Since:
        18
      • getElementToParentsMap

        java.util.Map<javax.xml.namespace.QName,​java.util.Collection<javax.xml.namespace.QName>> getElementToParentsMap​(AuthorNode nodeContext)
        Returns a graph with the links from a node to its potential parents.
        Parameters:
        nodeContext - The node context where this information is requested. Can be null.
        Returns:
        Returns a graph with the links from a node to its potential parents or null if this information is unavailable for this type of schema.
        Since:
        23
      • getGlobalElements

        java.util.List<CIElement> getGlobalElements​(AuthorNode nodeContext)
        Get all the names of global elements defined in the associated grammar.
        Parameters:
        nodeContext - The context node
        Returns:
        A list of CIElements.
        Since:
        23
      • isRequiredElement

        boolean isRequiredElement​(AuthorElement element)
        Check if the given element is required, based on the schema rules.
        Parameters:
        element - the element for which the check is performed.
        Returns:
        true if the element is defined as required in the schema, false otherwise.
        Since:
        19
      • getSchemaRepresentationAsJson

        java.lang.String getSchemaRepresentationAsJson()
        Returns the schema representation as JSON.
        Returns:
        A JSON representation of the schema, may be an empty JSON if the schema type is not supported.
        Since:
        21