You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jeremiah Johnson <Je...@commerce.com> on 2001/03/12 19:39:18 UTC

Q Xalan 1: parser liaison

This is the only list I found reference to in the overview and release
notes, so I apologize if it is the wrong place.

I don't appear to be using the XMLParserLiaison feature correctly.  First,
the reason that I think I need to use the parser liaison is because I need
to run an xCBL document through XSLT.  Here is a sample DOCTYPE from xCBL:
<!DOCTYPE PurchaseOrder SYSTEM "CBL.dtd">
That SYSTEM ID gets converted to file:///sites/weblogic/CBL.dtd (I assume
because my JVM started from /sites/weblogic).  I don't know how to control
what the system id is converted to, so for normal parsing, I just set the
entity resolver to ignore everything up to and including the last /; then
the code in my resolveEntity reads the DTD from the system classpath.

I can set the entity resolver easily with regular parsing, but with XSLT
involved I am missing something.  Based on the source code for
org.apache.xalan.xslt.Process, I tried setting a liaison and the set the
entity resolver of that liaison.  I used the liaison in the
XSLTProcessorFactory.getProcessor call.

I have tried a lot of code variations, but I always get the following error:

org.apache.xalan.xslt.XSLProcessorException: File
"file:///sites/weblogic/CBL.dtd" not found.

It really seems to me that anything I do with the liaison is ignored.

Here is the latest code that I tested (try catch blocks removed...):

--- from my transform method ---
Class parserLiaisonClass = Class.forName(
"org.apache.xalan.xpath.dtm.DTMLiaison" );
java.lang.reflect.Constructor parserLiaisonCtor =
parserLiaisonClass.getConstructor( null );
XMLParserLiaison xmlParserLiaison
   = (XMLParserLiaison) parserLiaisonCtor.newInstance( null );
// XMLParserLiaison xmlParserLiaison = new XercesLiaison();
processor = XSLTProcessorFactory.getProcessor( xmlParserLiaison );
xmlParserLiaison.setEntityResolver( new MyHandlerBase() );
xmlParserLiaison.setUseValidation( false );

stylesheetSource = new XSLTInputSource(is);
xslRoot = processor.processStylesheet(stylesheetSource);

inputSource = new XSLTInputSource(xmlInputStream);
outputSource = new XSLTResultTarget();
xslRoot.process(inputSource, outputSource);

--- from the MyHandlerBase ---
public class MyHandlerBase extends HandlerBase {
   public InputSource resolveEntity( String publicId, String systemId )
      throws SAXException
   {
      if( (systemId != null) && (systemId.startsWith("file:")) ) {
      systemId = systemId.substring( systemId.lastIndexOf("/") + 1 );
...

I am using a HandlerBase rather than EntityResolver because I already had
the HandlerBase done for regular parsing.  If you think that is causing
problem, please let me know that I am will make a separate EntityResolver.
I don't think that it is affecting my problem.

Thanks for any help you can provide.

- jeremiah