users@jaxb.java.net

Re: Problems with JAXB 1.0 -- Please help

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 13 Sep 2006 15:57:55 -0700

I appreciate you giving us all the details to reproduce the problem, I
think for this kind of things would be better posted as a zip file to
the issue tracker, where large files are not a problem.

As for your particular problem, I first suggest you to validate your
input document with the schema, just to make sure that it is indeed
valid. After all, that's what the RI is complaining --- it sees a header
  element where it's not expecting it.

So check with other tools to see if the document is really valid.


Patel, Ritesh (GMI - Debt Markets Technology) wrote:
> I'm having some problems using JAXB 1.0. This is my first attempt to
> use it, and I may be doing something VERY wrong.
>
> This is a complete scenario, so if I can simplify it, please let me
> know.
>
> Lets start with my code:
> JAXBContext
> jContext=JAXBContext.newInstance("ml:fpml:org.w3._2000._09.xmldsig_");
> Unmarshaller unmarshaller = jContext.createUnmarshaller() ;
> unmarshaller.setValidating(false);
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
>
> DocumentBuilder db = dbf.newDocumentBuilder();
> Document doc = db.parse(new FileInputStream( xmls[i]));
>
> System.out.println(unmarshaller.unmarshal(doc));
>
>
> My unmarshalling has a problem. I get the following expection:
> DefaultValidationEventHandler: [ERROR]: Unexpected element
> {http://www.fpml.org/2005/FpML-4-2}:header
> Location:
> javax.xml.bind.UnmarshalException: Unexpected element
> {http://www.fpml.org/2005/FpML-4-2}:header
> at
> fpml.impl.runtime.SAXUnmarshallerHandlerImpl.handleEvent(SAXUnmarshaller
> HandlerImpl.java:551)
> at
> fpml.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(Abst
> ractUnmarshallingEventHandlerImpl.java:148)
> at
> fpml.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(Abst
> ractUnmarshallingEventHandlerImpl.java:145)
> at
> fpml.impl.runtime.AbstractUnmarshallingEventHandlerImpl.unexpectedEnterE
> lement(AbstractUnmarshallingEventHandlerImpl.java:156)
> at
> fpml.impl.runtime.AbstractUnmarshallingEventHandlerImpl.enterElement(Abs
> tractUnmarshallingEventHandlerImpl.java:69)
> at
> fpml.impl.FpMLElementImpl$Unmarshaller.enterElement(FpMLElementImpl.java
> :163)
> at
> fpml.impl.runtime.AbstractUnmarshallingEventHandlerImpl.revertToParentFr
> omEnterElement(AbstractUnmarshallingEventHandlerImpl.java:338)
> at
> fpml.impl.DocumentImpl$Unmarshaller.enterElement(DocumentImpl.java:133)
> at
> fpml.impl.FpMLElementImpl$Unmarshaller.enterElement(FpMLElementImpl.java
> :158)
> at
> fpml.impl.runtime.SAXUnmarshallerHandlerImpl.startElement(SAXUnmarshalle
> rHandlerImpl.java:134)
> at
> com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:177)
> at
> com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:210)
> at
> com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:183)
> at
> com.sun.xml.bind.unmarshaller.DOMScanner.parse(DOMScanner.java:72)
> at
> fpml.impl.runtime.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:169)
> at MarchalExample.main(MarchalExample.java:54)
>
> I have a TON of xsd that are all linked together via ml-main-1-0.xsd. I
> have attached all the xsds to this email.
>
> When generating the classes, I did:
> java -Xmx800m -jar %JAXB_HOME%\lib\jaxb-xjc.jar ml-main-1-0.xsd
> -extension -d jschema -b binding.xjb
>
> Here in the content of my binding.xjb
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <jxb:bindings schemaLocation="fpml-main-4-2.xsd" node="/xs:schema">
> <jxb:schemaBindings>
> <jxb:package name="fpml"/>
> <jxb:nameXmlTransform>
> <jxb:elementName suffix="Element"/>
> </jxb:nameXmlTransform>
> </jxb:schemaBindings>
> </jxb:bindings>
> <jxb:bindings schemaLocation="ml-main-1-0.xsd" node="/xs:schema">
> <jxb:schemaBindings>
> <jxb:package name="ml"/>
> <jxb:nameXmlTransform>
> <jxb:elementName suffix="Element"/>
> </jxb:nameXmlTransform>
> </jxb:schemaBindings>
> </jxb:bindings>
> </jxb:bindings>
>
> I have also attached the xml file I'm trying to unmarchal.
>
> ANY HELP WOULD be appreciated.
>
> Thanks in advance,
>
>
> Ritesh Patel
> --------------------------------------------------------
>
> If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/
> --------------------------------------------------------
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com