Hi Michael,

Firstly thanks a lot for your reply.

I did the changes that you had suggested.

The changes I did are as:
parser.setProperty("
http://apache.org/xml/properties/schema/external-schemaLocation";, "
http://schemas.xmlsoap.org/soap/envelope/ " + xsdFile);

The earlier error message has gone. Now I get another error that says:
cvc-complex-type.2.4.a: Invalid content was found starting with element
'SOAP-ENV:Body'. One of '{Body}' is expected.

I dont want to change the response.xml because it contains the response that
i get from the server and I dont want to play with that.

Please suggest me the steps I need to take for this.

Thanks and regards,
Sneha

On Mon, Jun 29, 2009 at 8:28 AM, Michael Glavassevich
<mrgla...@ca.ibm.com>wrote:

> Hi Shena,
>
> There may be other issues with your program but thought I'd point out that
> the following line isn't correct:
>
>
> > parser.setProperty("
> http://apache.org/xml/properties/schema/external-schemaLocation";,
> xsdFile);
>
> The external-schemaLocation property has the same semantics as the
> xsi:schemaLocation attribute. Its value is a list of pairs of URIs, where
> the odd values are the target namespaces of each schema document and the
> even values are hints for the locations of those schema documents. You've
> only specified a schema location. You need to add its namespace before it.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrgla...@ca.ibm.com
> E-mail: mrgla...@apache.org
>
> Mukul Gandhi <gandhi.mu...@gmail.com> wrote on 06/27/2009 02:18:04 AM:
>
>
> > Hi Sneha,
> >   I looked at the XML and XSD files, that you posted. I haven't looked
> > at deeply at the Java programs you posted.
> >
> > When I perform XSD validation of your XML file with the Xerces-J
> > sample, jaxp.SourceValidator I get quite a few errors. Some of them
> > are related to improper use of namespaces.
> >
> > I suggest, please first make sure, that your XML and the Schema are
> > correct at the XSD language level. You can use the Xerces-J utility
> > jaxp.SourceValidator to check that. I suggest please use the option -f
> > of this utility to enable full Schema checking.
> >
> > After the validation passes with this utility, you can go into the
> > Java API details (after having a quick look at your Java programs, I
> > find them largely ok).
> >
> > On Fri, Jun 26, 2009 at 11:08 AM, Sneha Nikum<snehani...@gmail.com>
> wrote:
> > > Hi Mukul,
> > >
> > > Thanks for your reply.
> > >
> > > To answer all your queries,
> > >
> > > 1. My input xml is Response.xml
> > > 2. The xsd file is GenericSchema.xsd which has the WSDLSchema.xsd
> imported
> > > into it. All the 3 files, Response.xml, GeneriSchema.xsd,
> WSDLSchema.xsd are
> > > in my disk at the same location
> > > I am using eclipse version 3.4.1 So all the three files are directly in
> the
> > > project folder.
> > >
> > > 3. The code for performing the validation is as below:
> > >
> > > public static void main(String[] args) {
> > >         System.out.println("in main class");
> > >
> > >         boolean status = false;
> > >
> > >         SchemaValidator testXml = new SchemaValidator("Response.xml",
> > > "GenericSchema.xsd");
> > >
> > >         try {
> > >             status = testXml.process();
> > >             if (status) {
> > >                 System.out.println("Response is OK.");
> > >             }
> > >         } catch (SAXParseException e) {
> > >             //e.printStackTrace();
> > >             System.err.println("Validation failed\n" + e.getMessage() +
> > > "\nline " + e.getLineNumber() + ", column " + e.getColumnNumber() +
> "\n");
> > >         } catch (SAXException e) {
> > >             e.printStackTrace();
> > >         } catch (Exception e) {
> > >             e.printStackTrace();
> > >         } finally {
> > >             //System.out.println(status);
> > >         }
> > >
> > >     }
> > > public class SchemaValidator {
> > >     private String xmlFile = "";
> > >     private String xsdFile = "";
> > >
> > >     public SchemaValidator(String xmlFile, String xsdFile) {
> > >         this.xmlFile = xmlFile;
> > >         this.xsdFile = xsdFile;
> > >
> > >     }
> > >
> > >         public boolean process() throws SAXParseException,
> SAXException,
> > > Exception {
> > >             boolean status = true;
> > >             final String factoryImpl =
> > > System.getProperty("javax.xml.parsers.SAXParserFactory");
> > >             if (factoryImpl == null) {
> > >
> System.setProperty("javax.xml.parsers.SAXParserFactory",
> > >                 "org.apache.xerces.jaxp.SAXParserFactoryImpl");
> > >             }
> > >
> > >             final SAXParserFactory factory =
> SAXParserFactory.newInstance();
> > >             factory.setNamespaceAware(true);
> > >             factory.setValidating(true);
> > >             factory.setFeature("http://xml.org/sax/features/validation
> ",
> > > true);
> > >
> > > factory.setFeature("http://apache.org/xml/features/validation/schema
> ",true);
> > >
> > > factory.setFeature("http://apache.
> > org/xml/features/validation/schema-full-checking",
> > > true);
> > >             final SAXParser parser = factory.newSAXParser();
> > >             System.out.println("the xsd file is: " + xsdFile);
> > >
> > > parser.setProperty("http://apache.
> > org/xml/properties/schema/external-schemaLocation",
> > > xsdFile);
> > >
> > > //parser.setProperty("http://apache.
> > org/xml/properties/schema/external-noNamespaceSchemaLocation",
> > > xsdFile);
> > >             parser.parse(new FileInputStream(xmlFile), new
> DefaultHandler()
> > > {
> > >                 public void error(SAXParseException e) throws
> SAXException {
> > >                     final boolean status = false;
> > >                     throw e;
> > >                 }
> > >             });
> > >             return status;
> > >         }
> > >
> > >     }
> > >
> > > 4. I am using Xerces-J version 2.9.1
> > >
> > > Please do let me know if you require any other information from my
> side.
> > >
> > > Thanks in advance.
> > >
> > > Regards,
> > > Sneha
> >
> >
> >
> > --
> > Regards,
> > Mukul Gandhi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> > For additional commands, e-mail: j-users-h...@xerces.apache.org
>
>

Reply via email to