You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Henry Zongaro (JIRA)" <xa...@xml.apache.org> on 2006/10/12 16:46:37 UTC

[jira] Commented: (XALANJ-2323) closeStartTag() in ToHTMLSAXHandler does not pass localName or namespace to the ContentHandler. Results in ValidationException in Apache FOP.

    [ http://issues.apache.org/jira/browse/XALANJ-2323?page=comments#action_12441760 ] 
            
Henry Zongaro commented on XALANJ-2323:
---------------------------------------

The ToHTMLSAXHandler and ToTextSAXHandler classes owe their existence to some ambiguity in the JAXP 1.1 and 1.2 specifications.  It wasn't clear whether the various output properties specified in <xsl:output> or through Transformer.setOutputProperty and related methods had an effect only on StreamResult or on all three standard kinds of Result objects.  Some of the output properties can have no meaningful effect on SAXResult or DOMResult objects, but others can, so we (I think I was the one who really pushed for this interpretation) assumed that it was the intent of the specification that they should have an effect.

We were wrong.  ToHTMLSAXHandler and ToTextSAXHandler should go away.  JAXP 1.3 makes that clear under "Result Tree Serialization":

"Serialization of the result tree to a stream can be controlled with the javax.xml.transform.Transformer.setOutputProperties [ Method setOutputProperties(java.util.Properties)] and the javax.xml.transform.Transformer.setOutputProperty [ Method setOutputProperty(java.lang.String, java.lang.String)] methods. These properties only apply to stream results, they have no effect when the result is a DOM tree or SAX event stream."

> closeStartTag() in ToHTMLSAXHandler does not pass localName or namespace to the ContentHandler.  Results in ValidationException in Apache FOP.
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2323
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2323
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: Serialization
>    Affects Versions: 2.7
>         Environment: All environments
>            Reporter: Chad W. Gill
>
> In ToHTMLSAXHandler the closeStartTag() incorrectly passes EmptyString to namespace and ElementName to localName of the ContentHandler.
> From org.apache.xml.serializer.ToHTMLSAXHandler :
>     protected void closeStartTag() throws SAXException
>     {
>         m_elemContext.m_startTagOpen = false;
>         // Now is time to send the startElement event
>         m_saxHandler.startElement(
>             EMPTYSTRING,                                                  <<<< Should this be m_elementURI ?
>             m_elemContext.m_elementName,                <<<< Should this be m_elementLocalName ?
>             m_elemContext.m_elementName,
>             m_attributes);
>         m_attributes.clear();       
>     }
> This results in a ValidationException being thrown by Apache FOP DefaultHandler's startElement().  In this case, the namespace = "" (should be "http://www.w3.org/1999/XSL/Format")  and the localName = "fo:root" (should be "root")
> From org.apache.fop.fo.FOTreeBuilder:
>          public void startElement(String namespaceURI, String localName, String rawName,
>                                  Attributes attlist) throws SAXException {
>             /* the node found in the FO document */
>             FONode foNode;
>             PropertyList propertyList = null;
>             // Check to ensure first node encountered is an fo:root
>             if (rootFObj == null) {
>                 if (!namespaceURI.equals(FOElementMapping.URI) 
>                     || !localName.equals("root")) {
>                     throw new ValidationException(
>                         "Error: First element must be the fo:root formatting object. "
>                         + "Found " + FONode.getNodeString(namespaceURI, localName) 
>                         + " instead."
>                         + " Please make sure you're producing a valid XSL-FO document.");
>                 }.......
> This exception will untimately produce the following message:
> javax.xml.transform.TransformerException: java.lang.IllegalStateException: endElement() called for fo:root where there is no current element.
> -------  Here is a workaround -----------------
> In XALAN, the decision to use ToHTMLSAXHandler is made if the following is in the xslt file:  <xsl:output version="1.0" method="html" encoding="UTF-8" indent="no"/>.   If you change the method="html" to method="xml", XALAN will use ToXMLSAXHandler instead (which will correctly pass namespace and localName).
> FYI, The FO XSLT that I'm using was produced by Altova Stylevision.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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