Interface XMLBuilder


  • public interface XMLBuilder
    This interface permits to create several XML elements.
    Since:
    14.0
    Version:
    17.0 2020-01-04 14:41:40
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    inputoutput
    • Method Detail

      • getDocument

        Document getDocument()
                      throws DOMException
        Replies the document associated to this builder.
        Returns:
        the document associated to this builder.
        Throws:
        DOMException - if it is impossible to get the document.
      • createElement

        default Element createElement​(String tagName)
                               throws DOMException
        Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
        In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
        To create an element with a qualified name and namespace URI, use the createElementNS method.
        Parameters:
        tagName - The name of the element type to instantiate. For XML, this is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use. In that case, the name is mapped to the canonical form of that markup by the DOM implementation.
        Returns:
        A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
      • createDocumentFragment

        default DocumentFragment createDocumentFragment()
        Creates an empty DocumentFragment object.
        Returns:
        A new DocumentFragment.
      • createTextNode

        default Text createTextNode​(String data)
        Creates a Text node given the specified string.
        Parameters:
        data - The data for the node.
        Returns:
        The new Text object.
        See Also:
        createTextElement(String, String)
      • createTextElement

        default Element createTextElement​(String tagName,
                                          String data)
        Creates an element that contains the given text.

        Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
        In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.

        This function is equivalent to:

        
         Element e = createElement(tagName);
         Text t = createText(data);
         e.appendChild(t);
         return e;
         
        Parameters:
        tagName - The name of the element type to instantiate. For XML, this is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use. In that case, the name is mapped to the canonical form of that markup by the DOM implementation.
        data - The data for the node.
        Returns:
        the Element with the Text inside.
        See Also:
        createTextNode(String), createElement(String)
      • createComment

        default Comment createComment​(String data)
        Creates a Comment node given the specified string.
        Parameters:
        data - The data for the node.
        Returns:
        The new Comment object.
      • createCDATASection

        default CDATASection createCDATASection​(String data)
                                         throws DOMException
        Creates a CDATASection node whose value is the specified string.
        Parameters:
        data - The data for the CDATASection contents.
        Returns:
        The new CDATASection object.
        Throws:
        DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
      • createProcessingInstruction

        default ProcessingInstruction createProcessingInstruction​(String target,
                                                                  String data)
                                                           throws DOMException
        Creates a ProcessingInstruction node given the specified name and data strings.
        Parameters:
        target - The target part of the processing instruction.Unlike Document.createElementNS or Document.createAttributeNS, no namespace well-formed checking is done on the target name. Applications should invoke Document.normalizeDocument() with the parameter " namespaces" set to true in order to ensure that the target name is namespace well-formed.
        data - The data for the node.
        Returns:
        The new ProcessingInstruction object.
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified target is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
        NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
      • createAttribute

        default Attr createAttribute​(String name)
                              throws DOMException
        Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
        To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
        Parameters:
        name - The name of the attribute.
        Returns:
        A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
      • createEntityReference

        default EntityReference createEntityReference​(String name)
                                               throws DOMException
        Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.

        Note: If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 and 3 do not support any mechanism to resolve namespace prefixes in this case.

        Parameters:
        name - The name of the entity to reference.Unlike Document.createElementNS or Document.createAttributeNS, no namespace well-formed checking is done on the entity name. Applications should invoke Document.normalizeDocument() with the parameter " namespaces" set to true in order to ensure that the entity name is namespace well-formed.
        Returns:
        The new EntityReference object.
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
        NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
      • createElementNS

        default Element createElementNS​(String namespaceURI,
                                        String qualifiedName)
                                 throws DOMException
        Creates an element of the given qualified name and namespace URI.
        Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
        Parameters:
        namespaceURI - The namespace URI of the element to create.
        qualifiedName - The qualified name of the element type to instantiate.
        Returns:
        A new Element object with the following attributes:
        Attribute Value
        Node.nodeName qualifiedName
        Node.namespaceURI namespaceURI
        Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
        Node.localName local name, extracted from qualifiedName
        Element.tagName qualifiedName
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualifiedName is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
        NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces], or if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".
        NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, since namespaces were defined by XML.
        Since:
        DOM Level 2
      • createAttributeNS

        default Attr createAttributeNS​(String namespaceURI,
                                       String qualifiedName)
                                throws DOMException
        Creates an attribute of the given qualified name and namespace URI.
        Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
        Parameters:
        namespaceURI - The namespace URI of the attribute to create.
        qualifiedName - The qualified name of the attribute to instantiate.
        Returns:
        A new Attr object with the following attributes:
        Attribute Value
        Node.nodeName qualifiedName
        Node.namespaceURI namespaceURI
        Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
        Node.localName local name, extracted from qualifiedName
        Attr.name qualifiedName
        Node.nodeValue the empty string
        Throws:
        DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualifiedName is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
        NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns".
        NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, since namespaces were defined by XML.
        Since:
        DOM Level 2