Doug
I don't know if this is any help, but you can tell your DOMParser where to
find your schema by setting the following before you parse your document:
setFeature("http://xml.org/sax/features/validation", true);
setFeature("http://apache.org/xml/features/validation/schema", true);
setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSch
emaLocation", "my.xsd");
If you have already loaded your schema into a DOM (and so don't want to
provide a location) you can create an EntityResolver and add it via
setEntityResolver. Then when it needs the schema the DOMParser will call
your EntityResolver's resolveEntity method. You can then provide the schema
from its DOM, or wherever you want.
regards
Mark Lines-Davies
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 06 May 2002 19:40
To: [EMAIL PROTECTED]
Subject: Basic Schema Validation..HELP!
I am converting a webservice from a MS COM+ based application to Java. Out
public interface(s) methods are all defined with an argument of String.
That String is (or should be) a valid XML document. What I want to do is
load this string into a DOM document (or SAX could be fine) and validate it
against a given Schema document....However my incoming document (string)
does NOT have the xsi:location attribute...What I want to do is decide at
RUN time which Schema to validate this "document" against....load the
schema, load the document and call some method to say "validate this
document against this schema"....Does such a thing exist?
thanks
Doug
example of xml document
<?xml version="1.0" encoding="UTF-8" ?>
<request xmlns="mesapi/schemas/version1.0/getsomedata" server="s" database
="d">
� <facility_code>BF</facility_code>
� <id_nbr>32100000999</id_nbr>
� </request>
Schema document...
<?xml version="1.0" ?>
- <xsd:schema targetNamespace="mesapi/schemas/version1.0/getsomedata"
elementFormDefault="qualified" xmlns:src="
mesapi/schemas/version1.0/getsomedata" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
� <xsd:element name="request" type="src:requesttype" />
- <xsd:attributeGroup name="connections">
� <xsd:attribute name="server" type="xsd:string" use="required" />
� <xsd:attribute name="database" type="xsd:string" use="required"
/>
� </xsd:attributeGroup>
- <xsd:complexType name="requesttype">
- <xsd:sequence>
- <xsd:element name="facility_code">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
� <xsd:maxLength value="8" />
� </xsd:restriction>
� </xsd:simpleType>
� </xsd:element>
- <xsd:element name="id_nbr">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
� <xsd:maxLength value="11" />
� </xsd:restriction>
� </xsd:simpleType>
� </xsd:element>
� </xsd:sequence>
� <xsd:attributeGroup ref="src:connections" />
� </xsd:complexType>
� </xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
*************************************************************************
The information contained in this message or any of its
attachments may be privileged and confidential and intended
for the exclusive use of the addressee. If you are not the
addressee any disclosure, reproduction, distribution or other
dissemination or use of this communication is strictly prohibited
*************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]