- All Known Subinterfaces:
SDOXMLHelper
- All Known Implementing Classes:
JAXBXMLHelper
,SDOXMLHelperDelegate
,SDOXMLHelperDelegator
public interface XMLHelper
A helper to convert XML documents into DataObects and
DataObjects into XML documnets.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateDocument
(DataObject dataObject, String rootElementURI, String rootElementName) Creates an XMLDocument with the specified XML rootElement for the DataObject.load
(InputStream inputStream) Creates and returns an XMLDocument from the inputStream.load
(InputStream inputStream, String locationURI, Object options) Creates and returns an XMLDocument from the inputStream.Creates and returns an XMLDocument from the inputReader.Creates and returns an XMLDocument from the input String.Creates and returns an XMLDocument from the inputSource.save
(DataObject dataObject, String rootElementURI, String rootElementName) Returns the DataObject saved as an XML document with the specified root element.void
save
(DataObject dataObject, String rootElementURI, String rootElementName, OutputStream outputStream) Saves the DataObject as an XML document with the specified root element.void
save
(XMLDocument xmlDocument, OutputStream outputStream, Object options) Serializes an XMLDocument as an XML document into the outputStream.void
save
(XMLDocument xmlDocument, Writer outputWriter, Object options) Serializes an XMLDocument as an XML document into the outputWriter.void
save
(XMLDocument xmlDocument, Result outputResult, Object options) Serializes an XMLDocument as an XML document into the outputResult in a serialization technology independent format (as specified in javax.xml.transform).
-
Field Details
-
INSTANCE
The default XMLHelper.
-
-
Method Details
-
load
Creates and returns an XMLDocument from the input String. By default does not perform XSD validation. Same as load(new StringReader(inputString), null, null);- Parameters:
inputString
- specifies the String to read from- Returns:
- the new XMLDocument loaded
- Throws:
RuntimeException
- for errors in XML parsing or implementation-specific validation.
-
load
Creates and returns an XMLDocument from the inputStream. The InputStream will be closed after reading. By default does not perform XSD validation. Same as load(inputStream, null, null);- Parameters:
inputStream
- specifies the InputStream to read from- Returns:
- the new XMLDocument loaded
- Throws:
IOException
- for stream exceptions.RuntimeException
- for errors in XML parsing or implementation-specific validation.
-
load
Creates and returns an XMLDocument from the inputStream. The InputStream will be closed after reading. By default does not perform XSD validation.- Parameters:
inputStream
- specifies the InputStream to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- implementation-specific options.- Returns:
- the new XMLDocument loaded
- Throws:
IOException
- for stream exceptions.RuntimeException
- for errors in XML parsing or implementation-specific validation.
-
load
Creates and returns an XMLDocument from the inputReader. The InputStream will be closed after reading. By default does not perform XSD validation.- Parameters:
inputReader
- specifies the Reader to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- implementation-specific options.- Returns:
- the new XMLDocument loaded
- Throws:
IOException
- for stream exceptions.RuntimeException
- for errors in XML parsing or implementation-specific validation.
-
load
Creates and returns an XMLDocument from the inputSource. The InputSource will be closed after reading. By default does not perform XSD validation.- Parameters:
inputSource
- specifies the Source to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- implementation-specific options.- Returns:
- the new XMLDocument loaded
- Throws:
IOException
- for stream exceptions.RuntimeException
- for errors in XML parsing or implementation-specific validation.
-
save
Returns the DataObject saved as an XML document with the specified root element. Same as StringWriter stringWriter = new StringWriter(); save(createDocument(dataObject, rootElementURI, rootElementName), stringWriter, null); stringWriter.toString();- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- the Name of the root XML element- Returns:
- the saved XML document as a string
- Throws:
IllegalArgumentException
- if the dataObject tree is not closed or has no container.
-
save
void save(DataObject dataObject, String rootElementURI, String rootElementName, OutputStream outputStream) throws IOException Saves the DataObject as an XML document with the specified root element. Same as save(createDocument(dataObject, rootElementURI, rootElementName), outputStream, null);- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- the Name of the root XML elementoutputStream
- specifies the OutputStream to write to.- Throws:
IOException
- for stream exceptions.IllegalArgumentException
- if the dataObject tree is not closed or has no container.
-
save
Serializes an XMLDocument as an XML document into the outputStream. If the DataObject's Type was defined by an XSD, the serialization will follow the XSD. Otherwise the serialization will follow the format as if an XSD were generated as defined by the SDO specification. The OutputStream will be flushed after writing. Does not perform validation to ensure compliance with an XSD.- Parameters:
xmlDocument
- specifies XMLDocument to be savedoutputStream
- specifies the OutputStream to write to.options
- implementation-specific options.- Throws:
IOException
- for stream exceptions.IllegalArgumentException
- if the dataObject tree is not closed or has no container.
-
save
Serializes an XMLDocument as an XML document into the outputWriter. If the DataObject's Type was defined by an XSD, the serialization will follow the XSD. Otherwise the serialization will follow the format as if an XSD were generated as defined by the SDO specification. The OutputStream will be flushed after writing. Does not perform validation to ensure compliance with an XSD.- Parameters:
xmlDocument
- specifies XMLDocument to be savedoutputWriter
- specifies the Writer to write to.options
- implementation-specific options.- Throws:
IOException
- for stream exceptions.IllegalArgumentException
- if the dataObject tree is not closed or has no container.
-
save
Serializes an XMLDocument as an XML document into the outputResult in a serialization technology independent format (as specified in javax.xml.transform). The OutputResult will be flushed after writing. Does not perform validation to ensure compliance with an XSD.- Parameters:
xmlDocument
- specifies XMLDocument to be savedoutputResult
- specifies Result to be savedoptions
- implementation-specific options.- Throws:
IOException
- for stream exceptions.IllegalArgumentException
- if the dataObject tree is not closed or has no container.
-
createDocument
Creates an XMLDocument with the specified XML rootElement for the DataObject.- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- the Name of the root XML element- Returns:
- XMLDocument a new XMLDocument set with the specified parameters.
-