commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 17618] - [jelly] Bug in ImportTag as child of TransformTag
Date Thu, 13 Mar 2003 15:52:45 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17618>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17618

[jelly] Bug in ImportTag as child of TransformTag





------- Additional Comments From vb@bigdot.de  2003-03-13 15:52 -------
After some investigation I found the following:

The root cause of this exception is an ArrayIndexOutOfBoundsException in
xalan. (Unfortunately you can not see this root exception in the stacktrace.
I had to use the debugger...)

My first guess was that is due to inproper setup of the 
TransformContentHandler. This is right because the nested import tag does
not fire startDocument() and endDocument() events that the xalan content
handler depends on to setup itself.

To fix this bug I would suggest to fire these events in case the input source
of the transform tag is a TagBodyInputSource.

This changed doTag method works now for me

    /**
     * Process this tag instance
     *
     * @param output The pipeline for xml events
     * @throws Exception - when required attributes are missing
     */
    public void doTag(XMLOutput output) throws MissingAttributeException, 
JellyTagException {

        if (null == this.getXslt()) {
            throw new MissingAttributeException("The xslt attribute cannot be 
null");
        }

        // set a resolver to locate uri
        this.tf.setURIResolver(createURIResolver());
        
        try {
            this.transformerHandler =
                this.tf.newTransformerHandler(this.getObjAsSAXSource
(this.getXslt()));
        } 
        catch (TransformerConfigurationException e) {
            throw new JellyTagException(e);
        }

        // run any nested param tags
        this.doNestedParamTag(output);

        try {
            // get a reader to provide SAX events to transformer
            XMLReader xmlReader = this.createXMLReader();
            xmlReader.setContentHandler(this.transformerHandler);
            xmlReader.setProperty(LEXICAL_HANDLER_PROPERTY, 
this.transformerHandler);
            
            // handle result differently, depending on if var is specified
            String varName = this.getVar();
            InputSource inputSource = this.getXMLInputSource();
            Result result = null == varName? this.createSAXResult(output): new 
DocumentResult(); 
            this.transformerHandler.setResult(result);
            // fire these events manually, transformerHandler needs this
            if (inputSource instanceof TagBodyInputSource) {
                this.transformerHandler.startDocument();
            }
            xmlReader.parse(inputSource);
            // fire these events manually, transformerHandler needs this
            if (inputSource instanceof TagBodyInputSource) {
                this.transformerHandler.endDocument();
            }
            if (null != varName ) {
                // output the result as a variable
                Document transformedDoc = ((DocumentResult) result).getDocument
();
                this.context.setVariable(varName, transformedDoc);
            }
        } 
        catch (SAXException e) {
            throw new JellyTagException(e);
        } 
        catch (IOException e) {
            throw new JellyTagException(e);
        }

    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message