Package org.arakhne.afc.inputoutput.xml
Interface XMLBuilder
-
public interface XMLBuilderThis 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AttrcreateAttribute(String name)Creates anAttrof the given name.default AttrcreateAttributeNS(String namespaceURI, String qualifiedName)Creates an attribute of the given qualified name and namespace URI.default CDATASectioncreateCDATASection(String data)Creates aCDATASectionnode whose value is the specified string.default CommentcreateComment(String data)Creates aCommentnode given the specified string.default DocumentFragmentcreateDocumentFragment()Creates an emptyDocumentFragmentobject.default ElementcreateElement(String tagName)Creates an element of the type specified.default ElementcreateElementNS(String namespaceURI, String qualifiedName)Creates an element of the given qualified name and namespace URI.default EntityReferencecreateEntityReference(String name)Creates anEntityReferenceobject.default ProcessingInstructioncreateProcessingInstruction(String target, String data)Creates aProcessingInstructionnode given the specified name and data strings.default ElementcreateTextElement(String tagName, String data)Creates an element that contains the given text.default TextcreateTextNode(String data)Creates aTextnode given the specified string.DocumentgetDocument()Replies the document associated to this builder.
-
-
-
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 theElementinterface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values,Attrnodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use thecreateElementNSmethod.- 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
Elementobject with thenodeNameattribute set totagName, andlocalName,prefix, andnamespaceURIset tonull. - Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
-
createDocumentFragment
default DocumentFragment createDocumentFragment()
Creates an emptyDocumentFragmentobject.- Returns:
- A new
DocumentFragment.
-
createTextNode
default Text createTextNode(String data)
Creates aTextnode given the specified string.- Parameters:
data- The data for the node.- Returns:
- The new
Textobject. - 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
Elementinterface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values,Attrnodes 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 aCommentnode given the specified string.- Parameters:
data- The data for the node.- Returns:
- The new
Commentobject.
-
createCDATASection
default CDATASection createCDATASection(String data) throws DOMException
Creates aCDATASectionnode whose value is the specified string.- Parameters:
data- The data for theCDATASectioncontents.- Returns:
- The new
CDATASectionobject. - Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
-
createProcessingInstruction
default ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
Creates aProcessingInstructionnode given the specified name and data strings.- Parameters:
target- The target part of the processing instruction.UnlikeDocument.createElementNSorDocument.createAttributeNS, no namespace well-formed checking is done on the target name. Applications should invokeDocument.normalizeDocument()with the parameter " namespaces" set totruein order to ensure that the target name is namespace well-formed.data- The data for the node.- Returns:
- The new
ProcessingInstructionobject. - Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified target is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
-
createAttribute
default Attr createAttribute(String name) throws DOMException
Creates anAttrof the given name. Note that theAttrinstance can then be set on anElementusing thesetAttributeNodemethod.
To create an attribute with a qualified name and namespace URI, use thecreateAttributeNSmethod.- Parameters:
name- The name of the attribute.- Returns:
- A new
Attrobject with thenodeNameattribute set toname, andlocalName,prefix, andnamespaceURIset tonull. 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 theDocument.xmlVersionattribute.
-
createEntityReference
default EntityReference createEntityReference(String name) throws DOMException
Creates anEntityReferenceobject. In addition, if the referenced entity is known, the child list of theEntityReferencenode is made the same as that of the correspondingEntitynode.Note: If any descendant of the
Entitynode has an unbound namespace prefix, the corresponding descendant of the createdEntityReferencenode is also unbound; (itsnamespaceURIisnull). 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.UnlikeDocument.createElementNSorDocument.createAttributeNS, no namespace well-formed checking is done on the entity name. Applications should invokeDocument.normalizeDocument()with the parameter " namespaces" set totruein order to ensure that the entity name is namespace well-formed.- Returns:
- The new
EntityReferenceobject. - Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
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 valuenullas 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
Elementobject with the following attributes:Attribute Value Node.nodeNamequalifiedNameNode.namespaceURInamespaceURINode.prefixprefix, extracted from qualifiedName, ornullif there is no prefixNode.localNamelocal name, extracted from qualifiedNameElement.tagNamequalifiedName - Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specifiedqualifiedNameis not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
NAMESPACE_ERR: Raised if thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, or if thequalifiedNamehas a prefix that is "xml" and thenamespaceURIis different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces], or if thequalifiedNameor its prefix is "xmlns" and thenamespaceURIis different from "http://www.w3.org/2000/xmlns/", or if thenamespaceURIis "http://www.w3.org/2000/xmlns/" and neither thequalifiedNamenor 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 valuenullas thenamespaceURIparameter 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
Attrobject with the following attributes:Attribute Value Node.nodeNamequalifiedName Node.namespaceURInamespaceURINode.prefixprefix, extracted from qualifiedName, ornullif there is no prefixNode.localNamelocal name, extracted from qualifiedNameAttr.namequalifiedNameNode.nodeValuethe empty string - Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specifiedqualifiedNameis not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
NAMESPACE_ERR: Raised if thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, if thequalifiedNamehas a prefix that is "xml" and thenamespaceURIis different from " http://www.w3.org/XML/1998/namespace", if thequalifiedNameor its prefix is "xmlns" and thenamespaceURIis different from "http://www.w3.org/2000/xmlns/", or if thenamespaceURIis "http://www.w3.org/2000/xmlns/" and neither thequalifiedNamenor 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
-
-