You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Nina Juliadotter <nv...@it.uts.edu.au> on 2004/03/29 04:37:58 UTC

javax.xml.bind.UnmarshalException @ JMUnmarshallerImpl.java:133

Hello everyone,

I'm getting the follwing error:

javax.xml.bind.UnmarshalException
at org.apache.ws.jaxme.impl.JMUnmarshallerImpl.unmarshal   
JMUnmarshallerImpl.java:133)
at src.org.parser.myLogicParser.marshal(myLogicParser.java:135)
at src.org.parser.myLogicParser.parse(myLogicParser.java:78)
at src.org.parser.myLogicParser.<init>(myLogicParser.java:54)
at src.org.parser.myLogicParser.main(myLogicParser.java:47)

when I do this:

File f = new File("X:/W2SProject/Schema/RestaurantSchema.xsd);
org.xml.sax.InputSource isource = null;
isource = new InputSource(new FileInputStream(f));
isource.setSystemId(f.toURL().toString());

JAXBContext context =
(org.apache.ws.jaxme.impl.JAXBContextImpl)JAXBContext.newInstance("src.org.generated");
Unmarshaller um = context.createUnmarshaller();
Object object = um.unmarshal(isource);                            <-- this line is 135
Marshaller m = context.createMarshaller();
m.marshal(object, new PrintWriter(System.out));

Basically what I am doing is reading in an XML schema as an InputSource, and then I
try to unmarshal and marshal that (I have no use of unmarchalling it, but I need the
'object' to be able to marshal it). But obviously it's not happy unmarshalling it.
The JMUnmarshallerImpl source code is:

public Object unmarshal(InputSource pSource) throws JAXBException {
    UnmarshallerHandler uh = getUnmarshallerHandler();
    try {
      SAXParser sp = spf.newSAXParser();
      XMLReader xr = sp.getXMLReader();
      xr.setContentHandler(uh);
      xr.parse(pSource);
    } catch (SAXException e) {
      if (e.getException() != null) {
        throw new UnmarshalException(e.getException());           <-- this line is 133
      } else {
        throw new UnmarshalException(e);
      }
    } catch (IOException e) {
      throw new UnmarshalException(e);
    } catch (ParserConfigurationException e) {
      throw new UnmarshalException(e);
    }
    return uh.getResult();
  }

Could it be that it's unhappy to do xr.parse(pSource) on my InputSource that's
created from an XML schema rather than an XML instance? I'm not sure at all how
these things work. Or could it be a bug in JaxMe?


Cheers,
Nina



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: javax.xml.bind.UnmarshalException @ JMUnmarshallerImpl.java:133

Posted by Nina Juliadotter <nv...@it.uts.edu.au>.
Hi Jochen,

Thanks for your reply. Yes, I realise that I'm on the wrong track somehow.

What I am trying to do, is to generate HTML based on an XML schema. I was thinking
that one way to do this might be to use the xjc to generate classes based on my
schema. It's the next step that's causing my headache: how to get HMTL based on
this. I was thinking that if I can get my schema in a xml instance representation,
than I can use that together with an XSLT file to get the HTML. Which explains why I
was looking at marshalling the xml schema.
I have already looked into parsing the schema, but what can I really do with this
parsed schema, to reach my goal?

But anyway, I'm not expecting the list to solve my problems, it's just a bit of a
jungle out there with these relatively new technologies, and to do something that's
any different from the standard can cause quite a headache and confusion. I'll try
and be quiet now unless I have something really JaxMe-related to say :)

Nina


>
> Hi, Nina,
>
> I suppose, this is a followup to your post from last week?
>
> You are trying things the wrong way. An XML Schema is itself
> subject to a specific XML Schema. See examples/xs/structures.xsd.
>
> So you could, in theory, do the following:
>
> - Run the JaxMe generator on the file structures.xsd.
> - Use the generated sources to unmarshal or marshal the
>   schema file.
>
> Unfortunately I doubt this will work with the current version
> of JaxMe, as XML Schema almost definitely uses features that
> are still unsupported.
>
> However, in the case of XML Schema, there is possibly an
> excellent alternative: Use the XML Schema Parser JaxMeXS,
> which is used by JaxMe itself. See
>
>     http://ws.apache.org/jaxme/xs
>
> for details.
>
>
> Jochen
>
> Zitat von Nina Juliadotter <nv...@it.uts.edu.au>:
>
>> Hello everyone,
>>
>> I'm getting the follwing error:
>>
>> javax.xml.bind.UnmarshalException
>> at org.apache.ws.jaxme.impl.JMUnmarshallerImpl.unmarshal
>> JMUnmarshallerImpl.java:133)
>> at src.org.parser.myLogicParser.marshal(myLogicParser.java:135)
>> at src.org.parser.myLogicParser.parse(myLogicParser.java:78)
>> at src.org.parser.myLogicParser.<init>(myLogicParser.java:54)
>> at src.org.parser.myLogicParser.main(myLogicParser.java:47)
>>
>> when I do this:
>>
>> File f = new File("X:/W2SProject/Schema/RestaurantSchema.xsd);
>> org.xml.sax.InputSource isource = null;
>> isource = new InputSource(new FileInputStream(f));
>> isource.setSystemId(f.toURL().toString());
>>
>> JAXBContext context =
>>
> (org.apache.ws.jaxme.impl.JAXBContextImpl)JAXBContext.newInstance("src.org.generated");
>> Unmarshaller um = context.createUnmarshaller();
>> Object object = um.unmarshal(isource);                            <-- this
>> line is 135
>> Marshaller m = context.createMarshaller();
>> m.marshal(object, new PrintWriter(System.out));
>>
>> Basically what I am doing is reading in an XML schema as an InputSource, and
>> then I
>> try to unmarshal and marshal that (I have no use of unmarchalling it, but I
>> need the
>> 'object' to be able to marshal it). But obviously it's not happy
>> unmarshalling it.
>> The JMUnmarshallerImpl source code is:
>>
>> public Object unmarshal(InputSource pSource) throws JAXBException {
>>     UnmarshallerHandler uh = getUnmarshallerHandler();
>>     try {
>>       SAXParser sp = spf.newSAXParser();
>>       XMLReader xr = sp.getXMLReader();
>>       xr.setContentHandler(uh);
>>       xr.parse(pSource);
>>     } catch (SAXException e) {
>>       if (e.getException() != null) {
>>         throw new UnmarshalException(e.getException());           <-- this
>> line is 133
>>       } else {
>>         throw new UnmarshalException(e);
>>       }
>>     } catch (IOException e) {
>>       throw new UnmarshalException(e);
>>     } catch (ParserConfigurationException e) {
>>       throw new UnmarshalException(e);
>>     }
>>     return uh.getResult();
>>   }
>>
>> Could it be that it's unhappy to do xr.parse(pSource) on my InputSource
>> that's
>> created from an XML schema rather than an XML instance? I'm not sure at all
>> how
>> these things work. Or could it be a bug in JaxMe?
>>
>>
>> Cheers,
>> Nina
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: jaxme-dev-help@ws.apache.org
>>
>>
>>
>
>
>


Cheers,
Nina



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org