You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Dean Des Rosiers <de...@desropolis.com> on 2002/11/20 19:36:58 UTC
FW: EntityResolver for XSD - plain text
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