resolving external entities

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

resolving external entities

Gunzenreiner Simon
resolving external entities

Hi all

I had the need to resolve external entities (e.g. a DTD/Schema not known to orbeon). I did a "quick fix" that resolves my issue, namely extend the XMLUtils.EntityResolver in line 339 like this:

            // start fix

            URL url = URLFactory.createURL(systemId);

            // resolve http URLs locally if file name of systemId matches

            if (url.getProtocol().startsWith("http")) {

                String file = url.getFile();

                int last = file.lastIndexOf('/');

                file = file.substring(++last);

                URL alt = Thread.currentThread().getContextClassLoader().getResource(file);

                if (alt != null) {

                    logger.debug("Loading " + url.toExternalForm() + " entity from " + alt.toExternalForm());

                    url = alt;

                } else {

                    logger.debug("Loading " + url.toExternalForm() + " from external location.");

                }

            }

            // end fix

This allows a user to provide external entities in the classpath (putting in the classes directory) of orbeon, and having them loaded from there instead of using HTTP.

A more elegant way to achieve this is to use the XML catalog mechanism (http://www.oasis-open.org/committees/entity/spec-2001-08-06.html).

Best regards,

Simon



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: resolving external entities

Hank Ratzesberger-2

Hi Simon,

To avoid any delays, I moved the xhtml entity files to my local server by 
downloading them from the W3C site.  If you don't specify a protocol, OF 
will use the file protocol, or perhaps it is using the "oxf:" protocol.

But I agree it would be nice to configure these, or to specify an entity 
resolver class that does so.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/xhtml1-strict.dtd">

Cheers,
Hank

On Aug 3, 2010, at 10:07 PM, Gunzenreiner Simon wrote:

Hi all


I had the need to resolve external entities (e.g. a DTD/Schema not known to orbeon). I did a "quick fix" that resolves my issue, namely extend the XMLUtils.EntityResolver in line 339 like this:

            // start fix

            URL url = URLFactory.createURL(systemId);

            // resolve http URLs locally if file name of systemId matches

            if (url.getProtocol().startsWith("http")) {

                String file = url.getFile();

                int last = file.lastIndexOf('/');

                file = file.substring(++last);

                URL alt = Thread.currentThread().getContextClassLoader().getResource(file);

                if (alt != null) {

                    logger.debug("Loading " + url.toExternalForm() + " entity from " + alt.toExternalForm());

                    url = alt;

                } else {

                    logger.debug("Loading " + url.toExternalForm() + " from external location.");

                }

            }

            // end fix

This allows a user to provide external entities in the classpath (putting in the classes directory) of orbeon, and having them loaded from there instead of using HTTP.

A more elegant way to achieve this is to use the XML catalog mechanism (http://www.oasis-open.org/committees/entity/spec-2001-08-06.html).

Best regards,

Simon



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

Hank Ratzesberger
NEES@UCSB
Earth Research Institute
University of California, Santa Barbara
805-893-8042








--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws