Michael,

thank you very much. Problem solved setting the property
correctly:      portletParser.setProperty(
"http://apache.org/xml/properties/schema/external-schemaLocation";,
"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd " +
new File("portlet.xsd").toURL().toExternalForm() +    
" http://www.w3.org/XML/1998/namespace " +
new File("xml.xsd").toURL().toExternalForm());

The last namespace is necessary because of the import statement inside
the portlet.xsd schema.

Once again
Thank you very much,

Vitor

On 3/19/07, Michael Glavassevich <[EMAIL PROTECTED]> wrote:
Hi Vitor,

The external schema location properties have the same definitions as the
ones defined in the schema spec [1]. The value of external-schemaLocation
is a list of pairs of URIs, where the first of each pair is a target
namespace and the second of each pair is a schema location hint. You've
only specified the schemaLocation. It needs to be preceded by a target
namespace (i.e. http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd).

Thanks.

[1] http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#schema-loc

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

"Vitor Carreira" <[EMAIL PROTECTED]> wrote on 03/19/2007 09:33:02
AM:

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


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