{
InputSource source = new InputSource(schema);
XSParser xsParser = new XSParser();
xsParser.setValidating(false);
XSSchema xsSchema = xsParser.parse(source);
this.provider = provider instanceof GenericObjectModelProvider ?
(GenericObjectModelProvider)provider : new DelegatingObjectModelProvider(provider);
this.root = root;
//stack.push(document);
content.startDocument();
if(rootQNames.isEmpty())
{
XSElement[] elements = xsSchema.getElements();
for(int i = 0; i < elements.length; ++i)
{
log.info("marshalling " + elements[i].getName().getLocalName());
//processElement(elements[i], addedAttributes, 1);
processElement(elements[i], 1, true);
}
}
else
{
for(int i = 0; i < rootQNames.size(); ++i)
{
QName qName = (QName)rootQNames.get(i);
XsQName rootName = new XsQName(qName.getNamespaceURI(), qName.getLocalPart(), qName.getPrefix());
final XSElement xsRoot = xsSchema.getElement(rootName);
if(xsRoot == null)
{
throw new IllegalStateException("Root element not found: " + rootName);
}