The IXMLStruct Java interface
This section describes the XmlStruct interface that is implemented by java classes generated from struct specifications. This interface has method for conversion from and to XML, and functions to manipulate the struct itself, such as validation, initialization, cloning and copying.
This interface is defined in the org.xooof.xmlstruct package.
xsToXML
Convert the data structure to its XML representation as a string.
public xsToXML()
java.lang.String
Return values
The XML string representing the data structure. The XML declaration processing instruction is not generated, because it contains encoding information and the string could be later converted to a specific encoding. The XML declaration with the proper encoding should be added manually when the string is written to a medium with a specific encoding.
xsToDOM
Convert the data structure to its XML representation as a DOM tree.
public xsToDOM(
org.w3c.dom.Document doc,,
String wrapperName,
String wrapperNsURI)
org.w3c.dom.Element
Parameters
org.w3c.dom.Document doc,
The DOM document to use to create the nodes.
String wrapperName
For struct, this is the name of the element that must wrap all the field elements.
For a struct collection, this is the name of the element that must wrap each item in the list. The list itself is wrapped with an element that is the wrapper name suffixed with "-list".
If the wrapper name is not provided, the struct class name is used.
String wrapperNsURI
The namespace URI of the wrapper element(s).
Return values
The newly created root DOM element node
xsToSAX
Convert the data structure to its XML representation by emitting SAX events.
public xsToSAX(
org.xml.sax.ContentHandler contentHandler,
String wrapperName,
String wrapperNsURI,
java.lang.String parentDefaultNsURI)
Parameters
org.xml.sax.ContentHandler contentHandler
The SAX content handler that will receive the events.
The following SAX events are emitted: startElement, characters, endElement.
String wrapperName
For struct, this is the name of the element that must wrap all the field elements.
For a struct collection, this is the name of the element that must wrap each item in the list. The list itself is wrapped with an element that is the wrapper name suffixed with "-list".
If the wrapper name is not provided, the struct class name is used.
String wrapperNsURI
The namespace URI of the wrapper element(s).
java.lang.String parentDefaultNsURI
The current default namespace URI. This is used by the event generator to decide if it must generate xmlns attributes, to avoid putting them on all elements if they are not necessary.
xsFromXML
Populate the fields from an XML string.
Unknown XML elements are simply ignored.
public xsFromXML(
String xml,
org.xooof.xmlstruct.ErrorBag,
String ctx)
boolean
Parameters
String xml
The XML source string.
org.xooof.xmlstruct.ErrorBag
The error bag object where the errors must be stored.
String ctx
The context to use to prefix the error messages. This is normally the name of the object. If it is left blank, the field names causing errors are reported without any prefix.
Return values
False if errors where detected and added to the error bag; true otherwise.
Note Only the "syntax" errors are reported in this step: this generally means that only the value strings in the XML source that cannot be converted to the proper data type cause errors and leave the corresponding field empty (null). To perform full validation according to the struct specification, the xsValidate method must be used. |
xsFromDOM
Populate the fields from an XML string.
Unknown XML elements are simply ignored.
public xsFromDOM(
org.w3c.dom.Element root,
org.xooof.xmlstruct.ErrorBag,
String ctx)
boolean
Parameters
org.w3c.dom.Element root
The root element (wrapper), corresponding to the node returned by xsToDOM.
org.xooof.xmlstruct.ErrorBag
The error bag object where the errors must be stored.
String ctx
The context to use to prefix the error messages. This is normally the name of the object. If it is left blank, the field names causing errors are reported without any prefix.
Return values
False if errors where detected and added to the error bag; true otherwise.
Note Only the "syntax" errors are reported in this step: this generally means that only the value strings in the XML source that cannot be converted to the proper data type cause errors and leave the corresponding field empty (null). To perform full validation according to the struct specification, the xsValidate method must be used. |
xsValidate
Validate the struct against the specification.
public xsValidate(
org.xooof.xmlstruct.ErrorBag,
String ctx)
bool
Parameters
org.xooof.xmlstruct.ErrorBag
The error bag object where the errors must be stored.
String ctx
The context to use to prefix the error messages. This is normally the name of the object. If it is left blank, the field names causing errors are reported without any prefix.
Return values
False if errors where detected and added to the error bag; true otherwise.
xsReset
Set the struct into its initial state: vfields and gfields are reset to null, vlfield and glfields are reset to empty collections.
public xsReset()
xsClone
Create a new struct that is an exact (deep) copy.
public xsClone()
java.lang.Object
xsInitFrom
Initialize the struct so it becomes an exact copy of another one of the same type.
public xsInitFrom(
org.xooof.xmlstruct.XmlStruct source)
Parameters
org.xooof.xmlstruct.XmlStruct source
xsCreate
Create a new empty struct of the same type.
public xsCreate()
java.lang.Object