You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Sneha Nikum <sn...@gmail.com> on 2009/06/25 12:33:31 UTC

cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Hi All,

I am totally new to xerces. I am trying to validate a SOAP response against
its xsd files and am getting the error as
cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

The Response .xml file is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"

xsi:schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
namespace="urn:sms"
    >
    <SOAP-ENV:Body>
        <ns1:sendSMSToManyResponse xmlns:ns1="urn:SendSMSToMany">
            <status xsi:type="xsd:string">invalid login</status>
        </ns1:sendSMSToManyResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

GenericSchema.xsd

<schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
    xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:tn="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:pr1="urn:sms">
    <xsd:import
schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
namespace="urn:sms" />

    <element name="Envelope" type="tn:EnvelopeType" />
    <complexType name="EnvelopeType">
        <sequence>
            <element name="Body" type="tn:BodyType" />
        </sequence>
    </complexType>
    <complexType name="BodyType">
        <choice>
            <element ref="pr1:sendSMSToManyRequest"/>
            <element ref="pr1:sendSMSToManyResponse"/>
    </choice>
    </complexType>
</schema>

WSDLSchema.xsd

<xsd:schema targetNamespace="urn:sms"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="
http://www.w3.org/2001/XMLSchema">
    <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
    <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
    <element name="sendSMSToManyRequest">
        <complexType>
            <sequence>
                <element name="uid" type="xsd:string" />
                <element name="pwd" type="xsd:string" />
                <element name="phone" type="xsd:string" />
                <element name="msg" type="xsd:string" />
            </sequence>
        </complexType>
    </element>
    <element name="sendSMSToManyResponse">
        <complexType>
            <sequence>
                <element name="status" type="xsd:string" />
            </sequence>
        </complexType>
    </element>
</xsd:schema>


Also the code that I am using is the same as the one Gunni has written in
the following link:
http://forums.sun.com/thread.jspa?threadID=250998&start=15&tstart=0

I have looked on the net for various solutions for teh same, but have not
yet been able to solve it.

Please please please help.


Thanks and Regards,
-- 
Sneha

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Sneha Nikum <sn...@gmail.com>.
Hi Michael,

Thanks a lot for all the help.
I had figured it out yeserday and it worked for me after I changed my
genericSchema.xsd and added namespace to it.

Thanks a lot. :)
Sneha

On Tue, Jun 30, 2009 at 6:58 AM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

>  Hi Sneha,
>
> Sneha Nikum <sn...@gmail.com> wrote on 06/29/2009 02:25:29 AM:
>
> > 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.
>
> Have you tried using the official SOAP schema which you can download from:
> "http://schemas.xmlsoap.org/soap/envelope/"? The GenericSchema.xsd
> document you had posted is different from this. In particular in
> GenericSchema.xsd the "Body" element has been declared locally and has no
> namespace. In the official schema "Body" is global and has the "
> http://schemas.xmlsoap.org/soap/envelope/" namespace. Only the latter
> corresponds to the definition of the SOAP envelope.
>
> > Thanks and regards,
> > Sneha
>
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Sneha,:

Sneha Nikum <sn...@gmail.com> wrote on 06/29/2009 02:25:29 AM:

> 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.

Have you tried using the official SOAP schema which you can download from:
"http://schemas.xmlsoap.org/soap/envelope/"? The GenericSchema.xsd document
you had posted is different from this. In particular in GenericSchema.xsd
the "Body" element has been declared locally and has no namespace. In the
official schema "Body" is global and has the
"http://schemas.xmlsoap.org/soap/envelope/" namespace. Only the latter
corresponds to the definition of the SOAP envelope.

> Thanks and regards,
> Sneha

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Sneha Nikum <sn...@gmail.com>.
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
<mr...@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: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Mukul Gandhi <ga...@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<sn...@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-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Sneha Nikum <sn...@gmail.com>.
Hi Mukul,

Thanks for your inputs. I tried the jaxp.SourceValidation code. What are the
inputs that you have provided for the code.

When I give the arguments as:
java SourceValidation -l http://www.w3.org/2001/XMLSchema -x 1 -a
/home/sneha/WORK/workspace/WSDLConverter
/SOAPSchema.xsd  -vs sax -f on -hs on -va  on -ga  on -m on

I am not getting any errors. Please do let me know the inputs that you are
providing also please give me feedback whether I am giving the right inputs
or not.

Thanks a lot.
Sneha

On Sat, Jun 27, 2009 at 11:48 AM, Mukul Gandhi <ga...@gmail.com>wrote:

> 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<sn...@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-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
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: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Mukul Gandhi <ga...@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<sn...@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-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Mukul Gandhi <ga...@gmail.com>.
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<sn...@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-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Sneha Nikum <sn...@gmail.com>.
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

