public void validate(String filename)
throws org.apache.xmlbeans.XmlException, java.io.IOException
{
System.out.println("parsing document: " + filename);
HelloDocument doc = HelloDocument.Factory.parse(new File(filename));
ArrayList errors = new ArrayList();
XmlOptions opts = new XmlOptions();
opts.setErrorListener(errors);
if (doc.validate(opts))
{
System.out.println("document is valid.");
String[] names = doc.getHello().getNameArray();
for (int i = 0; i < names.length; i++)
{
System.out.println(" hi there, " + names[i] + "!");
}
}