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 Davanum Srinivas <da...@gmail.com> on 2006/01/14 06:06:20 UTC

JaxMeExtension

Jochen,

I was reviewing the code in JaxMe to see who easy it is to add a JaxMe
extension. After a bit of research this snippet seems to do what we
want (assuming we can fill in the xmlObjectsVector with InputSources
for all the xsd's)

            GeneratorImpl generator = new GeneratorImpl();
            JAXBSchemaReader reader = new JAXBSchemaReader();
            generator.setSchemaReader(reader);
            for (int i = 0; i < xmlObjectsVector.size(); i++) {
                SchemaSG sg = generator.generate((InputSource)
xmlObjectsVector.elementAt(i));
            }

But there are some things we need in addition to that.
#1: if there are some namespace/prefix combination is used inside an
embedded schema but defined in the top of the wsdl file, then there is
no way to pass it down to XSParser. (for example, XmlBeans has a
XmlOptions class takes with a setLoadAdditionalNamespaces method which
can be used to set such a map)
#2: I can't get a mapping of which schema type/element (QName) was
mapped to which java package/class. I need to to generate other code
like Stub/Receiver outside of JaxMe.

Could u please help?

thanks,
dims

--
Davanum Srinivas : http://wso2.com/blogs/

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


Re: JaxMeExtension

Posted by Davanum Srinivas <da...@gmail.com>.
i got #2 done. #1 seems like tall order for me :)

On 1/14/06, Jochen Wiedmann <jo...@gmail.com> wrote:
>
> Hi, Dims,
>
> Davanum Srinivas wrote:
>
> > #1: if there are some namespace/prefix combination is used inside an
> > embedded schema but defined in the top of the wsdl file, then there is
> > no way to pass it down to XSParser. (for example, XmlBeans has a
> > XmlOptions class takes with a setLoadAdditionalNamespaces method which
> > can be used to set such a map)
>
> how do you store the WSDL internally? As a DOM tree? In that case I do
> suggest the following:
>
> - Create an instance of XMLFilterImpl, which holds the schema element
>    and an empty InputSource() as internal fields. (Same InputSource,
>    which you'll pass to the generator later on.)
> - Overwrite the XMLFilter's method parse(InputSource) as follows:
>    Check, whether the InputSource is the same as the XMLFilter's internal
>    one. If not, throw an IllegalStateException. Otherwise, create an
>    instance of DOMSerializer. Note the DOMSerializer's property
>      parentsNamespaceDeclarationDisabled
>    Invoke the DOMSerializer's method serialize with the schema element.
>
> In other words, invoking the XMLFilter is equivalent to parsing the
> WSDL's schema with the additional namespace declarations from above. (It
> may be required to add the startDocument() and endDocument() events.)
> What's left is to make sure, that the XMLFilterImpl is used and not a
> standard XMLReader.
>
> - Do not use the SchemaReader's parse(InputSource) method, but copy it.
>    (Obviously, you can omit the DTD part.) That gives you access to two
>    objects: The XSParser, and the SchemaSG.
> - Create an instance of JAXBXsObjectFactoryImpl and overwrite the method
>    newXMLReader(). When invoked for the first time, return the XMLFilter
>    from above. Otherwise, return super.newXMLReader().
> - Make sure, that your object factory is used by invoking
>    XSParser.getData().setXsObjectFactory().
>
>
>
> > #2: I can't get a mapping of which schema type/element (QName) was
> > mapped to which java package/class. I need to to generate other code
> > like Stub/Receiver outside of JaxMe.
>
> That should be easy by using the above instance of SchemaSG.
>
>
> Jochen
>


--
Davanum Srinivas : http://wso2.com/blogs/

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


Re: JaxMeExtension

Posted by Jochen Wiedmann <jo...@gmail.com>.
Hi, Dims,

Davanum Srinivas wrote:

> #1: if there are some namespace/prefix combination is used inside an
> embedded schema but defined in the top of the wsdl file, then there is
> no way to pass it down to XSParser. (for example, XmlBeans has a
> XmlOptions class takes with a setLoadAdditionalNamespaces method which
> can be used to set such a map)

how do you store the WSDL internally? As a DOM tree? In that case I do 
suggest the following:

- Create an instance of XMLFilterImpl, which holds the schema element
   and an empty InputSource() as internal fields. (Same InputSource,
   which you'll pass to the generator later on.)
- Overwrite the XMLFilter's method parse(InputSource) as follows:
   Check, whether the InputSource is the same as the XMLFilter's internal
   one. If not, throw an IllegalStateException. Otherwise, create an
   instance of DOMSerializer. Note the DOMSerializer's property
     parentsNamespaceDeclarationDisabled
   Invoke the DOMSerializer's method serialize with the schema element.

In other words, invoking the XMLFilter is equivalent to parsing the 
WSDL's schema with the additional namespace declarations from above. (It 
may be required to add the startDocument() and endDocument() events.) 
What's left is to make sure, that the XMLFilterImpl is used and not a 
standard XMLReader.

- Do not use the SchemaReader's parse(InputSource) method, but copy it.
   (Obviously, you can omit the DTD part.) That gives you access to two
   objects: The XSParser, and the SchemaSG.
- Create an instance of JAXBXsObjectFactoryImpl and overwrite the method
   newXMLReader(). When invoked for the first time, return the XMLFilter
   from above. Otherwise, return super.newXMLReader().
- Make sure, that your object factory is used by invoking
   XSParser.getData().setXsObjectFactory().



> #2: I can't get a mapping of which schema type/element (QName) was
> mapped to which java package/class. I need to to generate other code
> like Stub/Receiver outside of JaxMe.

That should be easy by using the above instance of SchemaSG.


Jochen

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