Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / February 2004

Tip: Looking for answers? Try searching our database.

PLEASE PLEASE HELP - Castor porblem

Thread view: 
Gandu - 12 Jan 2004 06:16 GMT
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.
ZJT - 09 Feb 2004 03:20 GMT
> 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.
[quoted text clipped - 79 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.