You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by robert sanford <rs...@nolimitsystems.com> on 2000/08/16 20:29:28 UTC

relative path for validation?

i have clients that are submitting documents to a server. both are using the
same schema. i don't want to use an absolute path
(file:///e:/development/classpath/fc.xsd) to specify the schema location
because i have no idea where the client will install my software (the server
responds with documents the client is expected to validate) and i have no
idea where my production people are going to be installing the schema on the
server side. i would like to simply specify the schema name (fc.xsd) and
have both the client and the filing center "know" where the schema is
located.

how can i do this with xerces?

right now my solution is to have a properties file that my application reads
from and prepends the path to the schema in front of the schema name. it
seems to work but is, in my opinion, sub-optimal.

what i would really like is a property of the parser that i can set to tell
it where to look for schema files so that if the schema isn't initially
found it will search one or more other directories to try and find it.

thanks,

rjsjr

ps - this will need to work with the c++ version of xerces as well since my
client uses that.


Re: relative path for validation?

Posted by Eric Ye <er...@locus.apache.org>.
relative to the where the XML document is located.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "robert sanford" <rs...@nolimitsystems.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, August 16, 2000 1:00 PM
Subject: Re: relative path for validation?


> and what is that relative to on both sides?
>
> in c++ is it relative to where xerces.dll resides? where the application
was
> launched?
>
> what about in java? is it relative to the application's .jar file or
xerces'
> .jar file? or to the system directory?
>
> rjsjr
>
> ----- Original Message -----
> From: "Eric Ye" <er...@locus.apache.org>
> To: <xe...@xml.apache.org>; "robert sanford"
> <rs...@nolimitsystems.com>
> Sent: Wednesday, August 16, 2000 2:49 PM
> Subject: Re: relative path for validation?
>
>
> > You can use relative path , e.g. "abc/fc.xsd" in the schemaLocation or
> > noTargetNamespaceLocation.
> > _____
> >
> >
> > Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
> >
> > ----- Original Message -----
> > From: "robert sanford" <rs...@nolimitsystems.com>
> > To: <xe...@xml.apache.org>
> > Sent: Wednesday, August 16, 2000 11:29 AM
> > Subject: relative path for validation?
> >
> >
> > > i have clients that are submitting documents to a server. both are
using
> > the
> > > same schema. i don't want to use an absolute path
> > > (file:///e:/development/classpath/fc.xsd) to specify the schema
location
> > > because i have no idea where the client will install my software (the
> > server
> > > responds with documents the client is expected to validate) and i have
> no
> > > idea where my production people are going to be installing the schema
on
> > the
> > > server side. i would like to simply specify the schema name (fc.xsd)
and
> > > have both the client and the filing center "know" where the schema is
> > > located.
> > >
> > > how can i do this with xerces?
> > >
> > > right now my solution is to have a properties file that my application
> > reads
> > > from and prepends the path to the schema in front of the schema name.
it
> > > seems to work but is, in my opinion, sub-optimal.
> > >
> > > what i would really like is a property of the parser that i can set to
> > tell
> > > it where to look for schema files so that if the schema isn't
initially
> > > found it will search one or more other directories to try and find it.
> > >
> > > thanks,
> > >
> > > rjsjr
> > >
> > > ps - this will need to work with the c++ version of xerces as well
since
> > my
> > > client uses that.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> > >
> > >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>


Re: relative path for validation?

Posted by robert sanford <rs...@nolimitsystems.com>.
and what is that relative to on both sides?

in c++ is it relative to where xerces.dll resides? where the application was
launched?

what about in java? is it relative to the application's .jar file or xerces'
.jar file? or to the system directory?

rjsjr

----- Original Message -----
From: "Eric Ye" <er...@locus.apache.org>
To: <xe...@xml.apache.org>; "robert sanford"
<rs...@nolimitsystems.com>
Sent: Wednesday, August 16, 2000 2:49 PM
Subject: Re: relative path for validation?


> You can use relative path , e.g. "abc/fc.xsd" in the schemaLocation or
> noTargetNamespaceLocation.
> _____
>
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: "robert sanford" <rs...@nolimitsystems.com>
> To: <xe...@xml.apache.org>
> Sent: Wednesday, August 16, 2000 11:29 AM
> Subject: relative path for validation?
>
>
> > i have clients that are submitting documents to a server. both are using
> the
> > same schema. i don't want to use an absolute path
> > (file:///e:/development/classpath/fc.xsd) to specify the schema location
> > because i have no idea where the client will install my software (the
> server
> > responds with documents the client is expected to validate) and i have
no
> > idea where my production people are going to be installing the schema on
> the
> > server side. i would like to simply specify the schema name (fc.xsd) and
> > have both the client and the filing center "know" where the schema is
> > located.
> >
> > how can i do this with xerces?
> >
> > right now my solution is to have a properties file that my application
> reads
> > from and prepends the path to the schema in front of the schema name. it
> > seems to work but is, in my opinion, sub-optimal.
> >
> > what i would really like is a property of the parser that i can set to
> tell
> > it where to look for schema files so that if the schema isn't initially
> > found it will search one or more other directories to try and find it.
> >
> > thanks,
> >
> > rjsjr
> >
> > ps - this will need to work with the c++ version of xerces as well since
> my
> > client uses that.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>


Re: relative path for validation?

Posted by Eric Ye <er...@locus.apache.org>.
You can use relative path , e.g. "abc/fc.xsd" in the schemaLocation or
noTargetNamespaceLocation.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "robert sanford" <rs...@nolimitsystems.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, August 16, 2000 11:29 AM
Subject: relative path for validation?


> i have clients that are submitting documents to a server. both are using
the
> same schema. i don't want to use an absolute path
> (file:///e:/development/classpath/fc.xsd) to specify the schema location
> because i have no idea where the client will install my software (the
server
> responds with documents the client is expected to validate) and i have no
> idea where my production people are going to be installing the schema on
the
> server side. i would like to simply specify the schema name (fc.xsd) and
> have both the client and the filing center "know" where the schema is
> located.
>
> how can i do this with xerces?
>
> right now my solution is to have a properties file that my application
reads
> from and prepends the path to the schema in front of the schema name. it
> seems to work but is, in my opinion, sub-optimal.
>
> what i would really like is a property of the parser that i can set to
tell
> it where to look for schema files so that if the schema isn't initially
> found it will search one or more other directories to try and find it.
>
> thanks,
>
> rjsjr
>
> ps - this will need to work with the c++ version of xerces as well since
my
> client uses that.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>


Re: relative path for validation?

Posted by Werner Guttmann <We...@msdw.com>.
Andy,

thanks for the reply. I guess I should have been slightly more specific
with my questions. Using the EntityResolver interface itself is not the
problem. It's more about how the InputSource returned from the
resolveEntity() method needs to be setup.

Last Friday, I tried to use the XMLCatalogHandler class in order to
replace "http://www.msdw.com/DTD/2000/foo" style SYSTEM ids with
references to a locally stored file. After reading the documentation of
both the EntityResolver interface as well as the XMLCatalogHandler class,
I assumed that it would be enough to use the XMLCatalogHandler class in
the following way to register such a mapping.

catalog.addSystemMapping("http://www.msdw.com/DTD/2000/marginparams.dtd",

"file:///c|/download/marginparams.dtd");

Looking at the source code of XMLCatalogHandler, resolveEntity() creates
an InputSource from the second parameter to the above addSystemMapping()
call, i.e. it returns more or less new InputSource
("file:///c|/download/marginparams.dtd"). Given my understanding of
InputSource, it should be possible to create a BtyeStream to this URL
using URL.getByteStream() ? Unfortunately (as mentioned in my original
email), Xerces doesn't use the InputSource as returned by resolveEntity()
but uses the original SYSTEM id portion of the DOCTYPE definition.

With regards to the InputSource returned from resolveEntity(), would it
be enough to just create the InputSource from the String identifier, or
am I responsible to create the Stream as well (which I thought would only
be required if there' something special about the stream) ?

Thanks for your help.

Regards
Werner Guttmann




Andy Clark wrote:

> Werner Guttmann wrote:
> > what would be the best way to educate yourself here, i.e. what's
> > the best document(s) one should start to read with regards to
> > EntityResolvers et alias ?
>
> We don't have a specific example of an EntityResolver being used
> in the samples. However, it's pretty straightforward from reading
> the SAX/SAX2 javadoc. There is an interface called EntityResolver
> and both parsers have a method called "setEntityResolver" that is
> used to register the resolver.
>
> You can either read the SAX javadoc or check out David Megginson's
> web site for SAX: http://www.megginson.com/SAX/
>
> --
> Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: relative path for validation?

Posted by Andy Clark <an...@apache.org>.
Werner Guttmann wrote:
> what would be the best way to educate yourself here, i.e. what's 
> the best document(s) one should start to read with regards to 
> EntityResolvers et alias ?

We don't have a specific example of an EntityResolver being used
in the samples. However, it's pretty straightforward from reading
the SAX/SAX2 javadoc. There is an interface called EntityResolver
and both parsers have a method called "setEntityResolver" that is
used to register the resolver.

You can either read the SAX javadoc or check out David Megginson's
web site for SAX: http://www.megginson.com/SAX/

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org

Re: relative path for validation?

Posted by Werner Guttmann <We...@msdw.com>.
Andy,

what would be the best way to educate yourself here, i.e. what's the best
document(s) one should start to read with regards to EntityResolvers et
alias ?

Regards
Werner Guttmann

Andy Clark wrote:

> robert sanford wrote:
> > how can i do this with xerces?
>
> Look into using an EntityResolver in your application with a
> configurable catalog file that knows how to resolve your schema
> grammars to a local copy.
>
> --
> Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: relative path for validation?

Posted by Andy Clark <an...@apache.org>.
robert sanford wrote:
> how can i do this with xerces?

Look into using an EntityResolver in your application with a
configurable catalog file that knows how to resolve your schema
grammars to a local copy.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org