[
http://jira.jboss.com/jira/browse/JBXB-101?page=all ]
Scott M Stark resolved JBXB-101.
--------------------------------
Resolution: Done
After digging into the xerces code, both the VALIDATION and DYNAMIC_VALIDATION features
need to be false to avoid validation of docs with DOCTYPEs. The
UnmarshallerImpl.setValidation(boolean) was therefore updated to:
public void setValidation(boolean validation) throws JBossXBException
{
parser.setFeature(VALIDATION, validation);
parser.setFeature(DYNAMIC_VALIDATION, false);
}
Cannot disable validation
-------------------------
Key: JBXB-101
URL:
http://jira.jboss.com/jira/browse/JBXB-101
Project: JBoss XML Binding (JBossXB)
Issue Type: Bug
Affects Versions: JBossXB-2.0.0.CR2
Reporter: Scott M Stark
Assigned To: Scott M Stark
Fix For: JBossXB-2.0.0.CR3
Calling Unmarshaller.setValidation(false) has no affect on the parser validation. The
following org.jboss.test.xml.SimpleTestCase test fails:
public void testUnmarshalBooks2Dtd() throws Exception
{
// create an object model factory
String xmlSource = "books2-dtd.xml";
ObjectModelFactory factory = new BookObjectFactory();
log.debug("<test-unmarshal-" + xmlSource + '>');
// get the XML stream
URL xmlUrl = getResourceUrl("xml/book/" + xmlSource);
// create unmarshaller
Unmarshaller unmarshaller = getBookUnmarshaller();
unmarshaller.setValidation(false);
// let the object model factory to create an instance of Book and populate it with
data from XML
Book book = (Book)unmarshaller.unmarshal(xmlUrl.openStream(), factory, null);
checkUnmarshalledBook(book);
log.debug("</test-unmarshal-" + xmlSource + '>');
}
wth:
org.jboss.xb.binding.JBossXBException: Failed to parse source: The content of element
type "book" is incomplete, it must match
"(title,author,character+,misc+)". @ *unknown*[18,8]
at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:187)
at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:169)
at org.jboss.test.xml.SimpleTestCase.testUnmarshalBooks2Dtd(SimpleTestCase.java:94)
at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source)
at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;J)Ljava.lang.Object;(Unknown
Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.xml.sax.SAXException: The content of element type "book" is
incomplete, it must match "(title,author,character+,misc+)". @ *unknown*[18,8]
at
org.jboss.xb.binding.parser.sax.SaxJBossXBParser$MetaDataErrorHandler.error(SaxJBossXBParser.java:406)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(Ljava.lang.String;Ljava.lang.String;Lorg.apache.xerces.xni.parser.XMLParseException;)V(Unknown
Source)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(Lorg.apache.xerces.xni.XMLLocator;Ljava.lang.String;Ljava.lang.String;[Ljava.lang.Object;S)V(Unknown
Source)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(Ljava.lang.String;Ljava.lang.String;[Ljava.lang.Object;S)V(Unknown
Source)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Lorg.apache.xerces.xni.QName;Lorg.apache.xerces.xni.Augmentations;Z)V(Unknown
Source)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Lorg.apache.xerces.xni.QName;Lorg.apache.xerces.xni.Augmentations;)V(Unknown
Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement()I(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Z)Z(Unknown
Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Z)Z(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Z)Z(Unknown Source)
at
org.apache.xerces.parsers.XML11Configuration.parse(Lorg.apache.xerces.xni.parser.XMLInputSource;)V(Unknown
Source)
at
org.apache.xerces.parsers.XMLParser.parse(Lorg.apache.xerces.xni.parser.XMLInputSource;)V(Unknown
Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Lorg.xml.sax.InputSource;)V(Unknown
Source)
at
org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Lorg.xml.sax.InputSource;)V(Unknown
Source)
at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:183)
at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:169)
at org.jboss.test.xml.SimpleTestCase.testUnmarshalBooks2Dtd(SimpleTestCase.java:94)
because there are no misc elements in the document. The point of the test is to be able
to relax validation against the dtd as is required for application.xml deployments that
only include sars. This is separate from the schema validation of JBMICROCONT-169 but
related.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira