You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by KOZLOV Roman <r-...@opencascade.com> on 2002/07/05 12:20:18 UTC

SAXEventGenerator broken?

Hello,

It seems that SAXEventGenerator in Xindice 1.0 ("Birthday") is broken.
Could someone confirm this?
The matter is that when I've been using xindice.jar from 1.0rc2 my
client application (Cocoon 2.0.1 based) received correctly UTF-8 encoded
xml.
After replacing the xindice.jar by one from 1.0 version received xml is
broken (each non-ASCII character consists of some two characters).

Cocoon 2.0.1 uses SAX generator. Comparing source code of 1.0 and 1.0rc2
I can see for org.apache.xindice.xml.sax.SAXEventGenerator the comment
"must be fixed" and no UTF-8 encoding in 1.0 against 1.0rc2.
For 1.0 attribute value is computed as String(b), and for 1.0rc2 - as
String(b, "UTF-8").
Is it a bug of 1.0?

See the following snippets:

***** (1.0)
W:\XINDICE\JAVA\SRC\ORG\APACHE\XINDICE\XML\SAX\SAXEventGenerator.java
            String lclName = getLocalName(attrName);

            /* UTF8TOFIX: must be fixed when switching to internal UTF-8
representation of strings */
            String attrValue = new String(b);

            // look for and buffer newly mapped namespace prefixes
            if (attrName.startsWith(XMLNS_ATTR_PREFIX)) {
                // create the buffer if needed
                if (mappedPrefixes == null)
                    mappedPrefixes = new String[XMLNS_MAP_INCREMENT];

                // check the buffer's capacity
                if (nsMapCount >= mappedPrefixes.length) {
                    String[] newBuf = new String[mappedPrefixes.length +
XMLNS_MAP_INCREMENT];
                    System.arraycopy(mappedPrefixes, 0, newBuf, 0,
newBuf.length);
                    mappedPrefixes = newBuf;
                }

                content.startPrefixMapping(lclName, attrValue);
                mappedPrefixes[nsMapCount++] = lclName;
            }

            attrs.addAttribute(attrURI != null ? attrURI : "", lclName,
attrName, "", attrValue);
         }

***** (1.0rc2) SAXEVENTGENERATOR.JAVA
            String lclName = getLocalName(attrName);

            attrs.addAttribute(attrURI != null ? attrURI : "", lclName,
attrName, "", new String(b, "UTF-8"));
         }
*****

Thank you for reply.
Roman