Xerces is throwing an erroneouos sax parse exception that complains about the
absence of white space. Below is a standalone jaxp program 'ProtoParseXML.java'
that demonstrates the bug. The version of Xerces that exhibits the bug
is tag JDK-integration after 2.4 release; Xerces 2.4 does not exhibit this
bug, therefore this is a regression in Xerces component of Tiger.
Run with latest Tiger build:
----------------------------------
tigerfish% java -cp "." ProtoParseXML ra-ent.xsl
[Fatal Error] :2:21: White space is required between the entity name "toplevel"
and the definition in the entity declaration.
** Parsing error: line 2,uri null
White space is required between the entity name "toplevel" and the definition
in the entity declaration.
The Standalone program:
-------------------------
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.sax.SAXTransformerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import java.io.IOException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.OutputKeys;
public class ProtoParseXML {
public static void main(String[] args){
ProtoParseXML app = new ProtoParseXML();
app.run(args);
}
public void run(String[] args){
if (args.length != 1) {
usage();
}
String xmlFile = args[0];
SAXParserFactory sfactory = SAXParserFactory.newInstance();
sfactory.setNamespaceAware(true);
try {
// create the xml reader
SAXParser parser = sfactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
// create an identity transform as content handler for reader
SAXTransformerFactory stf =
(SAXTransformerFactory)TransformerFactory.newInstance();
TransformerHandler serializer = stf.newTransformerHandler();
// set the output to xml 1.1, may be ignored currently...
//Transformer identity = serializer.getTransformer();
//identity.setOutputProperty(OutputKeys.VERSION, "1.1");
// hook up serializer to std out
serializer.setResult(new StreamResult(System.out));
// hook up serializer as content handler for reader
reader.setContentHandler(serializer);
// start the reader reading the xml doc
reader.parse(new InputSource(new FileInputStream(xmlFile)));
}
catch (SAXParseException e) {
// locates errors in the original XML document,extends SAXException
System.out.println("\n** Parsing error: line " + e.getLineNumber()+
",uri " + e.getSystemId());
System.out.println(" " + e.getMessage());
}
catch (SAXException e) {
// basic error or warning info from either parser or application.
System.out.println("SAXException: " + e.getMessage());
}
catch (ParserConfigurationException e) {
// error configuring the SAX parser
System.out.println("SAXException: " + e.getMessage());
}
catch (IOException e) {
System.err.println("Could not open file..." + e);
e.printStackTrace();
}
catch (TransformerConfigurationException e) {
System.err.println("Transformer config error...");
}
catch (Exception e) {
System.err.println("Exception here...");
}
System.exit(0);
}
public void usage() {
System.err.println(
"Usage: run <xml_file>");
System.exit(1);
}
}
The stylesheets:
------------------
ra-ent.xsl
<!DOCTYPE xsl:transform [
ENTITY toplevel SYSTEM "toptemplate.xsl"
]>
<xsl:transform
xmlns:astro="http://www.astro.com/astro"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<!-- ra between 00:00:00 and 01:00:00 -->
<xsl:param name="ra_min_hr" select="0.106"/>
<xsl:param name="ra_max_hr" select="0.108"/>
&toplevel;
<xsl:template match="astro:star">
<xsl:if test="(
(number(astro:ra/astro:dv) >= $ra_min_hr) and
(number(astro:ra/astro:dv) <= $ra_max_hr))" >
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
<xsl:template match="astro:_test-04">
<!-- discard text contents -->
</xsl:template>
</xsl:transform>
------------------------------------------------------
toptemplate.xsl:
<xsl:template match="astro:stardb">
<stardb xmlns="http://www.astro.com/astro"
xsi:schemaLocation="http://www.astro.com/astro catalog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<xsl:apply-templates/>
</stardb>
</xsl:template>
###@###.### 2003-06-25
###@###.### 2003-07-24
absence of white space. Below is a standalone jaxp program 'ProtoParseXML.java'
that demonstrates the bug. The version of Xerces that exhibits the bug
is tag JDK-integration after 2.4 release; Xerces 2.4 does not exhibit this
bug, therefore this is a regression in Xerces component of Tiger.
Run with latest Tiger build:
----------------------------------
tigerfish% java -cp "." ProtoParseXML ra-ent.xsl
[Fatal Error] :2:21: White space is required between the entity name "toplevel"
and the definition in the entity declaration.
** Parsing error: line 2,uri null
White space is required between the entity name "toplevel" and the definition
in the entity declaration.
The Standalone program:
-------------------------
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.sax.SAXTransformerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import java.io.IOException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.OutputKeys;
public class ProtoParseXML {
public static void main(String[] args){
ProtoParseXML app = new ProtoParseXML();
app.run(args);
}
public void run(String[] args){
if (args.length != 1) {
usage();
}
String xmlFile = args[0];
SAXParserFactory sfactory = SAXParserFactory.newInstance();
sfactory.setNamespaceAware(true);
try {
// create the xml reader
SAXParser parser = sfactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
// create an identity transform as content handler for reader
SAXTransformerFactory stf =
(SAXTransformerFactory)TransformerFactory.newInstance();
TransformerHandler serializer = stf.newTransformerHandler();
// set the output to xml 1.1, may be ignored currently...
//Transformer identity = serializer.getTransformer();
//identity.setOutputProperty(OutputKeys.VERSION, "1.1");
// hook up serializer to std out
serializer.setResult(new StreamResult(System.out));
// hook up serializer as content handler for reader
reader.setContentHandler(serializer);
// start the reader reading the xml doc
reader.parse(new InputSource(new FileInputStream(xmlFile)));
}
catch (SAXParseException e) {
// locates errors in the original XML document,extends SAXException
System.out.println("\n** Parsing error: line " + e.getLineNumber()+
",uri " + e.getSystemId());
System.out.println(" " + e.getMessage());
}
catch (SAXException e) {
// basic error or warning info from either parser or application.
System.out.println("SAXException: " + e.getMessage());
}
catch (ParserConfigurationException e) {
// error configuring the SAX parser
System.out.println("SAXException: " + e.getMessage());
}
catch (IOException e) {
System.err.println("Could not open file..." + e);
e.printStackTrace();
}
catch (TransformerConfigurationException e) {
System.err.println("Transformer config error...");
}
catch (Exception e) {
System.err.println("Exception here...");
}
System.exit(0);
}
public void usage() {
System.err.println(
"Usage: run <xml_file>");
System.exit(1);
}
}
The stylesheets:
------------------
ra-ent.xsl
<!DOCTYPE xsl:transform [
ENTITY toplevel SYSTEM "toptemplate.xsl"
]>
<xsl:transform
xmlns:astro="http://www.astro.com/astro"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<!-- ra between 00:00:00 and 01:00:00 -->
<xsl:param name="ra_min_hr" select="0.106"/>
<xsl:param name="ra_max_hr" select="0.108"/>
&toplevel;
<xsl:template match="astro:star">
<xsl:if test="(
(number(astro:ra/astro:dv) >= $ra_min_hr) and
(number(astro:ra/astro:dv) <= $ra_max_hr))" >
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
<xsl:template match="astro:_test-04">
<!-- discard text contents -->
</xsl:template>
</xsl:transform>
------------------------------------------------------
toptemplate.xsl:
<xsl:template match="astro:stardb">
<stardb xmlns="http://www.astro.com/astro"
xsi:schemaLocation="http://www.astro.com/astro catalog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<xsl:apply-templates/>
</stardb>
</xsl:template>
###@###.### 2003-06-25
###@###.### 2003-07-24