[ http://nagoya.apache.org/jira/browse/XALANJ-979?page=history ]
Henry Zongaro updated XALANJ-979:
---------------------------------
Priority: Minor (was: Blocker)
> no error check for localname in ContentHandler.startElement()
> -------------------------------------------------------------
>
> Key: XALANJ-979
> URL: http://nagoya.apache.org/jira/browse/XALANJ-979
> Project: XalanJ2
> Type: Bug
> Components: SAX
> Versions: 2.3
> Environment: Operating System: Windows 9x
> Platform: PC
> Reporter: Sean Moriarty
> Priority: Minor
>
> <xsl:copy-of select="." /> seems to fail when using sax events.
> However, it seems to be fine when using a flat xml file..
> >>>>>>
> For example:
> Using the following files:
> my.xml:
> <?xml version="1.0"?>
> <myXML>Data</myXML>
> my.xsl:
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:template match="/">
> <xsl:copy-of select="." />
> </xsl:template>
> </xsl:stylesheet>
> From the command line, results in the following:
> C:\java\xalan>java org.apache.xalan.xslt.Process -in my.xml -xsl my.xsl
> <?xml version="1.0" encoding="UTF-8"?>
> <myXML>Data</myXML>
> >>>
> However, when using the following script (see below) results in:
> C:\java\xalan>java XSLTrans
> <?xml version="1.0" encoding="UTF-8"?>
> Exception in thread "main" java.lang.RuntimeException:
> java.lang.ArrayIndexOutOf
> BoundsException
> at
> org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java
> :3231)
> at
> org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(Trans
> formerHandlerImpl.java:436)
> at XSLTrans.emitSAX(XSLTrans.java:32)
> at XSLTrans.main(XSLTrans.java:58)
> If I run the same script substituting
> <xsl:copy-of select="." />
> with
> <myXML><xsl:apply-templates /></myXML>
> the following is output:
> C:\java\xalan>java XSLTrans
> <?xml version="1.0" encoding="UTF-8"?>
> <myXML>Data</myXML>
> which seems fine. I tried on both Win98 & Win2000 & downloaded the latest
> release version of Xalan on 4/23, though I found the problem in earlier
> versions as well.
> >>>>>>XSLTrans.java
> import java.util.*;
> import java.text.*;
> import java.io.*;
> import org.xml.sax.*;
> import org.xml.sax.helpers.*;
> import javax.xml.transform.*;
> import javax.xml.transform.sax.*;
> import javax.xml.transform.stream.*;
> public class XSLTrans {
> static ContentHandler ch;
> private static final Attributes EMPTY_ATTR = new AttributesImpl();
> char temp[];
> public void setContentHandler (ContentHandler ch) {
> this.ch = ch;
> }
> public void emitSAX() throws SAXException {
> ch.startDocument();
> ch.startElement("","","myXML",EMPTY_ATTR);
> String data = "Data";
> temp = data.toCharArray();
> ch.characters(temp, 0, temp.length);
> ch.endElement("","","myXML");
> ch.endDocument();
> }
> public static void main(String args[]) throws ParseException {
> File xsltFile = new File("my.xsl");
> try {
> //Instantiate producer
> XSLTrans myProducer = new XSLTrans();
> // create an instance of TransformerFactory
> TransformerFactory transFact = TransformerFactory.newInstance();
> if (transFact.getFeature(SAXTransformerFactory.FEATURE)) {
> SAXTransformerFactory saxTransFact = (SAXTransformerFactory) transFact;
> TransformerHandler transHand = saxTransFact.newTransformerHandler(new
> StreamSource(xsltFile));
> // set the destination for the XSLT transformation
> transHand.setResult(new StreamResult(System.out));
> myProducer.setContentHandler(transHand);
> myProducer.emitSAX();
> }
> } catch (SAXException e) {
> System.out.println("SAXException");
> } catch (TransformerException e) {
> System.out.println("TransformerException");
> e.printStackTrace();
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]