xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Des Rosiers" <d...@desropolis.com>
Subject RE: EntityResolver for XSD
Date Wed, 20 Nov 2002 18:36:20 GMT
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: 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


Mime
View raw message