*** Schema (AccCard.xsd) ***
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:element name="UserID" >
<xsd:simpleType>
<xsd:restriction base="xsd:string"><xsd:maxLength value="8" /></xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Header">
<xsd:complexType>
<xsd:sequence><xsd:element ref="UserID" minOccurs="1" maxOccurs="1"/></xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AccCard">
<xsd:complexType>
<xsd:sequence><xsd:element ref="Header" maxOccurs="1" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
*** XML Document (AccCard.xml) ***
<?xml version="1.0" encoding="UTF-8"?>
<AccCard xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AccCard.xsd">
<Header>
<UserID>clive</UserID>
</Header>
</AccCard>
*** castor.properties changes *** org.exolab.castor.parser.validation=true org.exolab.castor.parser.namespaces=true org.exolab.castor.features=http://xml.org/sax/features/validation,http://apache.org/xml/features/validation/schema,http://apache.org/xml/features/validation/dynamic org.exolab.castor.debug=true
*** Java snippet *** Mapping mapping = new Mapping(); mapping.loadMapping(this.getClass().getResource(MAPFILE)); Unmarshaller unmar = new Unmarshaller(mapping); AccCardVO ccMaster = (AccCardVO)unmar.unmarshal(new InputSource(is));
*** Mapping file ***
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<mapping>
<description>Castor generated mapping file</description>
<class name="AccCardHeaderVO">
<description>Default mapping for class AccCardVO</description>
<field name="user_id" type="java.lang.String"><bind-xml name="UserID" node="element" /></field>
<class name="AccCardVO">
<description>Default mapping for class AccCardVO</description>
<map-to xml="AccCard"/>
<field name="ccHeader" type="AccCardHeaderVO">
<bind-xml name="Header" node="element" />
</field>
</class>
</mapping>
*** Output *** Version=Xerces-J 2.5.0 #startElement: mapping #startElement: description #endElement: description #startElement: class #startElement: description #endElement: description #startElement: field #startElement: bind-xml #endElement: bind-xml #endElement: field #endElement: class #startElement: class #startElement: description #endElement: description #startElement: map-to #endElement: map-to #startElement: field #startElement: bind-xml #endElement: bind-xml #endElement: field #endElement: mapping
Parsing Error : Document is invalid: no grammar found. Line : 2 Column : 12
*** Other *** Classpath=xml-apis.jar, xercesImpl.jar, castor-0.9.5-xml.jar, j2ee.jar Xerces version 2.5 J2EE 1.3
(BTW, XML and Java have been cut-down)
Thanks again , I appreciate it Clive
From: "Ostermueller, Erik" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Validating XML documents and namespaces Date: Wed, 3 Sep 2003 15:36:14 -0500
For starters, it doesn't make much sense to ask (by way of castor.properties)
for both parser validation (...parser.validation=true) and Castor validation (...marshalling.validation=true).
You only need one of these set to 'true'. Setting both to 'true' will just waste cycles.
Could you post a small-as-possible example so we can have a first-hand look at the namespace issues?
Thanks,
Erik
_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today! http://www.msn.co.uk/messenger
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
