[ 
http://issues.apache.org/jira/browse/XALANJ-2323?page=comments#action_12443018 
] 
            
Brian Minchau commented on XALANJ-2323:
---------------------------------------

ToTextSAXHandler consumes all startElement  and endElement events because it 
"knows" that the final stream serializer will consume them rather than emit 
something for them into the stream of bytes. This was an optimization. 
ToHTMLSAXHandler  does similar. However this is in violation of JAXP 1.3, as 
the events ought to be passed further down the line (the user may have their 
own ContentHandler to accept SAX events for serializing text output).

Per the JIRA triage meeting on Oct 16, 2005:
Suggest that ToHTMLSAXHandler and ToTextSAXHandler be deprecated, and that only 
ToXMLSAXHandler be used in the future, which will resolve this particular issue.

> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to