From 1a37d8fa1c2114091a32846239b4f1e3bbe552b3 Mon Sep 17 00:00:00 2001 From: edwingo Date: Thu, 28 Jun 2001 23:12:32 +0000 Subject: [PATCH] Updates in javax.xml.{parsers, transform} for JAXP (Reference Implementation) RI version 1.1.1. Javadoc fixes to SAXParser and SAXParserFactory. Misc bug fixes to javax.xml.transform classes. git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@225916 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/javax/xml/parsers/SAXParser.java | 32 ++++++++++++------- .../javax/xml/parsers/SAXParserFactory.java | 4 +++ .../xml/transform/TransformerException.java | 3 +- .../xml/transform/stream/StreamResult.java | 9 +++++- .../xml/transform/stream/StreamSource.java | 11 +++++-- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/java/external/src/javax/xml/parsers/SAXParser.java b/java/external/src/javax/xml/parsers/SAXParser.java index da381b7..67da490 100644 --- a/java/external/src/javax/xml/parsers/SAXParser.java +++ b/java/external/src/javax/xml/parsers/SAXParser.java @@ -84,15 +84,6 @@ import org.xml.sax.SAXNotSupportedException; * a variety of input sources. These input sources are InputStreams, * Files, URLs, and SAX InputSources.

* - * This static method creates a new factory instance based - * on a system property setting or uses the platform default - * if no property has been defined.

- * - * The system property that controls which Factory implementation - * to create is named "javax.xml.parsers.SAXParserFactory". - * This property names a class that is a concrete subclass of this - * abstract class. If no property is defined, a platform default - * will be used.

* * As the content is parsed by the underlying parser, methods of the * given {@link org.xml.sax.HandlerBase} or the @@ -130,6 +121,8 @@ public abstract class SAXParser { * @param hb The SAX HandlerBase to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the given InputStream is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -155,6 +148,8 @@ public abstract class SAXParser { * @param systemId The systemId which is needed for resolving relative URIs. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the given InputStream is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler * version of this method instead. */ @@ -180,6 +175,8 @@ public abstract class SAXParser { * @param dh The SAX DefaultHandler to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the given InputStream is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -204,6 +201,8 @@ public abstract class SAXParser { * @param systemId The systemId which is needed for resolving relative URIs. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the given InputStream is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler * version of this method instead. */ @@ -231,6 +230,8 @@ public abstract class SAXParser { * @param hb The SAX HandlerBase to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the uri is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -254,6 +255,8 @@ public abstract class SAXParser { * @param dh The SAX DefaultHandler to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the uri is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -279,6 +282,8 @@ public abstract class SAXParser { * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the File object is null. * @see org.xml.sax.DocumentHandler + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. */ public void parse(File f, HandlerBase hb) @@ -304,6 +309,8 @@ public abstract class SAXParser { * @param dh The SAX DefaultHandler to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the File object is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -333,6 +340,8 @@ public abstract class SAXParser { * @param hb The SAX HandlerBase to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the InputSource is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -362,6 +371,8 @@ public abstract class SAXParser { * @param dh The SAX DefaultHandler to use. * @exception IOException If any IO errors occur. * @exception IllegalArgumentException If the InputSource is null. + * @exception SAXException If the underlying parser throws a + * SAXException while parsing. * @see org.xml.sax.DocumentHandler */ @@ -461,7 +472,4 @@ public abstract class SAXParser { */ public abstract Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException; - - - } diff --git a/java/external/src/javax/xml/parsers/SAXParserFactory.java b/java/external/src/javax/xml/parsers/SAXParserFactory.java index de4f3fb..38e5529 100644 --- a/java/external/src/javax/xml/parsers/SAXParserFactory.java +++ b/java/external/src/javax/xml/parsers/SAXParserFactory.java @@ -71,6 +71,10 @@ import org.xml.sax.SAXNotSupportedException; * An application can use the same instance of the factory to obtain one or * more instances of the SAXParser provided the instance * of the factory isn't being used in more than one thread at a time. + *

+ * + * The static newInstance method returns a new concrete + * implementation of this class. * * @since JAXP 1.0 * @version 1.0 diff --git a/java/external/src/javax/xml/transform/TransformerException.java b/java/external/src/javax/xml/transform/TransformerException.java index 944c5b6..cf2646b 100644 --- a/java/external/src/javax/xml/transform/TransformerException.java +++ b/java/external/src/javax/xml/transform/TransformerException.java @@ -336,7 +336,6 @@ public class TransformerException extends Exception { * @param s The writer where the dump will be sent to. */ public void printStackTrace(java.io.PrintWriter s) { - if (s == null) { s = new java.io.PrintWriter(System.err, true); } @@ -347,7 +346,6 @@ public class TransformerException extends Exception { if (null != locInfo) { s.println(locInfo); } - super.printStackTrace(s); } catch (Throwable e) {} @@ -396,5 +394,6 @@ public class TransformerException extends Exception { exception = null; } } + s.flush(); } } diff --git a/java/external/src/javax/xml/transform/stream/StreamResult.java b/java/external/src/javax/xml/transform/stream/StreamResult.java index e650080..ad2fd3a 100644 --- a/java/external/src/javax/xml/transform/stream/StreamResult.java +++ b/java/external/src/javax/xml/transform/stream/StreamResult.java @@ -188,7 +188,14 @@ public class StreamResult implements Result { * @param f Must a non-null File reference. */ public void setSystemId(File f) { - this.systemId = "file:///" + f.getAbsolutePath(); + String fpath=f.getAbsolutePath(); + if (File.separatorChar != '/') { + fpath = fpath.replace(File.separatorChar, '/'); + } + if( fpath.startsWith("/")) + this.systemId= "file://" + fpath; + else + this.systemId = "file:///" + fpath; } /** diff --git a/java/external/src/javax/xml/transform/stream/StreamSource.java b/java/external/src/javax/xml/transform/stream/StreamSource.java index 0873cab..e4d1ee3 100644 --- a/java/external/src/javax/xml/transform/stream/StreamSource.java +++ b/java/external/src/javax/xml/transform/stream/StreamSource.java @@ -160,7 +160,7 @@ public class StreamSource implements Source { * @param f Must a non-null File reference. */ public StreamSource(File f) { - this.systemId = "file:///" + f.getAbsolutePath(); + setSystemId(f); } /** @@ -268,7 +268,14 @@ public class StreamSource implements Source { * @param f Must a non-null File reference. */ public void setSystemId(File f) { - this.systemId = "file:///" + f.toString(); + String fpath=f.getAbsolutePath(); + if (File.separatorChar != '/') { + fpath = fpath.replace(File.separatorChar, '/'); + } + if( fpath.startsWith("/")) + this.systemId= "file://" + fpath; + else + this.systemId = "file:///" + fpath; } //////////////////////////////////////////////////////////////////////