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 Gottfried Szing <go...@szing.at> on 2002/04/11 21:51:22 UTC

entityresolver for external schemas

hi

my problem is to resolve external schema locations. this means
to load a schema which is located at e.g.
"http://test.at/test1.xsd".

my first attempt was to use the xerces properties (or features?)
for external schema locations. but without success. not a
technical problem, just a origanisational problem :((

so my question: is it a correct approach to use the entity
resolver to load schemas? and if yes, is a schema a publid id or
a system id?

TIA, goofy


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: entityresolver for external schemas

Posted by go...@szing.at.
On Fri, 12 Apr 2002, Doug Helton wrote:

> Hi,
>
> First you need to create the entity resolver it will call
> this class with the systemId for either case as long as the
> schema name is in the xml file. Here is a sample entity
> resolver:

[ cutted resolver code ]

> the resolveEntity method is where you would form the path to
> you schema and create an input source out of this path.  You
> do not call this method the parser will.

this is what i thought. and it seems to me that writing my own
entityresolver is a correct approach.

thanks for the info,
goofy


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: entityresolver for external schemas

Posted by Doug Helton <dh...@ideorlando.org>.
Hi,

	First you need to create the entity resolver it will call this class with
the systemId for either case as long as the schema name is in the xml file.
Here is a sample entity resolver:

public class SchemaResolver implements EntityResolver {

     /**
     * Constructor that sets the location of the dif folder associated with
     * this entity resolver
     * @param repos -- location of the "DIF" folder
     */

    SchemaResolver(String repos) {
        this.difDirectory = repos;
    }

    /**
     * Parser calls this method with the systemId, if it is dealing with a
DTD
     * it calls the parser with the fully quantified path where it thinks
the
     * dtd should be, when dealing with an XML Schema, it passes just the
     * schema name.  The systemId is then redirected to the appropriate
     * DIF folder.
     * @param publicId -- public ID of XML file
     * @param systemId -- system ID of the XML file
     * @return InputSource containing the location of the schema
     */
    public InputSource resolveEntity(String publicId, String systemId) {
        String temp = null;

        if (systemId.endsWith("dtd")) {
            temp = systemId.substring(systemId.lastIndexOf("/") + 1);
        }
        else {
            temp = systemId;
        }

        return new InputSource(difDirectory + temp);

    }
}

the resolveEntity method is where you would form the path to you schema and
create an input source out of this path.  You do not call this method the
parser will.

Then all you have to do is on your parse set the entity resolver to this
classlike this:

SchemaResolver resolver = new SchemaResolver(systemID)
this.parser.setEntityResolver(resolver);

Doug Helton

-----Original Message-----
From: Gottfried Szing [mailto:gottfried@szing.at]
Sent: Thursday, April 11, 2002 3:51 PM
To: xerces-j-user@xml.apache.org
Subject: entityresolver for external schemas



hi

my problem is to resolve external schema locations. this means
to load a schema which is located at e.g.
"http://test.at/test1.xsd".

my first attempt was to use the xerces properties (or features?)
for external schema locations. but without success. not a
technical problem, just a origanisational problem :((

so my question: is it a correct approach to use the entity
resolver to load schemas? and if yes, is a schema a publid id or
a system id?

TIA, goofy


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