users@jaxb.java.net

Re: Marshalling and unmarshalling to several root elements

From: Han Ming Ong <hanming_at_mac.com>
Date: Wed, 07 May 2003 15:54:53 -0700

On Wednesday, May 7, 2003, at 03:34 PM, Kohsuke Kawaguchi wrote:

> I was looking at your bug report regarding XSLT transformation. It
> seems
> like you are using JAXBSource in a wrong way:
>
> See the javadoc of JAXBSource at:
>
> http://java.sun.com/webservices/docs/1.1/api/javax/xml/bind/util/
> JAXBSource.html
>
> You are supposed to pass in a JAXBSource object as a parameter to the
> Transformer.transform().

Yes, that's the normal way it should be used.

But the bug I'm referring to is for chained transformation (quite a
normal use case apparently or Xalan wouldn't have 2 ways to do it :-).

I hope that you have tried the steps and saw the error?

==========================

I try to combine it with the chain transformation example from Xalan's
website ( http://xml.apache.org/xalan-j/samples.html#pipe ).

The pipe example requires an InputSource.

Since JAXBSource is a SAXSource (according to the Javadoc), it should
be able to return an InputSource when I use getInputSource().

Theoretically, it should work but I see an exception instead.

I'm using Xalan 2.5.0 and Xerces 2.4.0.

If I break up the chained transformations and save into temporary
files, then it would work, showing that nothing is wrong with my XSLT
files.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Download Xalan 2.5.0
2. Follow the example in http://xml.apache.org/xalan-j/samples.html#pipe
3. Create a very simple schema and use xjc.sh to generate the classes.
4. create a simple XML file and use JAXB to unmarshal it in
5. Instead of marshalling it out, use JAXBSource in combination with
the Pipe example to write it out.


EXPECTED VERSUS ACTUAL BEHAVIOR :
Should not see Exception.
here's part of the stack trace:

java.net.MalformedURLException
    at java.net.URL.<init>(URL.java:613)
    at java.net.URL.<init>(URL.java:476)
    at java.net.URL.<init>(URL.java:425)
    at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source)
    at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
... the rest are my program stack.