Hi all,
I'm trying to unmarshal an object from XML source using castor-1.2. The
XML format was defined separately (eg. it's not a product of marshaling).
Currently I have this problem:
The first problem is with a container element. I have a <parameters>
element that contains zero or more parameter elements. I have tried to
configure this in the mapping on the bind-xml element's location
attribute, but that doesn't seem to work.
I get this exception (only the relevant part):
Caused by: java.lang.NullPointerException
at
org.exolab.castor.xml.MarshalFramework.searchInheritance(MarshalFramework.java:547)
at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1865)
at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1418)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:715)
...
I have included both the XML source and the mapping file as an attachment.
Any help would be greatly appreciated!
--
Peter Molnar <[EMAIL PROTECTED]><?xml version="1.0" encoding="utf-8"?><!-- -*-nxml-*- -->
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://castor.exolab.org/"
xsi:schemaLocation="http://castor.org/mapping.xsd">
<!-- <description>Mapping file to unmarshall report objects from xml.</description> -->
<class name="hu.sztaki.weblog.ui.Report">
<!-- <description>Mapping for the Report object.</description> -->
<map-to xml="report"/>
<field name="title" type="string" required="true">
<bind-xml name="title" type="string" node="element"/>
</field>
<field name="description" type="string" required="true">
<bind-xml name="description" node="element"/>
</field>
<field name="category" type="string" required="true">
<bind-xml name="category" node="element"/>
</field>
<field name="parameters" type="hu.sztaki.weblog.ui.Parameter" collection="arraylist">
<bind-xml node="element" location="parameters" auto-naming="deriveByClass"/>
</field>
<field name="query" type="string" required="true">
<bind-xml name="query" node="element"/>
</field>
</class>
<!-- ====== PARAMETERS ====== -->
<class name="hu.sztaki.weblog.ui.Parameter">
<field name="bindName" type="string" required="true">
<bind-xml name="bindName" node="attribute"/>
</field>
<field name="omitValue" type="boolean" required="false">
<bind-xml name="omitValue" node="attribute"/>
</field>
<field name="constraints" collection="arraylist">
<bind-xml node="element" location="constraints" auto-naming="deriveByClass"/>
</field>
</class>
<class name="hu.sztaki.weblog.ui.IntegerParameter"
extends="hu.sztaki.weblog.ui.Parameter">
<map-to xml="integer-parameter"/>
</class>
<!-- ====== CONSTRAINTS ====== -->
<class name="hu.sztaki.weblog.ui.constraint.ConstraintAdaptor">
<field name="debug" type="boolean" required="false">
<bind-xml name="debug" node="attribute"/>
</field>
</class>
<class name="hu.sztaki.weblog.ui.constraint.RegexpConstraint"
extends="hu.sztaki.weblog.ui.constraint.ConstraintAdaptor">
<map-to xml="regexp-constraint"/>
<field name="pattern" type="string" required="true">
<bind-xml name="pattern" type="string" node="attribute"/>
</field>
</class>
<class name="hu.sztaki.weblog.ui.constraint.IntegerFormatConstraint"
extends="hu.sztaki.weblog.ui.constraint.RegexpConstraint">
<map-to xml="integer-format-constraint"/>
</class>
<class name="hu.sztaki.weblog.ui.constraint.FloatFormatConstraint"
extends="hu.sztaki.weblog.ui.constraint.RegexpConstraint">
<map-to xml="float-format-constraint"/>
</class>
<class name="hu.sztaki.weblog.ui.constraint.BooleanFormatConstraint"
extends="hu.sztaki.weblog.ui.constraint.ConstraintAdaptor">
<map-to xml="boolean-format-constraint"/>
</class>
</mapping><?xml version="1.0" encoding="utf-8"?>
<report>
<title>Test report 1</title>
<description>Test description 1</description>
<category>Group 1/Group 2</category>
<parameters>
<integer-parameter bindName="age" omitValue="true">
<constraints>
<integer-format-constraint/>
</constraints>
</integer-parameter>
</parameters>
<query>SELECT * FROM test_table</query>
</report>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email