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 Chandra Talluri <ct...@netnumber.com> on 2002/05/28 22:01:37 UTC

Dynamic XML Validation against schema giving Warning

Hi

I am using xerces 2.0 beta,  JDK 1.3.1

When I do dynamic Schema validation I get the warning

 Warning: org.xml.sax.SAXParseException: SchemaLocation: schemaLocation
value = 'http://localhost/test.xsd' must have even number of URIs


What does it mean. Other than that the code behaves fine

Following is the code snippet

     public static Document validate(InputSource source,String schema)
throws SAXException{           try{
                DOMParser parser = new DOMParser();

parser.setFeature("http://xml.org/sax/features/validation",true);
                parser.setFeature("http://xml.org/sax/features/namespaces",
true);

parser.setFeature("http://apache.org/xml/features/validation/schema",true);

parser.setFeature("http://apache.org/xml/features/validation/dynamic",
true);

parser.setFeature("http://apache.org/xml/features/validation/schema-full-che
cking", true);

parser.setProperty("http://apache.org/xml/properties/schema/external-schemaL
ocation",schema);
                parser.setErrorHandler(new ErrorHandling());

               parser.parse(source);
                Document doc = parser.getDocument();
                Node root = doc.getDocumentElement();
                System.out.println("Document name is:" +
root.getNodeName());
                return doc;
            }
            catch (Exception se){
               System.out.println("Error message: " + se.getMessage());
               se.printStackTrace();
               throw new SAXException(se.getMessage());
            }
}


schema parameter is 'http://localhost/test.xsd'

Any help is appreciated

-Chandra



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


Re: Dynamic XML Validation against schema giving Warning

Posted by Leonardo Holanda <le...@atlantico.com.br>.
Since you're using the attribute "schemaLocation" you have to specify the
appropriate namespace. For example:

<?xml version="1.0" ?>
<MainTag xmlns="http://www.yourcompany.com/namespaces/yournamespace"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.yourcompany.com/namespaces/yournamespace
http://localhost/test.xsd">
</MainTag>

The schemaLocation attribute requires two URIs in its value.
This namespace does not need to be a valid URI. Also, the Schema file does
not need to be specified as a complete URL, e.g. if you are inside a low
band network, it could be interesting to download this Schema and place it
in the same folder your XML file. So you can use:

<?xml version="1.0" ?>
<MainTag xmlns="http://www.yourcompany.com/namespaces/yournamespace"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.yourcompany.com/namespaces/yournamespace
test.xsd">
</MainTag>

best regards,
Leonardo Holanda
Systems Engineer
Insituto Atlântico
Fortaleza - CE - Brazil
http://www.atlantico.com.br/


----- Original Message -----
From: "Chandra Talluri" <ct...@netnumber.com>
To: "Xerces List (E-mail)" <xe...@xml.apache.org>
Sent: Tuesday, May 28, 2002 5:01 PM
Subject: Dynamic XML Validation against schema giving Warning


>  Warning: org.xml.sax.SAXParseException: SchemaLocation: schemaLocation
> value = 'http://localhost/test.xsd' must have even number of URIs

> schema parameter is 'http://localhost/test.xsd'
>
> Any help is appreciated
>
> -Chandra
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


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