Hi Jesse,

You can specify namespace-to-package mappings in the castor.properties file or using the addNamespaceToPackageMapping() method.

This will map all elements from a given namespace to a specific package.

Remember that when you have <ns1:foo> that the ns1 prefix must be mapped to an actual namespace eg:

<ns1:foo xmlns:ns1="http://org.acme/foo-namespace";>

In the castor.properties file you would add the "http://org.acme/foo-namespace"; to the set of namespace to package mappings, eg:

# XML namespace mapping to Java packages
#
org.exolab.castor.xml.nspackages=\
  http://org.acme/foo-namespace=org.acme.foo,\
  http://org.acme/bar-namespace=org.acme.bar


As for the NullPointerException, those are never good. If you can open up a bug report and attach a simple test case which reproduces the problem that would be great.


--Keith


Jesse Shieh wrote:
Is there a way for to specify a namespace-to-package mapping for tags the
same way you can use unmarshaller.addNamespaceToPackageMapping() for
xsi:types?

I want to be able to specify the mapping that way when castor sees a tag
with a namespace, it will know exactly what package to look for that class
in.  I know I can do this with a mapping file, but then I would have to have
to do this for every single tag that needs the namespace resolution.  The
schema I am working with is extremely large, so this really isn't an option.

i.e.

<engine>
  <ns1:processor>
    <name>p1</name>
  </ns1:processor>
<engine>

Is there a way for castor to see ns1 and map that to a package for any tag?
Actually it would almost be good enough if I could tell castor to ignore the
namespace.  Is that possible?  Currently, it sees ns1:processor and gives me
a NullPointerException probably because it can't find the processor field
using introspection?

java.lang.NullPointerException
        at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:14
10)
        at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:11
49)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:1284)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1171)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:583)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:491)
        at
com.liaison.uccnet.castor.polymorphism.MappingEngine.unmarshal(MappingEngine
.java:53)
        at
com.liaison.uccnet.castor.polymorphism.MappingEngine.main(MappingEngine.java
:129)

Thanks!




----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to