> I am using xerces 1_4_3 and I am unable to validate my instance
> document.
> I get the following errors.  I tried setting
> xsi:noNamespaceSchemaLocation

        according to ur files below, u are using noNameSpaceSchemaLocation 
attribute but in ur schema file schema component are under the namespace, as 
given by 'targetNamespace' attribute. In that case, 'schemaLocation' attribte 
should be used to refer to schema file, i have modified ur file for the same.
Refer to URL,
        http://www.w3.org/TR/xmlschema-1/#xsi_schemaLocation
for details on the use of these attributes.


Modified XML:-
<?xml version="1.0"?>
<record xmlns="http://eva.com/eng/test";
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://eva.com/eng/test validate.xsd">
        <recordName>Some Name</recordName>
        <comment>Some Comment</comment>
</record>

Modified XSD:

<schema xmlns="http://www.w3.org/2001/XMLSchema";
        xmlns:test="http://eva.com/eng/test";
        targetNamespace="http://eva.com/eng/test";
        elementFormDefault="qualified"
        attributeFormDefault="unqualified">

        <element name="record" type="test:RecordType"/>
        <complexType name="RecordType">
                <sequence>
                        <element name="recordName" type="string"/>
                        <element name="comment" type="string"/>
                </sequence>
        </complexType>
        
</schema>

hope that helps,


Neeraj Bajaj
Sun Microsystems, inc.

        
> ====error messages=====
> Error: URI=file:D:/dev/bmsrc/packages/validate.xml Line=2: Element type
> "record" must be declared.
> Error: URI=file:D:/dev/bmsrc/packages/validate.xml Line=3: Element type
> "recordName" must be declared.
> Error: URI=file:D:/dev/bmsrc/packages/validate.xml Line=4: Element type
> "comment" must be declared.
> 
> ====validate.xsd===
> <schema xmlns="http://www.w3.org/2001/XMLSchema";
>         xmlns:test="http://eva.com/eng/test";
>         targetNamespace="http://eva.com/eng/test";
>         elementFormDefault="qualified"
>         attributeFormDefault="unqualified">
> 
>         <element name="record" type="test:RecordType">
>         <complexType name="RecordType">
>                 <element name="recordName" type="string">
>                 <element name="comment" type="string">
>         </complexType>
> <schema>
> 
> ====validate.xml=====
> <?xml version="1.0"?>
> <record xmlns="http://eva.com/eng/test";>
>         <recordName>Some Name</recordName>
>         <comment>Some Comment</comment>
> </record>
> 
> ====validate1.xml=====
> <?xml version="1.0"?>
> <record xmlns="http://eva.com/eng/test";
> xsi:noNamespaceSchemaLocation="validate.xsd">
>         <recordName>Some Name</recordName>
>         <comment>Some Comment</comment>
> </record>
> 
> =====Validate.java====
> package com.bluemartini.test.xml;
> 
> import java.io.*;
> 
> import org.w3c.dom.*;
> import org.xml.sax.SAXParseException;
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.ParserConfigurationException;
> 
> /*
> * Sample test case
> * Takes in an XML document and validates it via DOM
> *
> */
> 
> public class Validate
> {
>         public static void main(String[] argv)
>     {
>         try {
>             DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
>             factory.setNamespaceAware(true);
>             factory.setValidating(true);
>             DocumentBuilder builder = factory.newDocumentBuilder();
>             File temp = new File("validate.xml");
>             Document doc = builder.parse(temp);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to