Hi,
(copy of a previous mail in castor-dev)
Edit the properties file : castor.properties provided in the jar file to enable namespaces to the following and then execute again ..


org.exolab.castor.parser.namespaces=true

This should work.

[EMAIL PROTECTED] wrote:
Hello,

This is my second attempt to use castor. In both cases I can create the java code via the .xsd file(schema). It builds under eclipse just fine. I can run the code that calls the marshal methods and it works just fine. I can test the 'well formed' and 'validity' of generated xml via xmlspy5 and it checks out ok!

But when I try to unmarshal the resultant .xml file the code generates an IllegalArgumentException.

This is an example from:

http://www.xml.com/pub/a/2002/07/24/databinding.html

It's really very straight forward, but I don't know what to do anymore!!!!

HELP HELP HELP I'm really stuck!!!!


Below is the stack dump from my current attempt:



java.lang.IllegalArgumentException: The prefix 'xml' is reserved (XML 1.0 Specification) and cannot be declared.
at org.exolab.castor.xml.Namespaces.addNamespace(Namespaces.java:130)
at org.exolab.castor.xml.UnmarshalHandler.startPrefixMapping(UnmarshalHandler.java:
1953)
at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementH
ook(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.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:583)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:491)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:669)
at org.dogshow.Show.unmarshal(Show.java:93)
at org.dogshow.LoadDogShow.main(LoadDogShow.java:10)



this is my current classpath in eclipse:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/xerces-2_5_0/xercesImpl.jar"/>
<classpathentry kind="lib" path="C:/xerces-2_5_0/xercesSamples.jar"/>
<classpathentry kind="lib" path="C:/xerces-2_5_0/xml-apis.jar"/>
<classpathentry kind="lib" path="C:/xerces-2_5_0/xmlParserAPIs.jar"/>
<classpathentry kind="lib" path="C:/castor/castor-0.9.5.2/castor-0.9.5.2/jta1.0.1.jar"/>
<classpathentry kind="lib" path="C:/castor/castor-0.9.5.2/castor-0.9.5.2/castor-0.9.5.2.jar"/>
<classpathentry kind="lib" path="C:/castor/castor-0.9.5.2/castor-0.9.5.2/castor-0.9.5.2-xml.jar"/>
<classpathentry kind="lib" path="C:/castor/castor-0.9.5.2/castor-0.9.5.2/jdbc-se2.0.jar"/>
<classpathentry kind="output" path=""/>
</classpath>


I'm using the Sun JRE 1.4.2_01

Heres the generated XML:

<?xml version="1.0" encoding="UTF-8"?>
<Show><id>1</id><name>O'Reilly Invitational Dog Show</name><judging><breed><id>1</id><name>English Springer Spaniel</name><dog><id>1</id><name>Wil-Orion's Angus Highlander</name></dog><dog><id>2</id><name>LenLear's Webmaster</name></dog></breed><judge><id>1</id><firstName>John</firstName><lastN
ame>Smith</lastName></judge><showRing><id>1</id><name>1</name></showRing><dateTi
me>2003-11-02T18:56:50.359-05:00</dateTime></judging></Show>


Heres the schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified">
<xs:complexType name="ShowType">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="judging" type="JudgingType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BreedType">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="dog" type="DogType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DogType">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="JudgeType">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element name="firstName" type="xs:string"/>
<xs:element name="lastName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ShowRingType">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="JudgingType">
<xs:sequence>
<xs:element name="breed" type="BreedType"/>
<xs:element name="judge" type="JudgeType"/>
<xs:element name="showRing" type="ShowRingType"/>
<xs:element name="dateTime" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Show" type="ShowType" nillable="false"/>
<xs:element name="Breed" type="BreedType" nillable="true"/>
<xs:element name="Dog" type="DogType" nillable="true"/>
<xs:element name="Judge" type="JudgeType" nillable="true"/>
<xs:element name="ShowRing" type="ShowRingType" nillable="true"/>
<xs:element name="Judging" type="JudgingType" nillable="true"/>
</xs:schema>


And heres the unmarshal code:

package org.dogshow;

import java.io.FileReader;

public class LoadDogShow {
        public static void main(String [] args) {
        try {
                FileReader reader = new FileReader("show.xml");
                
                Show show = (Show) Show.unmarshal(reader);
                

                System.out.println(show.getJudging()[0].
                                getBreed().getDog()[0].getName());

                reader.close();
        } catch (Exception e) {
                e.printStackTrace(System.err);
        }
        }
}

----------------------------------------------------------- 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




Reply via email to