On Fri, Jun 26, 2009 at 10:53 AM, Mukul Gandhi <ga...@gmail.com>wrote:

> Hi Sneha,
>   Could you please let us know:
>
> 1. What is your input XML (I guess it's Response.xml)? but please confirm..
> 2. What XSD document you are using to validate this XML? What is it's
> location?
> 3. How are you performing the validation? Do you use some API? If yes,
> which API are you using?
> 4. Which version of Xerces-J are you using?
>
> After we could know the answers to these questions, it would be easy
> to reproduce the problem, and suggest something.
>
> On Thu, Jun 25, 2009 at 4:03 PM, Sneha Nikum<sn...@gmail.com> wrote:
> > Hi All,
> >
> > I am totally new to xerces. I am trying to validate a SOAP response
> against
> > its xsd files and am getting the error as
> > cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope
> >
> > The Response .xml file is:
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <SOAP-ENV:Envelope
> > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> >     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >     xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> >
> >
> xsi:schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> > namespace="urn:sms"
> >     >
> >     <SOAP-ENV:Body>
> >         <ns1:sendSMSToManyResponse xmlns:ns1="urn:SendSMSToMany">
> >             <status xsi:type="xsd:string">invalid login</status>
> >         </ns1:sendSMSToManyResponse>
> >     </SOAP-ENV:Body>
> > </SOAP-ENV:Envelope>
> >
> > GenericSchema.xsd
> >
> > <schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
> >     xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"
> >     xmlns:tn="http://schemas.xmlsoap.org/soap/envelope/"
> >     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >     xmlns="http://www.w3.org/2001/XMLSchema"
> >     xmlns:pr1="urn:sms">
> >     <xsd:import
> >
> schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> > namespace="urn:sms" />
> >
> >     <element name="Envelope" type="tn:EnvelopeType" />
> >     <complexType name="EnvelopeType">
> >         <sequence>
> >             <element name="Body" type="tn:BodyType" />
> >         </sequence>
> >     </complexType>
> >     <complexType name="BodyType">
> >         <choice>
> >             <element ref="pr1:sendSMSToManyRequest"/>
> >             <element ref="pr1:sendSMSToManyResponse"/>
> >     </choice>
> >     </complexType>
> > </schema>
> >
> > WSDLSchema.xsd
> >
> > <xsd:schema targetNamespace="urn:sms"
> >     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns="http://www.w3.org/2001/XMLSchema">
> >     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
> >     <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
> >     <element name="sendSMSToManyRequest">
> >         <complexType>
> >             <sequence>
> >                 <element name="uid" type="xsd:string" />
> >                 <element name="pwd" type="xsd:string" />
> >                 <element name="phone" type="xsd:string" />
> >                 <element name="msg" type="xsd:string" />
> >             </sequence>
> >         </complexType>
> >     </element>
> >     <element name="sendSMSToManyResponse">
> >         <complexType>
> >             <sequence>
> >                 <element name="status" type="xsd:string" />
> >             </sequence>
> >         </complexType>
> >     </element>
> > </xsd:schema>
> >
> >
> > Also the code that I am using is the same as the one Gunni has written in
> > the following link:
> > http://forums.sun.com/thread.jspa?threadID=250998&start=15&tstart=0
> >
> > I have looked on the net for various solutions for teh same, but have not
> > yet been able to solve it.
> >
> > Please please please help.
> >
> >
> > Thanks and Regards,
> > --
> > Sneha
>
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Sneha,
   Could you please let us know:

1. What is your input XML (I guess it's Response.xml)? but please confirm..
2. What XSD document you are using to validate this XML? What is it's location?
3. How are you performing the validation? Do you use some API? If yes,
which API are you using?
4. Which version of Xerces-J are you using?

After we could know the answers to these questions, it would be easy
to reproduce the problem, and suggest something.

On Thu, Jun 25, 2009 at 4:03 PM, Sneha Nikum<sn...@gmail.com> wrote:
> Hi All,
>
> I am totally new to xerces. I am trying to validate a SOAP response against
> its xsd files and am getting the error as
> cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope
>
> The Response .xml file is:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
>
> xsi:schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> namespace="urn:sms"
>     >
>     <SOAP-ENV:Body>
>         <ns1:sendSMSToManyResponse xmlns:ns1="urn:SendSMSToMany">
>             <status xsi:type="xsd:string">invalid login</status>
>         </ns1:sendSMSToManyResponse>
>     </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> GenericSchema.xsd
>
> <schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
>     xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:tn="http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>     xmlns="http://www.w3.org/2001/XMLSchema"
>     xmlns:pr1="urn:sms">
>     <xsd:import
> schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> namespace="urn:sms" />
>
>     <element name="Envelope" type="tn:EnvelopeType" />
>     <complexType name="EnvelopeType">
>         <sequence>
>             <element name="Body" type="tn:BodyType" />
>         </sequence>
>     </complexType>
>     <complexType name="BodyType">
>         <choice>
>             <element ref="pr1:sendSMSToManyRequest"/>
>             <element ref="pr1:sendSMSToManyResponse"/>
>     </choice>
>     </complexType>
> </schema>
>
> WSDLSchema.xsd
>
> <xsd:schema targetNamespace="urn:sms"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.w3.org/2001/XMLSchema">
>     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
>     <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
>     <element name="sendSMSToManyRequest">
>         <complexType>
>             <sequence>
>                 <element name="uid" type="xsd:string" />
>                 <element name="pwd" type="xsd:string" />
>                 <element name="phone" type="xsd:string" />
>                 <element name="msg" type="xsd:string" />
>             </sequence>
>         </complexType>
>     </element>
>     <element name="sendSMSToManyResponse">
>         <complexType>
>             <sequence>
>                 <element name="status" type="xsd:string" />
>             </sequence>
>         </complexType>
>     </element>
> </xsd:schema>
>
>
> Also the code that I am using is the same as the one Gunni has written in
> the following link:
> http://forums.sun.com/thread.jspa?threadID=250998&start=15&tstart=0
>
> I have looked on the net for various solutions for teh same, but have not
> yet been able to solve it.
>
> Please please please help.
>
>
> Thanks and Regards,
> --
> Sneha



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope

Posted by Sneha Nikum <sn...@gmail.com>.
Hi All,

Please help me urgently. Also I have tried validating the same SOAP response
against the same schemas with Xerces c++ and it gets validated successfully
without any errors.

Please please help me urgently as this has become a blocker issue for me.

Thanks in advance.
Sneha

On Thu, Jun 25, 2009 at 4:03 PM, Sneha Nikum <sn...@gmail.com> wrote:

> Hi All,
>
> I am totally new to xerces. I am trying to validate a SOAP response against
> its xsd files and am getting the error as
> cvc-elt.1: Cannot find the declaration of element 'SOAP-ENV:Envelope
>
> The Response .xml file is:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
>
> xsi:schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> namespace="urn:sms"
>     >
>     <SOAP-ENV:Body>
>         <ns1:sendSMSToManyResponse xmlns:ns1="urn:SendSMSToMany">
>             <status xsi:type="xsd:string">invalid login</status>
>         </ns1:sendSMSToManyResponse>
>     </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> GenericSchema.xsd
>
> <schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
>     xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:tn="http://schemas.xmlsoap.org/soap/envelope/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>     xmlns="http://www.w3.org/2001/XMLSchema"
>     xmlns:pr1="urn:sms">
>     <xsd:import
> schemaLocation="file://home/sneha/WORK/workspace/WSDLConverter/WSDLSchema.xsd"
> namespace="urn:sms" />
>
>     <element name="Envelope" type="tn:EnvelopeType" />
>     <complexType name="EnvelopeType">
>         <sequence>
>             <element name="Body" type="tn:BodyType" />
>         </sequence>
>     </complexType>
>     <complexType name="BodyType">
>         <choice>
>             <element ref="pr1:sendSMSToManyRequest"/>
>             <element ref="pr1:sendSMSToManyResponse"/>
>     </choice>
>     </complexType>
> </schema>
>
> WSDLSchema.xsd
>
> <xsd:schema targetNamespace="urn:sms"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="
> http://www.w3.org/2001/XMLSchema">
>     <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
>     <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
>     <element name="sendSMSToManyRequest">
>         <complexType>
>             <sequence>
>                 <element name="uid" type="xsd:string" />
>                 <element name="pwd" type="xsd:string" />
>                 <element name="phone" type="xsd:string" />
>                 <element name="msg" type="xsd:string" />
>             </sequence>
>         </complexType>
>     </element>
>     <element name="sendSMSToManyResponse">
>         <complexType>
>             <sequence>
>                 <element name="status" type="xsd:string" />
>             </sequence>
>         </complexType>
>     </element>
> </xsd:schema>
>
>
> Also the code that I am using is the same as the one Gunni has written in
> the following link:
> http://forums.sun.com/thread.jspa?threadID=250998&start=15&tstart=0
>
> I have looked on the net for various solutions for teh same, but have not
> yet been able to solve it.
>
> Please please please help.
>
>
> Thanks and Regards,
> --
> Sneha
>