SAX Parsing passes back wrong attribute value
---------------------------------------------

                 Key: XERCESJ-1303
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1303
             Project: Xerces2-J
          Issue Type: Bug
          Components: SAX
         Environment: Java 1.6 included Xerces: 
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
            Reporter: Björn Müller


A certain attribute is not transferred back properly through the SAX interface. 
I ran the parsing of one and the same XML first with Xerces and then with 
Crimson. Please find the isolated code including the XML string below.

Somehow the attribute following the wrong one is mixing in. 

I hope it's not me doing some foolish thing...




This is the test class
======================

package org.eclnt.zztest;

import java.io.StringReader;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class TestParser
{
    public static class MyParser extends DefaultHandler
    {
        public void startElement(String uri, String localName, String name,
                Attributes attributes) throws SAXException
        {
            super.startElement(uri, localName, name, attributes);
            System.out.println("ELEMENT: " + name);
            for (int i=0; i<attributes.getLength(); i++)
            {
                System.out.println(attributes.getQName(i) + " = " +
                                   attributes.getValue(i));
            }
        }
    }
    
    public static void main(String[] args)
    {
        String s = 
          "<t:modalpopup id='g_24'"+ 
          "   bgpaint='#{eclntdefscr.modalPopups[0].bgpaint}'"+ 
          "   
actionListener='#{eclntdefscr.modalPopups[0].onPopupClosedByUser}'"+ 
          "   height='#{eclntdefscr.modalPopups[0].height}'"+ 
          "   opened='#{eclntdefscr.modalPopups[0].opened}'"+
          "   title='#{eclntdefscr.modalPopups[0].title}'"+
          "   undecorated='#{eclntdefscr.modalPopups[0].undecorated}'"+ 
          "   width='#{eclntdefscr.modalPopups[0].width}'"+
          "   harryleft='#{eclntdefscr.modalPopups[0].left}'"+ 
          "   harrytop='#{eclntdefscr.modalPopups[0].top}'"+
          "    >"+
          "</t:modalpopup>";
     
        try
        {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
            System.out.println("Parser = " + saxParser.getClass().getName());
            InputSource is = new InputSource(new StringReader(s));
            saxParser.parse(is,new MyParser());
        }
        catch (Throwable t)
        {
            t.printStackTrace();
        }
    }

}

This is the output with XERCES parser (included in Java 1.6):
=============================================================

Parser = com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
ELEMENT: t:modalpopup
id = g_24
bgpaint = #{eclntdefscr.modalPopups[0].bgpaint}
actionListener = #{eclntdefscr.modalPopups[0].onPopupClosedByUser}
height = #{eclntdefscr.modalPopups[0].height}
opened = #{eclntdefscr.modalPopups[0].opened}
title = #{eclntdefscr.modalPopups[0].title}
undecorated = #{eclntdefscr.modalPopups[0].undecorated}
width = #{eclntdefscr.modalPopups[0].left}}
harryleft = #{eclntdefscr.modalPopups[0].left}
harrytop = #{eclntdefscr.modalPopups[0].top}


This is the output with CRIMSON parser:
=======================================

Parser = org.apache.crimson.jaxp.SAXParserImpl
ELEMENT: t:modalpopup
id = g_24
bgpaint = #{eclntdefscr.modalPopups[0].bgpaint}
actionListener = #{eclntdefscr.modalPopups[0].onPopupClosedByUser}
height = #{eclntdefscr.modalPopups[0].height}
opened = #{eclntdefscr.modalPopups[0].opened}
title = #{eclntdefscr.modalPopups[0].title}
undecorated = #{eclntdefscr.modalPopups[0].undecorated}
width = #{eclntdefscr.modalPopups[0].width}
harryleft = #{eclntdefscr.modalPopups[0].left}
harrytop = #{eclntdefscr.modalPopups[0].top}

Please focus on the line with "width":
======================================

Xerces : width = #{eclntdefscr.modalPopups[0].left}}
Crimson: width = #{eclntdefscr.modalPopups[0].width}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to