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 Scott Carter <sc...@dotsconnect.com> on 2001/01/17 15:32:05 UTC

problem with Unix versus Windows paths

Does anyone know how to reference a relative path to an external dtd in a
way that is non-platform specific.  Right now, I am referencing as follows:

<!DOCTYPE MaintenanceRequest SYSTEM "xml_engine\dtd\MaintenanceRequest.dtd">

which doesn't work when I try to parse the document on a Unix machine.  Any
suggestions would be helpful......

Scott Carter


RE: problem with Unix versus Windows paths

Posted by Mark Diekhans <ma...@lutris.com>.
We use the Xerces XCatalog facility to accomplish this.  See:

   org/apache/xerces/readers/xcatalog.dtd

Brad O'Hearne <ca...@megapathdsl.net> writes:
> I guess I have a similar question associated with this.  I am receiving XML
> files from an external source (a business partner) and I would like them to
> only reference the dtd itself -- no path, either relative or absolute.
> However, I would like to get the dtd name out of the XML file and prepend a
> path to it, and then validate based on that.  Can this be done?  I very much
> prefer not requiring partners to have to accommodate our internal directory
> structure.

RE: problem with Unix versus Windows paths

Posted by Brad O'Hearne <ca...@megapathdsl.net>.
Thanks!  I attached another response I received with another idea...would
anyone care to comment on which idea might be better -- does it not matter,
or are there advantages/disadvantages for doing each?

Brad

-----Original Message-----
From: Ian Roberts [mailto:irr@decisionsoft.com]
Sent: Wednesday, January 17, 2001 9:11 AM
To: xerces-j-dev@xml.apache.org
Subject: RE: problem with Unix versus Windows paths


On Wed, 17 Jan 2001, Brad O'Hearne wrote:

> I guess I have a similar question associated with this.  I am receiving
XML
> files from an external source (a business partner) and I would like them
to
> only reference the dtd itself -- no path, either relative or absolute.
> However, I would like to get the dtd name out of the XML file and prepend
a
> path to it, and then validate based on that.  Can this be done?  I very
much
> prefer not requiring partners to have to accommodate our internal
directory
> structure.

You can do this with the EntityResolver method.  If you have the XML
files have a DOCTYPE like:

<!DOCTYPE MaintainanceRequest SYSTEM "MaintainanceRequest.dtd">

and set up your custom EntityResolver to map a request for the System ID
"MaintainanceRequest.dtd" to the real file in the correct directory.

Hope this makes sense,

Ian

--
Ian Roberts                     | irr@decisionsoft.com
DecisionSoft Ltd.               | http://www.decisionsoft.com/




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

RE: problem with Unix versus Windows paths

Posted by Ian Roberts <ir...@decisionsoft.com>.
On Wed, 17 Jan 2001, Brad O'Hearne wrote:

> I guess I have a similar question associated with this.  I am receiving XML
> files from an external source (a business partner) and I would like them to
> only reference the dtd itself -- no path, either relative or absolute.
> However, I would like to get the dtd name out of the XML file and prepend a
> path to it, and then validate based on that.  Can this be done?  I very much
> prefer not requiring partners to have to accommodate our internal directory
> structure.

You can do this with the EntityResolver method.  If you have the XML
files have a DOCTYPE like:

<!DOCTYPE MaintainanceRequest SYSTEM "MaintainanceRequest.dtd">

and set up your custom EntityResolver to map a request for the System ID
"MaintainanceRequest.dtd" to the real file in the correct directory.

Hope this makes sense,

Ian

-- 
Ian Roberts                     | irr@decisionsoft.com
DecisionSoft Ltd.               | http://www.decisionsoft.com/




RE: problem with Unix versus Windows paths

Posted by Brad O'Hearne <ca...@megapathdsl.net>.
I guess I have a similar question associated with this.  I am receiving XML
files from an external source (a business partner) and I would like them to
only reference the dtd itself -- no path, either relative or absolute.
However, I would like to get the dtd name out of the XML file and prepend a
path to it, and then validate based on that.  Can this be done?  I very much
prefer not requiring partners to have to accommodate our internal directory
structure.

-----Original Message-----
From: Milind Gadre [mailto:milind@ecplatforms.com]
Sent: Wednesday, January 17, 2001 9:01 AM
To: xerces-j-dev@xml.apache.org
Subject: Re: problem with Unix versus Windows paths


Scott, you may need to associate an EntityResolver with the parser. This
would evaluate the systemId and return an appropriate InputStream.


> Does anyone know how to reference a relative path to an external dtd
in a
> way that is non-platform specific.  Right now, I am referencing as
follows:
>
> <!DOCTYPE MaintenanceRequest SYSTEM
"xml_engine\dtd\MaintenanceRequest.dtd">
>
> which doesn't work when I try to parse the document on a Unix machine.
Any
> suggestions would be helpful......
>
> Scott Carter
>

In this specific case, I think you should use the Unix style
forward-slashes for the path separators. The default entity resolver
will simply convert it to a "file:" url and call openStream on it. The
java.io.File class converts between "/" and "\" as appropriate.

Regards...

Milind Gadre
ecPlatforms, Inc
901 Mariner's Island Blvd, Suite 565
San Mateo, CA 94404
C: 510-919-0596
F: 815-352-0779
milind@ecplatforms.com



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


Re: problem with Unix versus Windows paths

Posted by Milind Gadre <mi...@ecplatforms.com>.
Scott, you may need to associate an EntityResolver with the parser. This
would evaluate the systemId and return an appropriate InputStream.


> Does anyone know how to reference a relative path to an external dtd
in a
> way that is non-platform specific.  Right now, I am referencing as
follows:
>
> <!DOCTYPE MaintenanceRequest SYSTEM
"xml_engine\dtd\MaintenanceRequest.dtd">
>
> which doesn't work when I try to parse the document on a Unix machine.
Any
> suggestions would be helpful......
>
> Scott Carter
>

In this specific case, I think you should use the Unix style
forward-slashes for the path separators. The default entity resolver
will simply convert it to a "file:" url and call openStream on it. The
java.io.File class converts between "/" and "\" as appropriate.

Regards...

Milind Gadre
ecPlatforms, Inc
901 Mariner's Island Blvd, Suite 565
San Mateo, CA 94404
C: 510-919-0596
F: 815-352-0779
milind@ecplatforms.com