users@jaxb.java.net

Re: ID's supported properly? MVS vs. JAXB

From: David Halonen <david.halonen_at_compuware.com>
Date: Tue, 25 Mar 2003 06:32:43 -0700

>This behavior is expected if you are turning off the
>validation explicitly. Are you?

I *assumed* validation was on by default. Not so. Once validation is turned on, the problem is immediately signaled.

>But otherwise JAXB RI should detect the error when you unmarshal
>a document. Let me know if you think this is a bug of RI.

There is another issue, where RI is signaling an "unexpected attribute", which just happens to be a OID. The mvs stuff doesn't have any problems, but RI does.

Here is the code, for what its worth:

 //Validate the xml vs the schema first.
VerifierFactory factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
Schema schema = factory.compileSchema( "c:\\developmentSandbox\\StepThroughTest\\project.xsd" );
Verifier verifier = schema.newVerifier();
if( verifier.verify( "c:\\developmentSandbox\\StepThroughTest\\project.xml") ){
    System.out.println("All is well.");
} else {
    System.out.println("Verification failed.");
    return;
}
// create a JAXBContext capable of handling classes generated into
// the com.compuware.converterpro.jaxbdatamodel package
JAXBContext jc = JAXBContext.newInstance( "jaxbdatamodel" );
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
if( !u.isValidating() ) u.setValidating(true);
myValidationEventHandler eventHandler = new myValidationEventHandler();
u.setEventHandler( eventHandler );
project = (JaxbProject) u.unmarshal(
        (InputStream) (new FileInputStream(
            "c:\\developmentSandbox\\StepThroughTest\\project.xml" ) ));

Its during this unmarshal() call that RI gags on the following XML:

<WHILE OID="_96" Name="While_ORDER_LINE_TABLE2" Expression="Untitled2.DefaultTaskSet.GenTask.While_ORDER_TABLE1.While_ORDER_TABLE1_VS1.$GetResult_ORDER_LINE_TABLEInstance == true">

In particular, the position of the problem is between the letters n & c, near the end of the Expression string.

Would it be possible for to send you the schema & XML for review? This is kind of an odd problem.