Hm, maybe I'm misunderstanding the purpose of the mapping file.  I simply
want to map from an XML file containing data into a Java object
representation of that data.  The Castor mapping XML file seems like the
most logical way to do this without having to write a Java XML parser.  The
XSD merely provides requirements on how the XML file should be formed.

I simply followed the guide at
http://www.castor.org/how-to-enable-xml-validation.html to get my XML file
validated against the XSD, but I'm having the issues I previously mentioned.

What are you talking about when you mention "internal descriptor classes"?
I looked over your website, and it primarily talks about the mapping file,
so I'm a little confused.  I don't see any mention of "internal descriptor
classes."

Thanks for your help.

Geoff

On Wed, Jul 16, 2008 at 4:40 AM, Werner Guttmann <[EMAIL PROTECTED]>
wrote:

> Geoffrey,
>
> why do you want to be using a mapping file to map your Java classes to
> XML when you have an XML schema available and as such could be in a
> position where you generate Java classes (and internal descriptor
> classes) from the XML schema, and as such avoid having to write a
> mapping file.
>
> Geoffrey Fairchild wrote:
> > First of all, if you have a Something Awful account, you can read a more
> > formatted version of this here:
> > http://forums.somethingawful.com/showthread.php?threadid=2902508
> >
> >
> >
> > I'll go ahead and rewrite this if you don't have an account.
> >
> >
> >
> > I've been messing with this most of the afternoon, and I just can't
> figure
> > it out.
> >
> >
> >
> > Basically, I've got an XML file I've got to parse.  I need to put the
> data
> > into a few Java objects, and Castor is a really easy way to do it.
>  Castor's
> > working, and it's putting the data in the container properly.  The
> problem
> > is that I have an XSD schema file defined to validate the XML file, but
> I'm
> > having issues getting Castor to validate it.  The XSD is necessary
> because I
> > can type complete garbage into the XML file, and Castor reports success
> even
> > though it's totally invalid XML.
> That's an odd statement. If it's not valid XML, Castor will report
> exceptions.
>
> > I want to prevent this from happening.
> >
> >
> >
> > I'll get to it.  Here're the pertinent lines from *castor.xml*, the file
> > that Castor uses to map the XML elements/attributes to the Java objects:
> >
> >
> >
> > <?xml version="1.0"?>
> >
> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> >
> >             "http://castor.org/mapping.dtd";>
> >
> >
> >
> > <mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >
> >             xmlns="http://centurylogix.com/dbconfig";
> >
> >             xsi:schemaLocation="
> http://centurylogix.com/dbconfigdb-config-1.0.xsd";>
> >
> >
> >
> >             <class
> > name="com.centurylogix.graph.hybrid.io.containers.DataSourceInfo">
> >
> >                         <map-to xml="dataSource" ns-uri="
> > http://centurylogix.com/dbconfig"; />
>
> Why on earth are you referencing the XML schema file from your mapping
> file ? That does not make sense at all. If you want Castor to validate
> your XML document instance against an XML schema, please refer to the
> XML schema from the XML document instance 8and nowhere else).
>
> >
> > If you need more than that, I can post it, but those should be the only
> > relevant lines.
> >
> >
> >
> > Here're the first few lines from *db-config-1.0.xsd* which is obviously
> the
> > schema file used to verify the XML file:
> >
> >
> >
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> >
> >             targetNamespace="http://centurylogix.com/dbconfig";
> >
> >             xmlns="http://centurylogix.com/dbconfig";
> >
> >             elementFormDefault="qualified">
> >
> >
> >
> > And here're the first few lines from *db-config-sample.xml*, a sample XML
> > file that Castor reads in and puts into the correct Java objects:
> >
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <dataSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >
> >             xsi:schemaLocation="
> http://centurylogix.com/dbconfigdb-config-1.0.xsd";>
> >
> >
> >
> > I do have a *castor.properties* file defined with the following contents,
> > per http://www.castor.org/how-to-enable-xml-validation.html:
> >
> >
> >
> > org.exolab.castor.indent=true
> >
> > org.exolab.castor.parser.namespaces=true
> >
> > org.exolab.castor.sax.features=http://xml.org/sax/features/validation,\<http://xml.org/sax/features/validation,%5C>
> >
> >             
> > http://apache.org/xml/features/validation/schema,\<http://apache.org/xml/features/validation/schema,%5C>
> >
> >
> http://apache.org/xml/features/validation/schema-full-checking
> >
> >
> >
> > When I try to unmarshal the data, this is the error I get:
> >
> >
> >
> > java.lang.RuntimeException: org.exolab.castor.mapping.MappingException:
> > Nested error: org.exolab.castor.xml.MarshalException: Attribute
> "xmlns:xsi"
> > must be declared for element type "mapping".{File: [not available]; line:
> 7;
> > column: 74}
> >
> >
> >
> > I don't quite understand this error.  "xmlns:xsi" is clearly  defined in
> the
> > mapping element in castor.xml.  Do any of you know what I'm doing wrong?
> > Any ideas at all?  I think this is one those things that's probably
> simple
> > to fix, but I've just been staring at it too long, and I'm not seeing the
> > solution.  Thanks!
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

Reply via email to