Here's a use case. Consider an 'anyNode', especially like the one in the
<Body> element of the SOAP schema.
<Envelope>
</Header>
<Body>
<MyRequest xmlns="foo">
<!-- ...stuff -->
</MyRequest>
</Body>
</Envelope>
We don't have enough info to unmarshal <MyRequest>:
-<MyRequest>'s parent (<Body>) doesn't store the package name of <MyRequest> because
it is an anyNode.
-Using Unmarshaller(???.class) won't work because we don't have the class or package
name of <MyRequest>
-Can't get to the <MyRequest> Descriptor either, without the package name.
If the Unmarshaller has the following bindingfile info at runtime, you could
tie all the pieces together.
<cbf:package>
<cbf:name>mypackage.vo</cbf:name>
<cbf:namespace>foo</cbf:namespace>
</cbf:package>
A class smthg. like this would access the bindingfile info:
class BindingFileClassDescriptorResolverImpl extends ClassDescriptorResolverImpl {
public XMLClassDescriptor resolveByXMLName
(String xmlName, String namespaceURI, ClassLoader loader)
{
XMLClassDescriptor classDesc = super.resolveByXMLName(xmlName, namespaceURI,
loader);
String strClass = null;
try {
if (classDesc == null) {
//###############################################################
//Proposed API signature on the binding file <package> data.
//###############################################################
strClass = _bindingfile.getJavaPackageName(namespaceURI).trim() + "." +
xmlName;
Class classForXmlData = null;
try {
classForXmlData = Class.forName(strClass);
} catch (java.lang.ClassNotFoundException cnfe) {
return null;
}
resolve(classForXmlData);
classDesc = super.resolveByXMLName(xmlName, namespaceURI, loader);
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
} //end of catch
return classDesc;
} //end of method
} //end of class
> -----Original Message-----
> From: Arnaud Blandin [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 02, 2003 8:32 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] binding file -- <package> element
>
>
> Hi Erik,
>
> There is currently no code to inspect the code located
> in the binding
> file while unmarshalling.
> The binding file is meant to be used only to provide the Source
> Generator with necessary information to create the
> classes and the
> descriptors. I guess the information you are looking
> for should be
> stored somewhere in a descriptor. Do you have a use case?
>
> Thanks,
> Arnaud
> > -----Original Message-----
> > From: Ostermueller, Erik [mailto:[EMAIL PROTECTED]
> > Sent: Monday, June 02, 2003 3:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] binding file -- <package> element
> >
> > Yes, Arnaud, that will be great.
> >
> > > I have another question, though. This ns-package
> mapping would
> > > be very helpful when unmarshalling. Is there any
> code that inspects
> > > the bindingfile during unmarshalling?
> > >
> > > I want it to detect a ns in an instance doc, locate the
> corresponding
> > > java package in the binding file and then
> unmarshall the data.
> >
> > Thanks,
> >
> > Erik
> > > -----Original Message-----
> > > From: Arnaud Blandin [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, June 02, 2003 6:58 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [castor-dev] binding file --
> <package> element
> > >
> > >
> > > Hi Erik and Lisa,
> > >
> > > I've slightly modified the behavior of the <package>
> > > element and I hope
> > > it will fit your needs.
> > > The <package> element allows you to define a mapping
> > > between a package
> > > name and a schemaLocation. The schema
> location is a URI
> > > that identifies
> > > your XML Schema.
> > > You have several options:
> > >
> > > 1- using the absolute URI:
> > > <package>
> > > <name>foo.bar</name>
> > >
> > >
> <schemaLocation>file:///home/schemas/myschema.xsd</schem
> > aLocation>
> > > </package>
> > > When processing the schema myschema.xsd, Castor will
> > > create a location
> > > for it and the SourceGenerator will simply check that
> > > this location
> > > matches the one specified in the binding file.
> > >
> > > 2- using a relative URI
> > > <package>
> > > <name>foo.bar</name>
> > > <schemaLocation>./myschema.xsd</schemaLocation>
> > > </package>
> > >
> > > The Source Generator will compute the
> schemaLocation at
> > > runtime using
> > > the user current directory (user.dir property)
> > >
> > > 3- use the resource name
> > > <package>
> > > <name>foo.bar</name>
> > > <schemaLocation>myschema.xsd</schemaLocation>
> > > </package>
> > >
> > > In that case every 'myschema.xsd' whatever the URI is
> > > will generate
> > > sources in a foo.bar package.
> > >
> > > Let me know if it fits your needs,
> > >
> > > Arnaud
> > >
> > > > -----Original Message-----
> > > > From: Ostermueller, Erik
> [mailto:[EMAIL PROTECTED]
> > > > Sent: Friday, May 30, 2003 10:13 PM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [castor-dev] binding file --
> <package> element
> > > >
> > > > I wrote:
> > > > > Also, is the <package> node in any way a
> > > replacement for
> > > > > the property
> org.exolab.castor.builder.nspackages?
> > > > When you generate code, the answer is yes.
> > > >
> > > > > How about for the SourceGenerator -package
> > > command line
> > > > > parameter?
> > > > Again, when you generate code, the answer is yes, as
> > > long as you
> > > > put the same targetNamespace in both your schema and
> > > the binding file.
> > > >
> > > > I have another question, though. This ns-package
> > > mapping would
> > > > be very helpful when unmarshalling. Is there any
> > > code that inspects
> > > > the bindingfile during unmarshalling?
> > > >
> > > > I want it to detect a ns in an instance doc, locate
> > > the corresponding
> > > > java package in the binding file and then
> unmarshall the
> data.
> > > >
> > > > Also, I still haven't answered my original question:
> > > >
> > > > The binding file html doc says the <package> element
> > > allows you "to
> > > define the
> > > > mapping between a schemaLocation attribute
> and a Java
> > > package".
> > > >
> > > > Does this mean that the following binding
> file will place
> > > > all generated objects for Customer.xsd into the 'vo'
> package?
> > > > It's not working for me.
> > > >
> > > > <cbf:binding
> > >
> xmlns:cbf="http://www.castor.org/SourceGenerator/Binding"
> > > > defaultBindingType='type'>
> > > > <cbf:package>
> > > > <cbf:name>vo</cbf:name>
> > > >
> > >
> <cbf:schemaLocation>./Customer.xsd</cbf:schemaLocation>
> > > > </cbf:package>
> > > > </cbf:binding>
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > Erik
> > > >
> > > >
> -----------------------------------------------------------
> > > > If you wish to unsubscribe from this
> mailing, send mail to
> > > > [EMAIL PROTECTED] with a subject of:
> > > > unsubscribe castor-dev
> > >
> > >
> -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing,
> send mail to
> > > [EMAIL PROTECTED] with a subject of:
> > > unsubscribe castor-dev
> > >
> > >
> > > DISCLAIMER:
> > > This email message is for the sole use of the intended
> > > recipient(s) and may contain confidential and
> > > privileged information. Any unauthorized review, use,
> > > disclosure or distribution is prohibited. If you are
> > > not the intended recipient, please contact the sender
> > > by reply email and destroy all copies of the original
> > > message and attachments.
> > >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>
> DISCLAIMER:
> This email message is for the sole use of the intended
> recipient(s) and may contain confidential and
> privileged information. Any unauthorized review, use,
> disclosure or distribution is prohibited. If you are
> not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original
> message and attachments.
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev