XmlStructFactory sf = new XmlStructFactoryComposite(new XmlStructFactory[]{
new org.xooof.xmlstruct.test.nons.PackageXmlStructFactory(),
new org.xooof.xmlstruct.test.ns1.PackageXmlStructFactory(),
new org.xooof.xmlstruct.test.ns2.PackageXmlStructFactory(),
});
XmlStruct xs = null;
ErrorBag eb = new ErrorBag();
FileWriter rw = new FileWriter(result);
SAXTransformerFactory tf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
TransformerHandler handler = tf.newTransformerHandler();
handler.setResult(new StreamResult(rw));
try
{
handler.startDocument();
startElement(handler,"result");
// xsFromXML
try
{
FileInputStream fis = new FileInputStream(source);
xs = XmlStructUtils.xsFromXML(sf,fis,eb,"");
if (eb.size() > 0)
{
writeElementString(handler,"fromXmlErr",eb.toString());
return;
}
else
{
writeElementString(handler,"fromXmlOk","");
}
}
catch(XmlStructException e)
{
writeElementString(handler,"fromXmlErr",e.getMessage());
return;
}
catch(Exception e)
{
writeElementString(handler,"fromXmlErr","Fatal: "+e.toString());
return;
}
// xsValidate
{
xs.xsValidate(eb,"");
if (eb.size() > 0)
{
writeElementString(handler,"validateErr",eb.toString());
}
else