Hi,
I realize that this is most probably Xerces problem. But it affects Xalan
work in my case and there's still chance Xalan doesn't work correctly not
Xerces. So I'm sending this message to this mail-list. Sorry for
inconvenience.
I tried to use SAXParser/XMLReader with
javax.xml.transform.sax.TransformerHandler implementations. Code looks like:
TransformerHandler th_hnd =
((SAXTransformerFactory)th_fry).newTransformerHandler (templates);
...
...
th_hnd.setResult (new StreamResult(out));
...
...
XMLReader reader = sax_fry.newSAXParser().getXMLReader ();
reader.setContentHandler (th_hnd);
reader.parse (new InputSource(in));
Reader was an instance of org.apache.xerces.parsers.SAXParser
Here "in" and "out" are streams.
For XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<city>Sevastopol</city>
</root>
and XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method="html"
/>
<xsl:template match="/">
<h2>
<xsl:value-of select="root/city"/>
</h2>
</xsl:template>
</xsl:stylesheet>
I expected to get result:
<h2>Sevastopol</h2>
But the real result was:
<h2></h2>
I suspected that Xerces's SAXParser calls ContentHadler methods incorrectly.
I traced ContentHandler.startElement(String namespaceURI, String localName,
String qName, Attributes atts) and got:
namespaceURI = ""
localName = "" !!!!!!!!
qName = "root"
Here localName is empty but I belive it should be equal to qName in the case
namespace-uri is empty, right?
I rewrote source code as following:
TransformerHandler th_hnd =
((SAXTransformerFactory)th_fry).newTransformerHandler (templates);
...
...
th_hnd.setResult (new StreamResult(out));
...
...
th_hnd.startDocument ();
th_hnd.startElement ("", "root", "root", new AttributesImpl());
th_hnd.startElement ("", "city", "city", new AttributesImpl());
String s = "Sevastopol";
th_hnd.characters (s.toCharArray(), 0, s.length());
th_hnd.endElement ("", "city", "city");
th_hnd.endElement ("", "root", "root");
th_hnd.endDocument ();
After running this code I got correct result. So I believe
org.apache.xerces.parsers.SAXParser calls ContentHandler methods
incorrectly.
If it's a bug I can sumbit it to th bug-system for Xalan or Xerces.
Thanks,
Dmitry