Hi,

I'm trying to validate a XML document against a copy of an external schema.

The XML document, called portlet.xml start with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app
        xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";
        version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";>


I've download the schema from
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd and stored in a
file called portlet.xsd.

The code for my spike is the following:

DOMParser portletParser = new DOMParser();
portletParser.setFeature("http://xml.org/sax/features/validation";, true);
portletParser.setFeature("http://apache.org/xml/features/validation/schema";,
true);
        
String portletXSDLocation = new File("portlet.xml").toURL().toExternalForm();
portletParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation";,
portletXSDLocation);
portletParser.setErrorHandler(myErrorHandler);

InputSource source = new InputSource(new FileInputStream("portlet.xml"));       
              
parser.parse(source);

The code above doesn't work as expected. If I'm behind a firewall the
DOMParser doesn't use the XSD local copy and always tries to fetch the
xsd from http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd.

Any ideas how to validate a XML document using a local copy of an
external schema?

Thanks,

VĂ­tor

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

Reply via email to