| Developing with the SDK > Using and Writing Data Models > Handling XML Data Files in Java |
Handling XML Data Files in Java |
INDEX
PREVIOUS
NEXT
|
If you have existing data in an XML format, there is support in the class ilog.views.sdm.IlvSDMEngine for reading, writing and transforming it.
There are several ways available to read an XML file:
setXMLFile.
readXML(InputStream) to read XML data from an input stream.
readDOM. to read data directly from a DOM tree.
There are several ways available to write the contents of the data model to an XML file:
writeXML, specifying the filename:myEngine.writeXML( |
writeXML(OutputStream) to write XML data to an output stream.
writeDOM to write data directly to a DOM tree.
It is possible to read and write data in any XML format. To do this, you have two solutions:
IlvXMLConnector
XSLT is the simplest solution for reading and writing custom XML formats, because it requires no Java coding. This solution is easier to apply when the structure of the custom XML format is relatively close to the required structure.
For documentation and resources on XSLT, see the W3C web site (http://www.w3c.org). Proceed as follows:
IlvXSLConnector (a subclass of IlvXMLConnector), specifying the two XSLT files. To do this through the style sheet add a rule with the following structure:
Note that the two XSLT files must be written so that no information is lost, that is, the two transformations should be the exact inverse of one another. If the custom XML format contains information that is not useful for ILOG JViews Diagrammer purposes or that cannot be translated easily, this information can be stored as metadata (see Metadata in the XML Data File in Using the Designer).
It is possible to specify only one transformation. For example, you may specify only the input templates file if you read only custom XML files, but never modify and write them back.
There may be cases when you will not be able to write XSL transformations between the custom XML format and the SDM format, usually because the structures are too different and the XSLT language does not allow you to implement the transformation.
In such cases, proceed as follows:
ilog.views.sdm.util.IlvXMLConnector.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |