You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Dylan Parker <dy...@mindstech.com> on 2001/03/14 19:10:29 UTC

HELP! WAR files, EntityResolvers, xsl:include, and me!

Hello, all.

I asked this question in a petering off thread two days ago... and I
know how _I_ am about reading old boring threads ;) so here goes
again.

I _originally_ asked if there was a workaround to allow xalan-j to
read xsl files at runtime from an xsl:include tag, when the target xsl
file to be read resides inside of a WAR file.

So, to get the root xsl file read and parsed I can do.. since I am
creating the InputSource... but the code to handle xsl:include's I
can't intercept.... or so I thought.

Joseph Kesselman politely nodded his head in the direction of
entityResolvers and implied that I could write my own and use it to
parse the WAR files.

Very cool. But how?

The documentation around the method setEntityResolver implies that by
calling it you can add (or 'register') your resolver with the other
resolvers currently registered... But in the Xalan code,
StylesheetHandler.java to be specific -- which implements
EntityResolver, the code the uses setEntityResolver appears to treat
it like there can only be a single resolver at any one time...

Which is it?

In the documentation they have the following class :


 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;

 public class MyResolver implements EntityResolver {
   public InputSource resolveEntity (String publicId, String systemId)
   {
     if (systemId.equals("http://www.myhost.com/today")) {
              // return a special input source
       MyReader reader = new MyReader();
       return new InputSource(reader);
     } else {
              // use the default behaviour
       return null;
     }
   }
 }


 And the 'null' with the comment "use the default behaviour" implies
 that a series of resolvers are being tried...

 If I implement a class similar to the above that can handle reading
 from WAR files... how exactly can I make the bridge between Xalan and
 Xerces aware of it? The exact point I NEED the custom resolver is
 when Xalan comes across an xsl:include statement and must retrieve
 the file from inside of a WAR file...

 Can one register their EntityResolver in a queue of other
 EntityResolvers? So that each is tried in turn and the default
 behaviour used only when all 'registered' resolvers return null?

 If so... How exactly?
 If not... what do people suggest? What have other people done?
 
 Any help appreciated!

 Dylan Parker