Hi, Chris.
Chris Bowditch <[EMAIL PROTECTED]> wrote on 2008-08-14 06:45:19
AM:
> > Do you happen to know whether the characters in the content of the
> > xsl:text are being reported through ContentHandler.ignorableWhitespace
> > or through ContentHandler.characters? If the former, would it be
> > possible for you to try using the characters method as a work-around
> > instead - you mentioned that you're generating the stylesheet
> > programmatically using SAX events.
>
> Actually we use the ContentHandler.characters method to report the space
> inside the <xsl:text> element. Could there be a bug here too?
No, I think it's processing calls to ContextHandler.characters correctly.
I tried the following Java driver program, in an attempt to simulate what
you're doing, but the space character I placed in an xsl:text element is
being preserved. I even went back to versions as old as Xalan-J 2.3.0,
and the output was always correct. Without a sample driver program that
demonstrates the problem, I don't think I can help figure out what's going
wrong. Are you able to produce a stand-alone example?
import java.io.StringReader;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.helpers.AttributesImpl;
public class StyleIt {
public static final String XSLT_NS =
"http://www.w3.org/1999/XSL/Transform";
public static final void main(String[] args) throws Exception {
TemplatesHandler th =
((SAXTransformerFactory) TransformerFactory.newInstance())
.newTemplatesHandler();
AttributesImpl attrs = new AttributesImpl();
th.startDocument();
th.startPrefixMapping("xsl", XSLT_NS);
// <xsl:stylesheet version="1.0">
attrs.addAttribute("", "version", "version", "CDATA", "1.0");
th.startElement(XSLT_NS, "stylesheet", "xsl:stylesheet", attrs);
attrs.clear();
// <xsl:template match="/">
attrs.addAttribute("", "match", "match", "CDATA", "/");
th.startElement(XSLT_NS, "template", "xsl:template", attrs);
attrs.clear();
// <lre>
th.startElement("", "lre", "lre", attrs);
// <xsl:text>
th.startElement(XSLT_NS, "text", "xsl:text", attrs);
th.characters(" ".toCharArray(), 0, 1);
// </xsl:text>
th.endElement(XSLT_NS, "text", "xsl:text");
// </lre>
th.endElement("", "lre", "lre");
// </xsl:template>
th.endElement(XSLT_NS, "template", "xsl:template");
// </xsl:stylesheet>
th.endElement(XSLT_NS, "stylesheet", "xsl:stylesheet");
th.endPrefixMapping("xsl");
th.endDocument();
th.getTemplates().newTransformer().transform(
new StreamSource(new StringReader("<doc/>")),
new StreamResult(System.out));
}
}
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab T/L 313-6044; Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]