AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PLEASE PLEASE HELP - Castor porblem

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Software Tools
View previous topic :: View next topic  
Author Message
Gandu
Guest





PostPosted: Mon Jan 12, 2004 6:16 am    Post subject: PLEASE PLEASE HELP - Castor porblem Reply with quote



I am a newbie to Castor. I downloaded all the jar files, made changes
to the classpath etc, but I keep on getting exceptions being thrown.

The XML schema file is as follows:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="catalog">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="book" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float"/>
<xsd:element name="publish_date" type="xsd:date"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

If I type in:
C:>java org.exolab.castor.builder.SourceGenerator -i
C:\Temp\Test.xsd

I get the error message:
Exception in thread "main" 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.scanRootElementHook(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.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:583)
at org.exolab.castor.mapping.Mapping.loadMappingInternal(Mapping.java:515)
at org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:441)
at org.exolab.castor.xml.schema.SimpleTypesFactory.loadTypesDefinitions(SimpleTypesFactory.java:414)
at org.exolab.castor.xml.schema.SimpleTypesFactory.getType(SimpleTypesFactory.java:380)
at org.exolab.castor.xml.schema.SimpleTypesFactory.getBuiltInType(SimpleTypesFactory.java:202)
at org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:919)
at org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:858)
at org.exolab.castor.xml.schema.TypeReference.resolveTypeReference(TypeReference.java:113)
at org.exolab.castor.xml.schema.TypeReference.getType(TypeReference.java:69)
at org.exolab.castor.xml.schema.ElementDecl.getType(ElementDecl.java:327)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:743)
at org.exolab.castor.xml.schema.Group.validate(Group.java:471)
at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:795)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:748)
at org.exolab.castor.xml.schema.Group.validate(Group.java:471)
at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:795)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:748)
at org.exolab.castor.xml.schema.Schema.validate(Schema.java:1466)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:312)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:394)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:425)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:760)

Any help would be greatly appreciated. Thanks in advance for your
help.
Back to top
ZJT
Guest





PostPosted: Mon Feb 09, 2004 3:20 am    Post subject: Re: PLEASE PLEASE HELP - Castor porblem Reply with quote



[email]cpptutor2000 (AT) yahoo (DOT) com[/email] (Gandu) wrote in message news:<3c7c9804.0401112216.208ff066 (AT) posting (DOT) google.com>...
Quote:
I am a newbie to Castor. I downloaded all the jar files, made changes
to the classpath etc, but I keep on getting exceptions being thrown.

The XML schema file is as follows:
xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsd:element name="catalog"
xsd:complexType
xsd:sequence
xsd:element name="book" minOccurs="0" maxOccurs="unbounded"
xsd:complexType
xsd:sequence
xsd:element name="author" type="xsd:string"/
xsd:element name="title" type="xsd:string"/
xsd:element name="genre" type="xsd:string"/
xsd:element name="price" type="xsd:float"/
xsd:element name="publish_date" type="xsd:date"/
xsd:element name="description" type="xsd:string"/
/xsd:sequence
xsd:attribute name="id" type="xsd:string"/
/xsd:complexType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema

If I type in:
C:>java org.exolab.castor.builder.SourceGenerator -i
C:\Temp\Test.xsd

I get the error message:
Exception in thread "main" 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.scanRootElementHook(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.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:583)
at org.exolab.castor.mapping.Mapping.loadMappingInternal(Mapping.java:515)
at org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:441)
at org.exolab.castor.xml.schema.SimpleTypesFactory.loadTypesDefinitions(SimpleTypesFactory.java:414)
at org.exolab.castor.xml.schema.SimpleTypesFactory.getType(SimpleTypesFactory.java:380)
at org.exolab.castor.xml.schema.SimpleTypesFactory.getBuiltInType(SimpleTypesFactory.java:202)
at org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:919)
at org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:858)
at org.exolab.castor.xml.schema.TypeReference.resolveTypeReference(TypeReference.java:113)
at org.exolab.castor.xml.schema.TypeReference.getType(TypeReference.java:69)
at org.exolab.castor.xml.schema.ElementDecl.getType(ElementDecl.java:327)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:743)
at org.exolab.castor.xml.schema.Group.validate(Group.java:471)
at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:795)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:748)
at org.exolab.castor.xml.schema.Group.validate(Group.java:471)
at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:795)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:748)
at org.exolab.castor.xml.schema.Schema.validate(Schema.java:1466)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:312)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:394)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:425)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:760)

Any help would be greatly appreciated. Thanks in advance for your
help.

For Castor 0.9.5.2

The issue occurs with newer versions of Xerces than the version 1.4
that ships with Castor. The older version works ok. For some reason,
when the newer version of Xerces encounters an "xml" prefixed
attribute, such as "xml:lang" it tries to automatically start a prefix
mapping for "xml". Which, in my opinion, is technically incorrect.
They shouldn't be doing that. According to the w3c, the "xml" prefix
should never be declared.


The reason it started appearing in the new Castor (0.9.5.2), was
because of a switch to SAX 2 by default during unmarshalling.

Solution:
A built in work-around has been checked into the Castor CVS and will
automatically exist in any post 0.9.5.2 releases. For those who are
using 0.9.5.2 and can't upgrade I found a simple workaround (tested
with Xerces 2.5) , at first I thought about disabling namespace
processing in Xerces, but then realized that it's already disabled by
default by Castor...so I have no idea why they call
#startPrefixMapping when namespace processing has been disabled. But
in any event... explicitly enabling namespace processing seems to fix
the problem:


in the castor.properties file change the following line:

org.exolab.castor.parser.namespaces=false

to:

org.exolab.castor.parser.namespaces=true
Note: that work-around has only been tested with Xerces
2.5.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Software Tools All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.