Hi, I am new to XML and Castor Framework. I'll Appreciate if somebody can help me out.
Getting error " MarshalException The attribute 'noNamespaceSchemaLocation' appears illegally on element 'Comments'" when I try to get Java Objects corresponding to this XML file: Without the Shema Name Space Instance Use, It works fine but without any validation. <?xml version="1.0" encoding="UTF-8"?> <Comments xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NewCommentSync.xsd"> <CommentsKey> <SourceSystem>XEROX - eMAX</SourceSystem> <DestinationSystem>VFD</DestinationSystem> <DatetimeCreated>2002-09-09T16:10:33</DatetimeCreated> <EcommerceSubmittalID>123456789</EcommerceSubmittalID> <ApplicationType>1</ApplicationType> </CommentsKey> <Comment SequenceNumber="1"> <Type>General</Type> <Text>Test Comment 1</Text> <CreatedByUserID>Sanjay</CreatedByUserID> <CreatedDate>2002-09-09</CreatedDate> </Comment> </Comments> My Schema File "NewCommentSync.xsd" which is in the same directory as XML Document. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="C:\VendorFlowDecisioning\XML Schemas\NewCommentSync.xsl"?> <xs:schema xmlns:xs="http://www.w3.org/2000/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:include schemaLocation="vfdBaseTypes.xsd"/> //This Schema is also in the same directory as the other schemas <xs:annotation> <xs:documentation xml:lang="en"> Title: New Comments Sent To/From VFD Schema. Description: Official Comment XML Schema for sending Comments to and from the Vendor Flow Decisioning Application. Author: Steve Faiella Date: 8/26/2002 Copyright: Copyright 2002 GE.Com All rights reserved. </xs:documentation> </xs:annotation> <xs:element name="Comments"> <xs:complexType> <xs:sequence> <xs:element name="CommentsKey" type="UTvfdkey"/> <xs:element name="Comment" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Language" type="utlanguage" minOccurs="0"/> <xs:element name="Type" type="utexternalCommentType"/> <xs:element name="Text" type="utstring1500"/> <xs:element name="CreatedByUserID" type="xs:string"/> <xs:element name="CreatedDate" type="utdate"/> </xs:sequence> <xs:attribute name="Sequence" type="xs:integer" use="required"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Java Program I am using is like this: public static void main(String args[]) { Mapping mapping = new Mapping(); try { // 1. Load the mapping information from the file mapping.loadMapping( "P:\\CEF-Panther\\Sanjay\\VFD\\sudhi\\mappingsanjay.xml" ); // 2. Unmarshal the data Unmarshaller unmar = new Unmarshaller(mapping); unmar.setValidation(true); unmar.setIgnoreExtraAttributes(false); //If I comment out this line, parsing error goes away but then it doesn't report if a required attribute is missing in XML Data t = System.currentTimeMillis(); CommentsLWBO ansSet = (CommentsLWBO)unmar.unmarshal(new InputSource(new FileReader("P:\\CEF-Panther\\Sanjay\\VFD\\java\\com\\gec\\sanjay\\Comments2.xml"))); } catch (MappingException e) { System.out.println("MappingException " + e.getMessage()); return; } catch (ValidationException e) { System.out.println("ValidationException "+ e.getMessage()); return; } catch (MarshalException e) { System.out.println("MarshalException "+ e.getMessage()); return; } catch (Exception e) { System.out.println("Exception "+ e.getMessage()); return; } Many many thinks in advance, Sanjay Barnwal e-Mail:[EMAIL PROTECTED] > g GE Capital > ____________________________________________ > Sanjay Kumar Barnwal > BirlaSoft Inc. > IT Shared Services > Mid-Market Finance > 101 East Ridge, > Danbury, CT-06810 > Tel:(203)749-6641(O), > DialCom: 8*662-6641 > Fax: (203)749-4013 > e-Mail:[EMAIL PROTECTED] > [EMAIL PROTECTED] > ____________________________________________ > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
