After the document specification is loaded, you can iterate
the templates and the data sources for each template. The data sources
for a template are available in the RPETemplate.getDataSources() collection.
After you have identified the data source, you can modify the data
source properties as needed.
The example shows modifying the URI of the data source named
“DS1”. The data source is searched in all templates from the document
specification. If you want to restrict the search you need to verify
the path property of the template.
for (RPETemplate template : docspec.getRuntime().getTemplates())
{
String templatePath = PropertyUtils.getPropertyRawValue( template.getProperty(RPEConfigConstants.PROPERTY_PATH), "");
for ( RPEDataSource ds : template.getDataSources())
{
String dsName = PropertyUtils.getPropertyRawValue( ds.getProperty(RPEConfigConstants.PROPERTY_NAME), "");
if ( dsName.equals("DS1"))
{
Property dsURI = ds.getProperty(RPEConfigConstants.PROPERTY_URI);
assert( dsURI != null);
dsURI.setValue( new Value( null, "c:\\test\\sample.xml"));
}
}
Note: You can also configure the data sources from a
template as you add the template to the document specification.