logo       

Help with validating a new instance: msg#00044

text.xml.xmlbeans.user

Subject: Help with validating a new instance

I am having problems validating an new instance of a document. Has to be
something I am missing. Can anyone help?

// Set options for new instance
XmlOptions opts = new XmlOptions();
opts = opts.setDocumentType ( CustomerDocument.type );
opts = opts.setDocumentSourceName("customer");
ArrayList errorList = new ArrayList();
opts = opts.setErrorListener(errorList);

xmlRoot = XmlObject.Factory.newInstance( opts );

if (! xmlRoot.validate( opts )) {
...

The error I get from validation is
"Expected element customer at the end of the content"
location = "<xml-fragment/>

I have added the customer element before validating but then get errors that
sub-elements are missing. I put this code before validation

XmlCursor cursor = xmlRoot.newCursor();
cursor.toEndDoc();
QName q = new QName (null, "customer");
cursor.insertElement( q );

How far do I have to go before successful validation and how do I get rid of
<xml-fragment>? Must be missing something...


Thanks,
-- Brian


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise