Package commonj.sdo.helper

# Interface XMLDocument

public interface XMLDocument
Represents an XML Document containing a tree of DataObjects. An example XMLDocument fragment is: invalid input: '<'?xml version="1.0"?> created from this XML Schema fragment: invalid input: '<'xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> invalid input: '<'xsd:element name="purchaseOrder" type="PurchaseOrderType"/> invalid input: '<'xsd:complexType name="PurchaseOrderType"> Upon loading this XMLDocument: DataObject is an instance of Type PurchaseOrderType. RootElementURI is null because the XSD has no targetNamespace URI. RootElementName is purchaseOrder. Encoding is null because the document did not specify an encoding. XMLDeclaration is true because the document contained an XML declaration. XMLVersion is 1.0 SchemaLocation and noNamespaceSchemaLocation are null because they are not specified in the document. When saving the root element, if the type of the root dataObject is not the type of global element specified by rootElementURI and rootElementName, or if a global element does not exist for rootElementURI and rootElementName, then an xsi:type declaration is written to record the root DataObject's Type. When loading the root element and an xsi:type declaration is found it is used as the type of the root DataObject. In this case, if validation is not being performed, it is not an error if the rootElementName is not a global element.

## Method Summary

Modifier and Type
Method
Description
`String`
`getEncoding()`
Return the XML encoding of the document, or null if not specified.
`String`
`getNoNamespaceSchemaLocation()`
Return the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.
`String`
`getRootElementName()`
Return the name of the root element.
`String`
`getRootElementURI()`
Return the targetNamespace URI for the root element.
`DataObject`
`getRootObject()`
Return the root DataObject for the XMLDocument.
`String`
`getSchemaLocation()`
Return the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.
`String`
`getXMLVersion()`
Return the XML version of the document, or null if not specified.
`boolean`
`isXMLDeclaration()`
Return the XML declaration of the document.
`void`
`setEncoding(String encoding)`
Set the XML encoding of the document, or null if not specified.
`void`
`setNoNamespaceSchemaLocation(String schemaLocation)`
Sets the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.
`void`
`setSchemaLocation(String schemaLocation)`
Sets the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.
`void`
`setXMLDeclaration(boolean xmlDeclaration)`
Set the XML declaration version of the document.
`void`
`setXMLVersion(String xmlVersion)`
Set the XML version of the document, or null if not specified.

## Method Details

### getRootObject

DataObject getRootObject()
Return the root DataObject for the XMLDocument.

Returns:
  root DataObject for the XMLDocument.

### getRootElementURI

String getRootElementURI()
Return the targetNamespace URI for the root element. If there is no targetNamespace URI, the value is null. The root element is a global element of the XML Schema with a type compatible to the DataObject.

Returns:
  the targetNamespace URI for the root element.

### getRootElementName

String getRootElementName()
Return the name of the root element. The root element is a global element of the XML Schema with a type compatible to the DataObject.

Returns:
  the name of the root element.

### getEncoding

String getEncoding()
Return the XML encoding of the document, or null if not specified. The default value is "UTF-8". Specification of other values is implementation-dependent.

Returns:
  the XML encoding of the document, or null if not specified.

### setEncoding

void setEncoding(String encoding)
Set the XML encoding of the document, or null if not specified.

Parameters:
  `encoding` -

### isXMLDeclaration

boolean isXMLDeclaration()
Return the XML declaration of the document. If true, XMLHelper save() will produce a declaration of the form: invalid input: '<'?xml version="1.0" encoding="UTF-8"?> Encoding will be suppressed if getEncoding() is null. The default value is true.

Returns:
  the XML declaration of the document.

### setXMLDeclaration

void setXMLDeclaration(boolean xmlDeclaration)
Set the XML declaration version of the document.

Parameters:
  `xmlDeclaration` - the XML declaration version of the document.

### getXMLVersion

String getXMLVersion()
Return the XML version of the document, or null if not specified. The default value is "1.0". Specification of other values is implementation-dependent.

Returns:
  the XML version of the document, or null if not specified.

### setXMLVersion

void setXMLVersion(String xmlVersion)
Set the XML version of the document, or null if not specified.

Parameters:
  `xmlVersion` - the XML version of the document, or null if not specified.

### getSchemaLocation

String getSchemaLocation()
Return the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.

Returns:
  the value of the schemaLocation declaration, or null if not present.

### setSchemaLocation

void setSchemaLocation(String schemaLocation)
Sets the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.

Parameters:
  `schemaLocation` - the value of the schemaLocation declaration, or null.

### getNoNamespaceSchemaLocation

String getNoNamespaceSchemaLocation()
Return the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.

Returns:
  the value of the noNamespaceSchemaLocation declaration, or null if not present.

### setNoNamespaceSchemaLocation

void setNoNamespaceSchemaLocation(String schemaLocation)
Sets the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.

Parameters:
  `schemaLocation` - the value of the noNamespaceSchemaLocation declaration, or null.