| Business Objects and Data Sources > Data Sources > Advanced Parsing and Writing of a Data Source |
Advanced Parsing and Writing of a Data Source |
INDEX
PREVIOUS
NEXT
|
In addition to the basic IlpDefaultDataSource API for parsing an XML file a data source and writing the data source content to an XML file, JViews TGO provides the classes IlpDataSourceLoader and IlpDataSourceOutput for a more advanced use. Both these classes are located in the package ilog.cpl.storage.
The class IlpDataSourceLoader has the following functionality:
InputSource.
XMLReader. You can modify the behavior of the XML reader before the parsing takes place (for example, to disable the validation of the XML schema).
IlpDataSourceLoader loader = new IlpDataSourceLoader(inputSource,
dataSource);
XMLReader reader = loader.getXMLReader();
reader.setFeature("http://xml.org/sax/features/validation",false);
loader.parse();
The example below loads a template file into the data source. It shows how to create an identifier factory to modify parent identifiers of root objects. The complete sample code is located in the following directory:
<installdir>/tutorials/browser
final Object parentID = expandedObject.getIdentifier();
// Create an identifier factory that prepends the parent ID to
// all identifiers read from the template.
IlpIdentifierFactory idFactory = new IlpIdentifierFactory(){
public Object getIdentifier (Object previousIdentifier){
return parentID.toString() + "/" + previousIdentifier.toString();
}
};
// Load the template into the datasource
// Load the template objects under the parent node, and transform
// their IDs so they are unique
IlpDataSourceLoader loader = new IlpDataSourceLoader(templateFileName,
mainDataSource);
loader.setIdentifierFactory(idFactory);
loader.setParentIdOfRootObjects(parentID);
loader.parse();
The class IlpDataSourceOutput has the following functionality:
ContentHandler. This content handler can be used to feed a DOM tree for example.
outputHierarchy(IlpObject). The IlpObject parameter and all its children (which are defined by the container interface) are written to the file.
outputObject(IlpObject).
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |