Hi,
  Thanks for your response. I could get some information from your reply.
But I need few clarification. I have to validate the attched XML against the
attached XSD. The XML file come to the validator through some other
application. The incoming XML look like the attached one. It does not have
xsi:schemaLocation = . But, some other means, I know that the incoming XML
has to be validated against the remote XSD. (attached for reference). As
your suggested I attached the entity resolver with the XMLReader. When I run
the program the following error is appearing.

Error: General Schema Error: Grammar with uri:
http://www.tibco.com/xmlns/ae2xsd/2002/05/ae/test/display , can not be
found; schema namespace may be wrong:  Xerces supports schemas from the
"http://www.w3.org/2001/XMLSchema"; namespace or the instance document's
namespace may not match the targetNamespace of the schema.

The interesting part is entity resolver is not at all called to load the
schema.

If I add the xsi:schemaLocation in the XML, it works fine. It calls the
entity resolver to resolve the schema. But my requirement is to validation
with out xsi;schemaLocation.

Could you please suggest anything...???

Cheers
Kumaravel


----- Original Message -----
From: "Dean Des Rosiers" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 21, 2002 12:06 AM
Subject: RE: EntityResolver for XSD


> I've implemented a very simple EntityResolver.  It pulls the xsd from an
> EntityBean, if you can imagine such a thing!  It's possible that this code
> is no good or even dangerous.  I'll leave it to the better minds on this
> list to determine that.  I contribute this code because I've gotten a lot
of
> info from this list and I'd like to "give back."
>
> Here's the code...
>
> public class DataSetSchemaResolver implements EntityResolver
> {
>   public InputSource resolveEntity(String publicId, String systemId)
>     throws SAXException, IOException
>   {
>     try
>     {
>       String descriptiveId = systemId;
>       int dotLoc = systemId.indexOf('.');
>       if (dotLoc > -1)
>         descriptiveId = systemId.substring(0, systemId.indexOf('.'));
>
>       DataSetSchemaLocal schema =
>
(DataSetSchemaLocal)getSchemaHome().findByDescriptiveIdLatest(descriptiveId)
> ;
>       if (schema != null)
>       {
>         InputSource inputSource = new InputSource(new
> StringReader(schema.getXmlText()));
>         inputSource.setPublicId(publicId);
>         inputSource.setSystemId(systemId);
>         return inputSource;
>       }
>       else
>       {
>         throw new SAXException("Couldn't find " + systemId);
>       }
>     }
>     catch (Exception e)
>     {
>       throw new SAXException(e);
>     }
>
>   }
>
>
> Hope this helps.
> Dean
>
> Hi,
>   Can any one give some information about EntityResolver to load the XSD
> from some where else. Any reference or code samples...??
>
> Cheers
> Kumar
>
>
> ---------------------------------------------------------------------
> 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]
>
<?xml version = "1.0" encoding = "UTF-8"?>
<ns:inputclass xsi:type = "ns:inputclass"  xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance";  xmlns:ae = "http://www.tibco.com/xmlns/ae2xsd/2002/05";  xmlns:ns = "http://www.tibco.com/xmlns/ae2xsd/2002/05/ae/test/display";>
<firstName>Corba</firstName>
<lastName>Adapter</lastName>
</ns:inputclass>
<ns2:schema xmlns:ns1 = "http://www.tibco.com/xmlns/ae2xsd/2002/05"; xmlns:ae = "http://www.tibco.com/xmlns/ae2xsd/2002/05"; xmlns:ns2 = "http://www.w3.org/2001/XMLSchema"; xmlns:ns3 = "http://www.tibco.com/xmlns/ae2xsd/2002/05/ae/test/display"; ae:directory = "/tibco/public/class/ae/test/display" elementFormDefault = "unqualified" attributeFormDefault = "unqualified" targetNamespace = "http://www.tibco.com/xmlns/ae2xsd/2002/05/ae/test/display";>
	<ns2:import namespace = "http://www.tibco.com/xmlns/ae2xsd/2002/05"; schemaLocation = "xslt/xsd/AE2XSD.xsd"/>

	<ns2:complexType ae:directory = "/tibco/public/class/ae/test/display" name = "inputclass">
		<ns2:sequence>
			<ns2:element ae:readable = "true" ae:writeable = "true" ae:key = "false" minOccurs = "0" name = "firstName" nillable = "true" type = "ae:string"/>
			<ns2:element ae:readable = "true" ae:writeable = "true" ae:key = "false" minOccurs = "0" name = "lastName" nillable = "true" type = "ae:string"/>
		</ns2:sequence>
	</ns2:complexType>
	<ns2:complexType ae:directory = "/tibco/public/class/ae/test/display" name = "outputclass">
		<ns2:sequence>
			<ns2:element ae:readable = "true" ae:writeable = "true" ae:key = "false" minOccurs = "0" name = "firstName" nillable = "true" type = "ae:string"/>
			<ns2:element ae:readable = "true" ae:writeable = "true" ae:key = "false" minOccurs = "0" name = "lastName" nillable = "true" type = "ae:string"/>
		</ns2:sequence>
	</ns2:complexType>
	<ns2:element name = "inputclass" type = "ns3:inputclass"/>
	<ns2:element name = "outputclass" type = "ns3:outputclass"/>
</ns2:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to