summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/xml
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/javax/xml
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/classpath/javax/xml')
-rw-r--r--libjava/classpath/javax/xml/XMLConstants.java131
-rw-r--r--libjava/classpath/javax/xml/datatype/DatatypeConfigurationException.java70
-rw-r--r--libjava/classpath/javax/xml/datatype/DatatypeConstants.java264
-rw-r--r--libjava/classpath/javax/xml/datatype/DatatypeFactory.java421
-rw-r--r--libjava/classpath/javax/xml/datatype/Duration.java291
-rw-r--r--libjava/classpath/javax/xml/datatype/XMLGregorianCalendar.java217
-rw-r--r--libjava/classpath/javax/xml/datatype/package.html57
-rw-r--r--libjava/classpath/javax/xml/namespace/NamespaceContext.java67
-rw-r--r--libjava/classpath/javax/xml/namespace/QName.java173
-rw-r--r--libjava/classpath/javax/xml/namespace/package.html9
-rw-r--r--libjava/classpath/javax/xml/parsers/DocumentBuilder.java203
-rw-r--r--libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java369
-rw-r--r--libjava/classpath/javax/xml/parsers/FactoryConfigurationError.java113
-rw-r--r--libjava/classpath/javax/xml/parsers/ParserConfigurationException.java66
-rw-r--r--libjava/classpath/javax/xml/parsers/SAXParser.java340
-rw-r--r--libjava/classpath/javax/xml/parsers/SAXParserFactory.java273
-rw-r--r--libjava/classpath/javax/xml/parsers/package.html16
-rw-r--r--libjava/classpath/javax/xml/stream/EventFilter.java53
-rw-r--r--libjava/classpath/javax/xml/stream/FactoryConfigurationError.java85
-rw-r--r--libjava/classpath/javax/xml/stream/Location.java75
-rw-r--r--libjava/classpath/javax/xml/stream/StreamFilter.java52
-rw-r--r--libjava/classpath/javax/xml/stream/XMLEventFactory.java352
-rw-r--r--libjava/classpath/javax/xml/stream/XMLEventReader.java102
-rw-r--r--libjava/classpath/javax/xml/stream/XMLEventWriter.java108
-rw-r--r--libjava/classpath/javax/xml/stream/XMLInputFactory.java451
-rw-r--r--libjava/classpath/javax/xml/stream/XMLOutputFactory.java279
-rw-r--r--libjava/classpath/javax/xml/stream/XMLReporter.java57
-rw-r--r--libjava/classpath/javax/xml/stream/XMLResolver.java65
-rw-r--r--libjava/classpath/javax/xml/stream/XMLStreamConstants.java121
-rw-r--r--libjava/classpath/javax/xml/stream/XMLStreamException.java98
-rw-r--r--libjava/classpath/javax/xml/stream/XMLStreamReader.java300
-rw-r--r--libjava/classpath/javax/xml/stream/XMLStreamWriter.java243
-rw-r--r--libjava/classpath/javax/xml/stream/events/Attribute.java70
-rw-r--r--libjava/classpath/javax/xml/stream/events/Characters.java67
-rw-r--r--libjava/classpath/javax/xml/stream/events/Comment.java52
-rw-r--r--libjava/classpath/javax/xml/stream/events/DTD.java72
-rw-r--r--libjava/classpath/javax/xml/stream/events/EndDocument.java46
-rw-r--r--libjava/classpath/javax/xml/stream/events/EndElement.java61
-rw-r--r--libjava/classpath/javax/xml/stream/events/EntityDeclaration.java77
-rw-r--r--libjava/classpath/javax/xml/stream/events/EntityReference.java57
-rw-r--r--libjava/classpath/javax/xml/stream/events/Namespace.java62
-rw-r--r--libjava/classpath/javax/xml/stream/events/NotationDeclaration.java62
-rw-r--r--libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java57
-rw-r--r--libjava/classpath/javax/xml/stream/events/StartDocument.java79
-rw-r--r--libjava/classpath/javax/xml/stream/events/StartElement.java83
-rw-r--r--libjava/classpath/javax/xml/stream/events/XMLEvent.java135
-rw-r--r--libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java151
-rw-r--r--libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java408
-rw-r--r--libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java68
-rw-r--r--libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java55
-rw-r--r--libjava/classpath/javax/xml/transform/ErrorListener.java66
-rw-r--r--libjava/classpath/javax/xml/transform/OutputKeys.java103
-rw-r--r--libjava/classpath/javax/xml/transform/Result.java72
-rw-r--r--libjava/classpath/javax/xml/transform/Source.java60
-rw-r--r--libjava/classpath/javax/xml/transform/SourceLocator.java70
-rw-r--r--libjava/classpath/javax/xml/transform/Templates.java67
-rw-r--r--libjava/classpath/javax/xml/transform/Transformer.java164
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerConfigurationException.java101
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerException.java246
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerFactory.java284
-rw-r--r--libjava/classpath/javax/xml/transform/TransformerFactoryConfigurationError.java106
-rw-r--r--libjava/classpath/javax/xml/transform/URIResolver.java58
-rw-r--r--libjava/classpath/javax/xml/transform/dom/DOMLocator.java57
-rw-r--r--libjava/classpath/javax/xml/transform/dom/DOMResult.java163
-rw-r--r--libjava/classpath/javax/xml/transform/dom/DOMSource.java118
-rw-r--r--libjava/classpath/javax/xml/transform/dom/package.html5
-rw-r--r--libjava/classpath/javax/xml/transform/package.html38
-rw-r--r--libjava/classpath/javax/xml/transform/sax/SAXResult.java132
-rw-r--r--libjava/classpath/javax/xml/transform/sax/SAXSource.java197
-rw-r--r--libjava/classpath/javax/xml/transform/sax/SAXTransformerFactory.java115
-rw-r--r--libjava/classpath/javax/xml/transform/sax/TemplatesHandler.java68
-rw-r--r--libjava/classpath/javax/xml/transform/sax/TransformerHandler.java78
-rw-r--r--libjava/classpath/javax/xml/transform/sax/package.html9
-rw-r--r--libjava/classpath/javax/xml/transform/stream/StreamResult.java173
-rw-r--r--libjava/classpath/javax/xml/transform/stream/StreamSource.java210
-rw-r--r--libjava/classpath/javax/xml/transform/stream/package.html6
-rw-r--r--libjava/classpath/javax/xml/validation/Schema.java61
-rw-r--r--libjava/classpath/javax/xml/validation/SchemaFactory.java264
-rw-r--r--libjava/classpath/javax/xml/validation/SchemaFactoryLoader.java52
-rw-r--r--libjava/classpath/javax/xml/validation/TypeInfoProvider.java83
-rw-r--r--libjava/classpath/javax/xml/validation/Validator.java117
-rw-r--r--libjava/classpath/javax/xml/validation/ValidatorHandler.java115
-rw-r--r--libjava/classpath/javax/xml/validation/package.html9
-rw-r--r--libjava/classpath/javax/xml/xpath/XPath.java115
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathConstants.java91
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathException.java88
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathExpression.java86
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathExpressionException.java61
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFactory.java227
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFactoryConfigurationException.java61
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFunction.java59
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFunctionException.java61
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathFunctionResolver.java59
-rw-r--r--libjava/classpath/javax/xml/xpath/XPathVariableResolver.java52
-rw-r--r--libjava/classpath/javax/xml/xpath/package.html9
95 files changed, 11619 insertions, 0 deletions
diff --git a/libjava/classpath/javax/xml/XMLConstants.java b/libjava/classpath/javax/xml/XMLConstants.java
new file mode 100644
index 000000000..82485c8df
--- /dev/null
+++ b/libjava/classpath/javax/xml/XMLConstants.java
@@ -0,0 +1,131 @@
+/* XMLConstants.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml;
+
+/**
+ * Repository for well-known XML constants.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.5
+ */
+public final class XMLConstants
+{
+
+ private XMLConstants()
+ {
+ // to prevent instantiation
+ }
+
+ /**
+ * Dummy namespace URI indicating that there is no namespace.
+ * @see http://www.w3.org/TR/REC-xml-names/#defaulting
+ */
+ public static final String NULL_NS_URI = "";
+
+ /**
+ * Dummy namespace prefix indicating that there is no namespace.
+ * @see http://www.w3.org/TR/REC-xml-names/#ns-qualnames
+ */
+ public static final String DEFAULT_NS_PREFIX = "";
+
+ /**
+ * The XML Namespace URI.
+ * @see http://www.w3.org/TR/REC-xml-names/#ns-qualnames
+ */
+ public static final String XML_NS_URI =
+ "http://www.w3.org/XML/1998/namespace";
+
+ /**
+ * The XML Namespace prefix.
+ * @see http://www.w3.org/TR/REC-xml-names/#ns-qualnames
+ */
+ public static final String XML_NS_PREFIX = "xml";
+
+ /**
+ * The XML Namespace declaration URI.
+ * @see http://www.w3.org/TR/REC-xml-names/#ns-qualnames
+ */
+ public static final String XMLNS_ATTRIBUTE_NS_URI =
+ "http://www.w3.org/2000/xmlns/";
+
+ /**
+ * The XML Namespace declaration attribute.
+ * @see http://www.w3.org/TR/REC-xml-names/#ns-qualnames
+ */
+ public static final String XMLNS_ATTRIBUTE = "xmlns";
+
+ /**
+ * The XML Schema (XSD) namespace URI.
+ * @see http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions
+ */
+ public static final String W3C_XML_SCHEMA_NS_URI =
+ "http://www.w3.org/2001/XMLSchema";
+
+ /**
+ * The XML Schema Instance (XSI) namespace URI.
+ * @see http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions
+ */
+ public static final String W3C_XML_SCHEMA_INSTANCE_NS_URI =
+ "http://www.w3.org/2001/XMLSchema-instance";
+
+ /**
+ * The XPath 2.0 datatypes namespace URI.
+ * @see http://www.w3.org/TR/xpath-datamodel
+ */
+ public static final String W3C_XPATH_DATATYPE_NS_URI =
+ "http://www.w3.org/2003/11/xpath-datatypes";
+
+ /**
+ * The XML DTD namespace URI.
+ */
+ public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";
+
+ /**
+ * The RELAX NG Namespace URI.
+ * @see http://relaxng.org/spec-20011203.html
+ */
+ public static final String RELAXNG_NS_URI =
+ "http://relaxng.org/ns/structure/1.0";
+
+ /**
+ * DOM feature for secure processing.
+ */
+ public static final String FEATURE_SECURE_PROCESSING =
+ "http://javax.xml.XMLConstants/feature/secure-processing";
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/DatatypeConfigurationException.java b/libjava/classpath/javax/xml/datatype/DatatypeConfigurationException.java
new file mode 100644
index 000000000..642cdcaf3
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/DatatypeConfigurationException.java
@@ -0,0 +1,70 @@
+/* DatatypeConfigurationException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.datatype;
+
+/**
+ * A serious error during datatype configuration.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public class DatatypeConfigurationException
+ extends Exception
+{
+
+ public DatatypeConfigurationException()
+ {
+ super();
+ }
+
+ public DatatypeConfigurationException(String message)
+ {
+ super(message);
+ }
+
+ public DatatypeConfigurationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public DatatypeConfigurationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/DatatypeConstants.java b/libjava/classpath/javax/xml/datatype/DatatypeConstants.java
new file mode 100644
index 000000000..1fe439e00
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/DatatypeConstants.java
@@ -0,0 +1,264 @@
+/* DatatypeConstants.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.datatype;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Basic data type constants.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.5
+ */
+public final class DatatypeConstants
+{
+
+ private DatatypeConstants()
+ {
+ // to prevent instantiation
+ }
+
+ /**
+ * Typesafe enumerated class representing the six fields of the
+ * <a href='Duration.html'>Duration</a> class.
+ */
+ public static final class Field
+ {
+
+ final int id;
+ final String name;
+
+ Field(int id, String name)
+ {
+ this.id = id;
+ this.name = name;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ }
+
+ /**
+ * Value for January.
+ */
+ public static final int JANUARY = 1;
+
+ /**
+ * Value for February.
+ */
+ public static final int FEBRUARY = 2;
+
+ /**
+ * Value for March.
+ */
+ public static final int MARCH = 3;
+
+ /**
+ * Value for April.
+ */
+ public static final int APRIL = 4;
+
+ /**
+ * Value for May.
+ */
+ public static final int MAY = 5;
+
+ /**
+ * Value for June.
+ */
+ public static final int JUNE = 6;
+
+ /**
+ * Value for July.
+ */
+ public static final int JULY = 7;
+
+ /**
+ * Value for August.
+ */
+ public static final int AUGUST = 8;
+
+ /**
+ * Value for September.
+ */
+ public static final int SEPTEMBER = 9;
+
+ /**
+ * Value for October.
+ */
+ public static final int OCTOBER = 10;
+
+ /**
+ * Value for November.
+ */
+ public static final int NOVEMBER = 11;
+
+ /**
+ * Value for December.
+ */
+ public static final int DECEMBER = 12;
+
+ /**
+ * Comparison result.
+ */
+ public static final int LESSER = -1;
+
+ /**
+ * Comparison result.
+ */
+ public static final int EQUAL = 0;
+
+ /**
+ * Comparison result.
+ */
+ public static final int GREATER = 1;
+
+ /**
+ * Comparison result.
+ */
+ public static final int INDETERMINATE = 2;
+
+ /**
+ * Comparison result.
+ */
+ public static final int FIELD_UNDEFINED = -2147483648;
+
+ /**
+ * Constant that represents the years field.
+ */
+ public static final Field YEARS = new Field(1, "YEARS");
+
+ /**
+ * Constant that represents the months field.
+ */
+ public static final Field MONTHS = new Field(2, "MONTHS");
+
+ /**
+ * Constant that represents the days field.
+ */
+ public static final Field DAYS = new Field(3, "DAYS");
+
+ /**
+ * Constant that represents the hours field.
+ */
+ public static final Field HOURS = new Field(4, "HOURS");
+
+ /**
+ * Constant that represents the minutes field.
+ */
+ public static final Field MINUTES = new Field(5, "MINUTES");
+
+ /**
+ * Constant that represents the seconds field.
+ */
+ public static final Field SECONDS = new Field(6, "SECONDS");
+
+ /**
+ * The qualified-name for the <code>dateTime</code> data type.
+ */
+ public static final QName DATETIME = new QName ("http://www.w3.org/2001/XMLSchema#dateTime", "");
+
+ /**
+ * The qualified-name for the <code>time</code> data type.
+ */
+ public static final QName TIME = new QName ("http://www.w3.org/2001/XMLSchema#time", "");
+
+ /**
+ * The qualified-name for the <code>date</code> data type.
+ */
+ public static final QName DATE = new QName ("http://www.w3.org/2001/XMLSchema#date", "");
+
+ /**
+ * The qualified-name for the <code>gYearMonth</code> data type.
+ */
+ public static final QName GYEARMONTH = new QName ("http://www.w3.org/2001/XMLSchema#gYearMonth", "");
+
+ /**
+ * The qualified-name for the <code>gMonthDay</code> data type.
+ */
+ public static final QName GMONTHDAY = new QName ("http://www.w3.org/2001/XMLSchema#gMonthDay", "");
+
+ /**
+ * The qualified-name for the <code>gYear</code> data type.
+ */
+ public static final QName GYEAR = new QName ("http://www.w3.org/2001/XMLSchema#gYear", "");
+
+ /**
+ * The qualified-name for the <code>gMonth</code> data type.
+ */
+ public static final QName GMONTH = new QName ("http://www.w3.org/2001/XMLSchema#gMonth", "");
+
+ /**
+ * The qualified-name for the <code>gDay</code> data type.
+ */
+ public static final QName GDAY = new QName ("http://www.w3.org/2001/XMLSchema#gDay", "");
+
+ /**
+ * The qualified-name for the <code>duration</code> data type.
+ */
+ public static final QName DURATION = new QName ("http://www.w3.org/2001/XMLSchema#duration", "");
+
+ /**
+ * The qualified-name for the <code>dayTimeDuration</code> data type.
+ */
+ public static final QName DURATION_DAYTIME = new QName ("http://www.w3.org/2001/XMLSchema#dayTimeDuration", "");
+
+ /**
+ * The qualified-name for the <code>yearMonthDuration</code> data type.
+ */
+ public static final QName DURATION_YEARMONTH = new QName ("http://www.w3.org/2001/XMLSchema#yearMonthDuration", "");
+
+ /**
+ * XML Schema maximum timezone offset, in minutes.
+ */
+ public static final int MAX_TIMEZONE_OFFSET = -840;
+
+ /**
+ * XML Schema minimum timezone offset, in minutes.
+ */
+ public static final int MIN_TIMEZONE_OFFSET = 840;
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/DatatypeFactory.java b/libjava/classpath/javax/xml/datatype/DatatypeFactory.java
new file mode 100644
index 000000000..924a610c1
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/DatatypeFactory.java
@@ -0,0 +1,421 @@
+/* DatatypeFactory.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.datatype;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.ServiceLoader;
+
+/**
+ * Factory class to create new datatype objects mapping XML to and from Java
+ * objects.
+ *
+ * @author Chris Burdess
+ * @since 1.5
+ */
+public abstract class DatatypeFactory
+{
+
+ /**
+ * JAXP 1.3 default property name.
+ */
+ public static final String DATATYPEFACTORY_PROPERTY = "javax.xml.datatype.DatatypeFactory";
+
+ /**
+ * JAXP 1.3 default implementation class name.
+ */
+ public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS = "gnu.xml.datatype.JAXPDatatypeFactory";
+
+ protected DatatypeFactory()
+ {
+ }
+
+ /**
+ * Returns a new factory instance.
+ */
+ public static DatatypeFactory newInstance()
+ throws DatatypeConfigurationException
+ {
+ try
+ {
+ // 1. system property
+ String className = System.getProperty(DATATYPEFACTORY_PROPERTY);
+ if (className != null)
+ return (DatatypeFactory) Class.forName(className).newInstance();
+ // 2. jaxp.properties property
+ File javaHome = new File(System.getProperty("java.home"));
+ File javaHomeLib = new File(javaHome, "lib");
+ File jaxpProperties = new File(javaHomeLib, "jaxp.properties");
+ if (jaxpProperties.exists())
+ {
+ FileInputStream in = new FileInputStream(jaxpProperties);
+ Properties p = new Properties();
+ p.load(in);
+ in.close();
+ className = p.getProperty(DATATYPEFACTORY_PROPERTY);
+ if (className != null)
+ return (DatatypeFactory) Class.forName(className).newInstance();
+ }
+ // 3. services
+ Iterator<DatatypeFactory> i = ServiceLoader.load(DatatypeFactory.class).iterator();
+ if (i.hasNext())
+ return i.next();
+ // 4. fallback
+ Class<?> t = Class.forName(DATATYPEFACTORY_IMPLEMENTATION_CLASS);
+ return (DatatypeFactory) t.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new DatatypeConfigurationException(e);
+ }
+ }
+
+ /**
+ * Returns a new duration from its string representation.
+ * @param lexicalRepresentation the lexical representation of the
+ * duration, as specified in XML Schema 1.0 section 3.2.6.1.
+ */
+ public abstract Duration newDuration(String lexicalRepresentation);
+
+ /**
+ * Returns a new duration.
+ * @param durationInMilliSeconds the duration in milliseconds
+ */
+ public abstract Duration newDuration(long durationInMilliSeconds);
+
+ /**
+ * Returns a new duration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param years the number of years
+ * @param months the number of months
+ * @param days the number of days
+ * @param hours the number of hours
+ * @param minutes th number of minutes
+ * @param seconds the number of seconds
+ */
+ public abstract Duration newDuration(boolean isPositive,
+ BigInteger years,
+ BigInteger months,
+ BigInteger days,
+ BigInteger hours,
+ BigInteger minutes,
+ BigDecimal seconds);
+
+ /**
+ * Returns a new duration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param years the number of years
+ * @param months the number of months
+ * @param days the number of days
+ * @param hours the number of hours
+ * @param minutes th number of minutes
+ * @param seconds the number of seconds
+ */
+ public Duration newDuration(boolean isPositive,
+ int years,
+ int months,
+ int days,
+ int hours,
+ int minutes,
+ int seconds)
+ {
+ return newDuration(isPositive,
+ BigInteger.valueOf((long) years),
+ BigInteger.valueOf((long) months),
+ BigInteger.valueOf((long) days),
+ BigInteger.valueOf((long) hours),
+ BigInteger.valueOf((long) minutes),
+ BigDecimal.valueOf((long) seconds));
+ }
+
+ /**
+ * Returns a new dayTimeDuration from its string representation.
+ * @param lexicalRepresentation the lexical representation of the
+ * duration, as specified in XML Schema 1.0 section 3.2.6.1.
+ */
+ public Duration newDurationDayTime(String lexicalRepresentation)
+ {
+ return newDuration(lexicalRepresentation);
+ }
+
+ /**
+ * Returns a new dayTimeDuration.
+ * @param durationInMilliseconds the duration in milliseconds
+ */
+ public Duration newDurationDayTime(long durationInMilliseconds)
+ {
+ // TODO xmlSchemaType
+ return newDuration(durationInMilliseconds);
+ }
+
+ /**
+ * Returns a new dayTimeDuration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param days the number of days
+ * @param hours the number of hours
+ * @param minutes th number of minutes
+ * @param seconds the number of seconds
+ */
+ public Duration newDurationDayTime(boolean isPositive,
+ BigInteger days,
+ BigInteger hours,
+ BigInteger minutes,
+ BigInteger seconds)
+ {
+ return newDuration(isPositive,
+ null,
+ null,
+ days,
+ hours,
+ minutes,
+ new BigDecimal(seconds));
+ }
+
+ /**
+ * Returns a new dayTimeDuration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param days the number of days
+ * @param hours the number of hours
+ * @param minutes th number of minutes
+ * @param seconds the number of seconds
+ */
+ public Duration newDurationDayTime(boolean isPositive,
+ int days,
+ int hours,
+ int minutes,
+ int seconds)
+ {
+ return newDuration(isPositive,
+ null,
+ null,
+ BigInteger.valueOf((long) days),
+ BigInteger.valueOf((long) hours),
+ BigInteger.valueOf((long) minutes),
+ BigDecimal.valueOf((long) seconds));
+ }
+
+ /**
+ * Returns a new yearMonthDuration from its string representation.
+ * @param lexicalRepresentation the lexical representation of the
+ * duration, as specified in XML Schema 1.0 section 3.2.6.1.
+ */
+ public Duration newDurationYearMonth(String lexicalRepresentation)
+ {
+ return newDuration(lexicalRepresentation);
+ }
+
+ /**
+ * Returns a new yearMonthDuration.
+ * @param durationInMilliseconds the duration in milliseconds
+ */
+ public Duration newDurationYearMonth(long durationInMilliseconds)
+ {
+ // TODO xmlSchemaType
+ return newDuration(durationInMilliseconds);
+ }
+
+ /**
+ * Returns a new yearMonthDuration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param years the number of years
+ * @param months the number of months
+ */
+ public Duration newDurationYearMonth(boolean isPositive,
+ BigInteger years,
+ BigInteger months)
+ {
+ return newDuration(isPositive,
+ years,
+ months,
+ null,
+ null,
+ null,
+ null);
+ }
+
+ /**
+ * Returns a new yearMonthDuration by specifying the individual components.
+ * @param isPositive whether the duration is positive
+ * @param years the number of years
+ * @param months the number of months
+ */
+ public Duration newDurationYearMonth(boolean isPositive,
+ int years,
+ int months)
+ {
+ return newDuration(isPositive,
+ BigInteger.valueOf((long) years),
+ BigInteger.valueOf((long) months),
+ null,
+ null,
+ null,
+ null);
+ }
+
+ /**
+ * Returns a new XMLGregorianCalendar with no fields initialized.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar();
+
+ /**
+ * Returns a new XMLGregorianCalendar from a string representation.
+ * @param lexicalRepresentation the lexical representation as specified in
+ * XML Schema 1.0 Part 2, section 3.2.[7-14].1.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(String lexicalRepresentation);
+
+ /**
+ * Returns a new XMLGregorianCalendar based on the specified Gregorian
+ * calendar.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(GregorianCalendar cal);
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public abstract XMLGregorianCalendar newXMLGregorianCalendar(BigInteger year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fractionalSecond,
+ int timezone);
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendar(int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ int millisecond,
+ int timezone)
+ {
+ return newXMLGregorianCalendar(BigInteger.valueOf((long) year),
+ month,
+ day,
+ hour,
+ minute,
+ second,
+ new BigDecimal(((double) millisecond) / 1000.0),
+ timezone);
+ }
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarDate(int year,
+ int month,
+ int day,
+ int timezone)
+ {
+ return newXMLGregorianCalendar(BigInteger.valueOf((long) year),
+ month,
+ day,
+ DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED,
+ null,
+ timezone);
+ }
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
+ int minutes,
+ int seconds,
+ int timezone)
+ {
+ return newXMLGregorianCalendar(null,
+ DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED,
+ hours,
+ minutes,
+ seconds,
+ null,
+ timezone);
+ }
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
+ int minutes,
+ int seconds,
+ BigDecimal fractionalSecond,
+ int timezone)
+ {
+ return newXMLGregorianCalendar(null,
+ DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED,
+ hours,
+ minutes,
+ seconds,
+ fractionalSecond,
+ timezone);
+ }
+
+ /**
+ * Returns a new XMLGregorianCalendar with the specified components.
+ */
+ public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
+ int minutes,
+ int seconds,
+ int milliseconds,
+ int timezone)
+ {
+ return newXMLGregorianCalendar(null,
+ DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED,
+ hours,
+ minutes,
+ seconds,
+ new BigDecimal(((double) milliseconds) / 1000.0),
+ timezone);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/Duration.java b/libjava/classpath/javax/xml/datatype/Duration.java
new file mode 100644
index 000000000..7f53021ce
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/Duration.java
@@ -0,0 +1,291 @@
+/* Duration.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.datatype;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.namespace.QName;
+
+/**
+ * An immutable time space as specified in XML Schema 1.0.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.5
+ */
+public abstract class Duration
+{
+
+ /**
+ * Returns the name of the XML Schema data type this value maps to.
+ */
+ public QName getXMLSchemaType()
+ {
+ int state = 0;
+ state |= isSet(DatatypeConstants.YEARS) ? 32 : 0;
+ state |= isSet(DatatypeConstants.MONTHS) ? 16 : 0;
+ state |= isSet(DatatypeConstants.DAYS) ? 8 : 0;
+ state |= isSet(DatatypeConstants.HOURS) ? 4 : 0;
+ state |= isSet(DatatypeConstants.MINUTES) ? 2 : 0;
+ state |= isSet(DatatypeConstants.SECONDS) ? 1 : 0;
+ switch (state)
+ {
+ case 63:
+ return DatatypeConstants.DURATION;
+ case 15:
+ return DatatypeConstants.DURATION_DAYTIME;
+ case 48:
+ return DatatypeConstants.DURATION_YEARMONTH;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * Returns the sign of this value.
+ */
+ public abstract int getSign();
+
+ /**
+ * Returns the years in this duration as an int, or 0 if not present.
+ */
+ public int getYears()
+ {
+ Number val = getField(DatatypeConstants.YEARS);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the months in this duration as an int, or 0 if not present.
+ */
+ public int getMonths()
+ {
+ Number val = getField(DatatypeConstants.MONTHS);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the days in this duration as an int, or 0 if not present.
+ */
+ public int getDays()
+ {
+ Number val = getField(DatatypeConstants.DAYS);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the hours in this duration as an int, or 0 if not present.
+ */
+ public int getHours()
+ {
+ Number val = getField(DatatypeConstants.HOURS);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the minutes in this duration as an int, or 0 if not present.
+ */
+ public int getMinutes()
+ {
+ Number val = getField(DatatypeConstants.MINUTES);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the seconds in this duration as an int, or 0 if not present.
+ */
+ public int getSeconds()
+ {
+ Number val = getField(DatatypeConstants.SECONDS);
+ return (val == null) ? 0 : val.intValue();
+ }
+
+ /**
+ * Returns the duration length in milliseconds.
+ * Because the length of a month or year may vary depending on the year,
+ * the <code>startInstant</code> parameter is used to specify the duration
+ * offset.
+ */
+ public long getTimeInMillis(Calendar startInstant)
+ {
+ Calendar cal = (Calendar) startInstant.clone();
+ long t1 = cal.getTimeInMillis();
+ addTo(cal);
+ long t2 = cal.getTimeInMillis();
+ return t2 - t1;
+ }
+
+ /**
+ * Returns the duration length in milliseconds.
+ * Because the length of a month or year may vary depending on the year,
+ * the <code>startInstant</code> parameter is used to specify the duration
+ * offset.
+ */
+ public long getTimeInMillis(Date startInstant)
+ {
+ Date date = (Date) startInstant.clone();
+ long t1 = date.getTime();
+ addTo(date);
+ long t2 = date.getTime();
+ return t2 - t1;
+ }
+
+ /**
+ * Returns the value of the specified field, or <code>null</code> if the
+ * field is undefined.
+ */
+ public abstract Number getField(DatatypeConstants.Field field);
+
+ /**
+ * Indicates whether the specified field is set.
+ */
+ public abstract boolean isSet(DatatypeConstants.Field field);
+
+ /**
+ * Returns the result of adding the specified duration to this duration.
+ */
+ public abstract Duration add(Duration rhs);
+
+ /**
+ * Adds this duration to the specified calendar.
+ */
+ public abstract void addTo(Calendar calendar);
+ /*{
+ switch (getSign())
+ {
+ case -1:
+ calendar.add(Calendar.YEAR, -getYears());
+ calendar.add(Calendar.MONTH, -getMonths());
+ calendar.add(Calendar.DATE, -getDays());
+ calendar.add(Calendar.HOUR, -getHours());
+ calendar.add(Calendar.MINUTE, -getMinutes());
+ calendar.add(Calendar.SECOND, -getSeconds());
+ break;
+ case 1:
+ calendar.add(Calendar.YEAR, getYears());
+ calendar.add(Calendar.MONTH, getMonths());
+ calendar.add(Calendar.DATE, getDays());
+ calendar.add(Calendar.HOUR, getHours());
+ calendar.add(Calendar.MINUTE, getMinutes());
+ calendar.add(Calendar.SECOND, getSeconds());
+ }
+ }*/
+
+ /**
+ * Adds this duration to the specified date.
+ */
+ public void addTo(Date date)
+ {
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTimeInMillis(date.getTime());
+ addTo(calendar);
+ date.setTime(calendar.getTimeInMillis());
+ }
+
+ /**
+ * Returns the result of subtracting the given duration from this
+ * duration.
+ */
+ public Duration subtract(Duration rhs)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the result of multiplying this duration by the given factor.
+ */
+ public Duration multiply(int factor)
+ {
+ return multiply(BigDecimal.valueOf((long) factor));
+ }
+
+ /**
+ * Returns the result of multiplying this duration by the given factor.
+ */
+ public abstract Duration multiply(BigDecimal factor);
+
+ /**
+ * Returns the unary negative of this duration.
+ */
+ public abstract Duration negate();
+
+ /**
+ * Converts the years and months fields into the days field using a
+ * specific time instant as the reference point.
+ */
+ public abstract Duration normalizeWith(Calendar startTimeInstant);
+
+ /**
+ * Partial order relation comparison with this duration, in accordance
+ * with XML Schema 1.0 Part 2, Section 3.2.7.6.2.
+ */
+ public abstract int compare(Duration duration);
+
+ public boolean isLongerThan(Duration duration)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isShorterThan(Duration duration)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(java.lang.Object duration)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract int hashCode();
+
+ /**
+ * Returns the lexical representation of this duration.
+ */
+ public String toString()
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/XMLGregorianCalendar.java b/libjava/classpath/javax/xml/datatype/XMLGregorianCalendar.java
new file mode 100644
index 000000000..a8a9272e0
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/XMLGregorianCalendar.java
@@ -0,0 +1,217 @@
+/* XMLGregorianCalendar.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.datatype;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+import javax.xml.namespace.QName;
+
+/**
+ * An XML Schema 1.0 date/time data type.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class XMLGregorianCalendar
+ implements Cloneable
+{
+
+ /**
+ * Resets all fields to undefined.
+ */
+ public abstract void clear();
+
+ /**
+ * Resets all fields to their original values.
+ */
+ public abstract void reset();
+
+ public abstract void setYear(BigInteger year);
+
+ public abstract void setYear(int year);
+
+ public abstract void setMonth(int month);
+
+ public abstract void setDay(int day);
+
+ public abstract void setTimezone(int offset);
+
+ public void setTime(int hour, int minute, int second)
+ {
+ setHour(hour);
+ setMinute(minute);
+ setSecond(second);
+ }
+
+ public abstract void setHour(int hour);
+
+ public abstract void setMinute(int minute);
+
+ public abstract void setSecond(int second);
+
+ public abstract void setMillisecond(int millisecond);
+
+ public abstract void setFractionalSecond(BigDecimal fractional);
+
+ public void setTime(int hour, int minute, int second, BigDecimal fractional)
+ {
+ setHour(hour);
+ setMinute(minute);
+ setSecond(second);
+ setFractionalSecond(fractional);
+ }
+
+ public void setTime(int hour, int minute, int second, int millisecond)
+ {
+ setHour(hour);
+ setMinute(minute);
+ setSecond(second);
+ setMillisecond(millisecond);
+ }
+
+ public abstract BigInteger getEon();
+
+ public abstract int getYear();
+
+ public abstract BigInteger getEonAndYear();
+
+ public abstract int getMonth();
+
+ public abstract int getDay();
+
+ public abstract int getTimezone();
+
+ public abstract int getHour();
+
+ public abstract int getMinute();
+
+ public abstract int getSecond();
+
+ public int getMillisecond()
+ {
+ BigDecimal factor = BigDecimal.valueOf(1000L);
+ BigDecimal val = getFractionalSecond().multiply(factor);
+ return val.intValue();
+ }
+
+ public abstract BigDecimal getFractionalSecond();
+
+ public abstract int compare(XMLGregorianCalendar xmlGregorianCalendar);
+
+ public abstract XMLGregorianCalendar normalize();
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof XMLGregorianCalendar)
+ {
+ XMLGregorianCalendar xgc = (XMLGregorianCalendar) obj;
+ BigInteger y1 = getEonAndYear();
+ BigInteger y2 = xgc.getEonAndYear();
+ BigDecimal f1 = getFractionalSecond();
+ BigDecimal f2 = xgc.getFractionalSecond();
+ return ((y1 == null && y2 == null) || (y1 != null && y1.equals(y2))) &&
+ getMonth() == xgc.getMonth() &&
+ getDay() == xgc.getDay() &&
+ getTimezone() == xgc.getTimezone() &&
+ getHour() == xgc.getHour() &&
+ getMinute() == xgc.getMinute() &&
+ getSecond() == xgc.getSecond() &&
+ ((f1 == null && f2 == null) || (f1 != null && f1.equals(f2)));
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int hash = 0;
+ BigInteger y = getEonAndYear();
+ BigDecimal f = getFractionalSecond();
+ if (y != null)
+ {
+ hash *= 31 + y.hashCode();
+ }
+ hash *= 31 + getMonth();
+ hash *= 31 + getDay();
+ hash *= 31 + getTimezone();
+ hash *= 31 + getHour();
+ hash *= 31 + getMinute();
+ hash *= 31 + getSecond();
+ if (f != null)
+ {
+ hash *= 31 + f.hashCode();
+ }
+ return hash;
+ }
+
+ /**
+ * Returns the XML Schema lexical representation of this calendar.
+ */
+ public abstract String toXMLFormat();
+
+ public abstract QName getXMLSchemaType();
+
+ public String toString()
+ {
+ return toXMLFormat();
+ }
+
+ /**
+ * Determines the validity of this calendar by
+ * <code>getXMLSchemaType</code> constraints.
+ */
+ public abstract boolean isValid();
+
+ /**
+ * Adds the specified duration to this calendar.
+ */
+ public abstract void add(Duration duration);
+
+ public abstract GregorianCalendar toGregorianCalendar();
+
+ public abstract GregorianCalendar toGregorianCalendar(TimeZone timezone,
+ Locale locale,
+ XMLGregorianCalendar defaults);
+
+ public abstract TimeZone getTimeZone(int defaultZoneoffset);
+
+ public abstract Object clone();
+
+}
diff --git a/libjava/classpath/javax/xml/datatype/package.html b/libjava/classpath/javax/xml/datatype/package.html
new file mode 100644
index 000000000..ffd850c04
--- /dev/null
+++ b/libjava/classpath/javax/xml/datatype/package.html
@@ -0,0 +1,57 @@
+<body>
+
+<div>
+This package provides type mappings between XML and Java data types.
+</div>
+
+<table summary='XML Schema type mappings'>
+ <tr>
+ <th>XML Schema data type</th><th>Java data type</th>
+ </tr>
+ <tr>
+ <td>xs:date</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:dateTime</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:duration</td><td><a href='Duration.html'>Duration</a></td>
+ </tr>
+ <tr>
+ <td>xs:gDay</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:gMonth</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:gMonthDay</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:gYear</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:gYearMonth</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+ <tr>
+ <td>xs:time</td><td><a href='XMLGregorianCalendar.html'>XMLGregorianCalendar</a></td>
+ </tr>
+</table>
+
+<table summary='XPath 2.0 data type mappings'>
+ <tr>
+ <th>XPath 2.0 data type</th><th>Java data type</th>
+ </tr>
+ <tr>
+ <td>xdt:dayTimeDuration</td><td><a href='Duration.html'>Duration</a></td>
+ </tr>
+ <tr>
+ <td>xdt:yearMonthDuration</td><td><a href='Duration.html'>Duration</a></td>
+ </tr>
+</table>
+
+<div>
+Other XML Schema data types are considered to have a <q>natural</q> mapping to
+Java types, which are defined by the Java Architecture for XML Binding (JAXB).
+</div>
+
+</body>
diff --git a/libjava/classpath/javax/xml/namespace/NamespaceContext.java b/libjava/classpath/javax/xml/namespace/NamespaceContext.java
new file mode 100644
index 000000000..b3e1e1f61
--- /dev/null
+++ b/libjava/classpath/javax/xml/namespace/NamespaceContext.java
@@ -0,0 +1,67 @@
+/* NamespaceContext.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.namespace;
+
+import java.util.Iterator;
+
+/**
+ * Interface by which namespace properties are made available.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public interface NamespaceContext
+{
+
+ /**
+ * Returns the namespace URI currently bound to the given prefix.
+ */
+ public String getNamespaceURI(String prefix);
+
+ /**
+ * Returns the prefix currently bound to the given namespace URI.
+ */
+ public String getPrefix(String namespaceURI);
+
+ /**
+ * Returns all the prefixes currently bound to the given namespace URI.
+ */
+ @SuppressWarnings("unchecked")
+ public Iterator getPrefixes(String namespaceURI);
+
+}
diff --git a/libjava/classpath/javax/xml/namespace/QName.java b/libjava/classpath/javax/xml/namespace/QName.java
new file mode 100644
index 000000000..4033febfc
--- /dev/null
+++ b/libjava/classpath/javax/xml/namespace/QName.java
@@ -0,0 +1,173 @@
+/* QName.java - An XML qualified name.
+ Copyright (C) 2004,2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.xml.namespace;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.Serializable;
+
+import javax.xml.XMLConstants;
+
+/**
+ * An XML
+ * <a href='http://www.w3.org/TR/REC-xml-names/#ns-qualnames'>qualified name</a>.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ * @since 1.3
+ */
+public class QName implements Serializable
+{
+ private static final long serialVersionUID = 4418622981026545151L;
+
+ private final String namespaceURI;
+ private final String localPart;
+ private final String prefix;
+ private transient String qName;
+ transient int hashCode = -1;
+
+ public QName(String namespaceURI, String localPart)
+ {
+ this(namespaceURI, localPart, null);
+ }
+
+ public QName(String namespaceURI, String localPart, String prefix)
+ {
+ if (namespaceURI == null)
+ namespaceURI = XMLConstants.NULL_NS_URI;
+ if (localPart == null)
+ throw new IllegalArgumentException();
+ if (prefix == null)
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+ else
+ {
+ if (XMLConstants.XML_NS_PREFIX.equals(prefix))
+ namespaceURI = XMLConstants.XML_NS_URI;
+ else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))
+ namespaceURI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ }
+ this.namespaceURI = namespaceURI;
+ this.localPart = localPart;
+ this.prefix = prefix;
+ }
+
+ public QName(String localPart)
+ {
+ this(null, localPart, null);
+ }
+
+ public String getNamespaceURI()
+ {
+ return namespaceURI;
+ }
+
+ public String getLocalPart()
+ {
+ return localPart;
+ }
+
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ public final boolean equals(Object obj)
+ {
+ if (obj instanceof QName)
+ {
+ QName qname = (QName) obj;
+ return qname.getLocalPart().equals(localPart) &&
+ qname.getNamespaceURI().equals(namespaceURI);
+ }
+ return false;
+ }
+
+ public final int hashCode()
+ {
+ if (hashCode == -1)
+ hashCode = localPart.hashCode() ^ namespaceURI.hashCode();
+ return hashCode;
+ }
+
+ public synchronized String toString()
+ {
+ if (qName == null)
+ {
+ CPStringBuilder buf = new CPStringBuilder();
+ if (namespaceURI.length() > 0)
+ {
+ buf.append('{');
+ buf.append(namespaceURI);
+ buf.append('}');
+ }
+ if (prefix.length() > 0)
+ {
+ buf.append(prefix);
+ buf.append(':');
+ }
+ buf.append(localPart);
+ qName = buf.toString();
+ }
+ return qName;
+ }
+
+ public static QName valueOf(String qNameAsString)
+ {
+ if (qNameAsString == null)
+ throw new IllegalArgumentException("qNameAsString can't be null");
+
+ String namespaceUri = "", prefix = null;
+ int start = qNameAsString.indexOf('{');
+ int end = qNameAsString.indexOf('}');
+ if (start != -1)
+ {
+ if (end < start)
+ throw new IllegalArgumentException(qNameAsString);
+ namespaceUri = qNameAsString.substring(start + 1, end);
+ qNameAsString = qNameAsString.substring(end + 1);
+ }
+ start = qNameAsString.indexOf(':');
+ if (start != -1)
+ {
+ prefix = qNameAsString.substring(0, start);
+ qNameAsString = qNameAsString.substring(start + 1);
+ }
+ return new QName(namespaceUri, qNameAsString, prefix);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/namespace/package.html b/libjava/classpath/javax/xml/namespace/package.html
new file mode 100644
index 000000000..00929f8a0
--- /dev/null
+++ b/libjava/classpath/javax/xml/namespace/package.html
@@ -0,0 +1,9 @@
+<html>
+<body>
+
+<div>
+<a href='http://www.w3.org/TR/REC-xml-names'>XML Namespace</a> processing.
+</div>
+
+</body>
+</html>
diff --git a/libjava/classpath/javax/xml/parsers/DocumentBuilder.java b/libjava/classpath/javax/xml/parsers/DocumentBuilder.java
new file mode 100644
index 000000000..8e4eccbb0
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/DocumentBuilder.java
@@ -0,0 +1,203 @@
+/* DocumentBuilder.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import javax.xml.validation.Schema;
+import org.w3c.dom.Document;
+import org.w3c.dom.DOMImplementation;
+import org.xml.sax.InputSource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Convenience class for parsing an XML document into a W3C DOM object
+ * graph.
+ * Instances of this class are <em>not</em> guaranteed to be thread safe.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class DocumentBuilder
+{
+
+ protected DocumentBuilder()
+ {
+ }
+
+ /**
+ * Parse the specified input stream and return a DOM Document.
+ * Prefer the version of this method that specifies a system ID, in order
+ * to resolve external references correctly.
+ * @param is an XML input stream
+ * @exception IllegalArgumentException if the input stream is null
+ */
+ public Document parse(InputStream is)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ return parse(new InputSource(is));
+ }
+
+ /**
+ * Parse the specified input stream and return a DOM Document.
+ * @param is an XML input stream
+ * @param systemId the system ID of the XML document
+ * @exception IllegalArgumentException if the input stream is null
+ */
+ public Document parse(InputStream is, String systemId)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ InputSource source = new InputSource(is);
+ source.setSystemId(systemId);
+ return parse(source);
+ }
+
+ /**
+ * Parse the content of the specified URI and return a DOM Document.
+ * @param uri an XML system ID
+ * @exception IllegalArgumentException if the URI is null
+ */
+ public Document parse(String uri)
+ throws SAXException, IOException
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("URI is null");
+ }
+ return parse(new InputSource(uri));
+ }
+
+ /**
+ * Parse the specified file and return a DOM Document.
+ * @param f the XML file
+ * @exception IllegalArgumentException if the file is null
+ */
+ public Document parse(File f)
+ throws SAXException, IOException
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("file is null");
+ }
+ InputSource source = new InputSource(new FileInputStream(f));
+ source.setSystemId(f.toURL().toString());
+ return parse(source);
+ }
+
+ /**
+ * Parse the specified input source and return a DOM Document.
+ * @param source the input source
+ * @exception IllegalArgumentException if the input source is null
+ */
+ public abstract Document parse(InputSource source)
+ throws SAXException, IOException;
+
+ /**
+ * Indicates whether this document builder is XML Namespace aware.
+ */
+ public abstract boolean isNamespaceAware();
+
+ /**
+ * Indicates whether this document builder will validate its input.
+ */
+ public abstract boolean isValidating();
+
+ /**
+ * Sets the SAX entity resolver callback used to resolve external entities
+ * in the XML document(s) to parse.
+ * @param er an entity resolver
+ */
+ public abstract void setEntityResolver(EntityResolver er);
+
+ /**
+ * Sets the SAX error handler callback used to report parsing errors.
+ * @param eh the error handler
+ */
+ public abstract void setErrorHandler(ErrorHandler eh);
+
+ /**
+ * Creates a new, empty DOM Document.
+ * To create a document with a root element and optional doctype, use the
+ * <code>DOMImplementation</code> instead.
+ * @see org.w3c.dom.DOMImplementation#createDocument
+ */
+ public abstract Document newDocument();
+
+ /**
+ * Returns the DOM implementation.
+ */
+ public abstract DOMImplementation getDOMImplementation();
+
+ // -- JAXP 1.3 methods --
+
+ /**
+ * Reset this document builder to its original configuration.
+ * @since 1.3
+ */
+ public void reset()
+ {
+ }
+
+ /**
+ * Returns the schema in use by the XML processor.
+ */
+ public Schema getSchema()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the XInclude processing mode in use by the parser.
+ */
+ public boolean isXIncludeAware()
+ {
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java b/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java
new file mode 100644
index 000000000..5f8b49d7c
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/DocumentBuilderFactory.java
@@ -0,0 +1,369 @@
+/* DocumentBuilderFactory.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Properties;
+import javax.xml.validation.Schema;
+
+/**
+ * Factory for obtaining document builders.
+ * Instances of this class are <em>not</em> guaranteed to be thread safe.
+ *
+ * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
+ */
+public abstract class DocumentBuilderFactory
+{
+
+ private boolean namespaceAware;
+ private boolean validating;
+ private boolean ignoringElementContentWhitespace;
+ private boolean expandEntityReferences = true;
+ private boolean ignoringComments;
+ private boolean coalescing;
+ private Schema schema;
+ private boolean xIncludeAware;
+
+ protected DocumentBuilderFactory()
+ {
+ }
+
+ /**
+ * Creates a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.parsers.DocumentBuilderFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/jaxp.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ public static DocumentBuilderFactory newInstance()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = DocumentBuilderFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (DocumentBuilderFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.dom.DomDocumentBuilderFactory();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.parsers.DocumentBuilderFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "jaxp.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ DocumentBuilderFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new document builder instance using the currently specified
+ * factory configuration.
+ * @exception ParserConfigurationException if the specified configuration
+ * is not supported
+ */
+ public abstract DocumentBuilder newDocumentBuilder()
+ throws ParserConfigurationException;
+
+ /**
+ * Sets whether document builders obtained from this factory will be XML
+ * Namespace aware.
+ */
+ public void setNamespaceAware(boolean awareness)
+ {
+ namespaceAware = awareness;
+ }
+
+ /**
+ * Sets whether document builders obtained from this factory will validate
+ * their input.
+ */
+ public void setValidating(boolean validating)
+ {
+ this.validating = validating;
+ }
+
+ /**
+ * Sets whether document builders obtained from this factory will
+ * eliminate whitespace within elements that have an element-only content
+ * model.
+ */
+ public void setIgnoringElementContentWhitespace(boolean whitespace)
+ {
+ ignoringElementContentWhitespace = whitespace;
+ }
+
+ /**
+ * Sets whether document builders obtained from this factory will expand
+ * entity reference nodes.
+ */
+ public void setExpandEntityReferences(boolean expandEntityRef)
+ {
+ expandEntityReferences = expandEntityRef;
+ }
+
+ /**
+ * Sets whether document builders obtained from this factory will discard
+ * comment nodes.
+ */
+ public void setIgnoringComments(boolean ignoreComments)
+ {
+ ignoringComments = ignoreComments;
+ }
+
+ /**
+ * Sets whether document builders obtained from this factory will convert
+ * CDATA sections to text nodes and normalize adjacent text nodes into a
+ * single text node.
+ */
+ public void setCoalescing(boolean coalescing)
+ {
+ this.coalescing = coalescing;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will be
+ * XML Namespace aware.
+ */
+ public boolean isNamespaceAware()
+ {
+ return namespaceAware;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will
+ * validate their input.
+ */
+ public boolean isValidating()
+ {
+ return validating;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will
+ * eliminate whitespace within elements that have an element-only content
+ * model.
+ */
+ public boolean isIgnoringElementContentWhitespace()
+ {
+ return ignoringElementContentWhitespace;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will
+ * expand entity reference nodes.
+ */
+ public boolean isExpandEntityReferences()
+ {
+ return expandEntityReferences;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will
+ * discard comment nodes.
+ */
+ public boolean isIgnoringComments()
+ {
+ return ignoringComments;
+ }
+
+ /**
+ * Indicates whether document builders obtained from this factory will
+ * convert CDATA sections to text nodes and normalize adjacent text nodes
+ * into a single text node.
+ */
+ public boolean isCoalescing()
+ {
+ return coalescing;
+ }
+
+ /**
+ * Set the named attribute on the underlying implementation.
+ * @param name the name of the attribute
+ * @param value the new value
+ * @exception IllegalArgumentException if the attribute is not recognized
+ */
+ public abstract void setAttribute(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Retrieves the named attribute value from the underlying implementation.
+ * @param name the name of the attribute
+ * @exception IllegalArgumentException if the attribute is not recognized
+ */
+ public abstract Object getAttribute(String name)
+ throws IllegalArgumentException;
+
+ // -- JAXP 1.3 methods --
+
+ /**
+ * Returns the schema.
+ * @see #setSchema
+ * @since 1.5
+ */
+ public Schema getSchema()
+ {
+ return schema;
+ }
+
+ /**
+ * Sets the schema.
+ * @see #getSchema
+ * @since 1.5
+ */
+ public void setSchema(Schema schema)
+ {
+ this.schema = schema;
+ }
+
+ /**
+ * Indicates whether parsers obtained from this factory will be XInclude
+ * aware.
+ * @since 1.5
+ */
+ public boolean isXIncludeAware()
+ {
+ return xIncludeAware;
+ }
+
+ /**
+ * Sets whether parsers obtained from this factory will be XInclude aware.
+ * @since 1.5
+ */
+ public void setXIncludeAware(boolean state)
+ {
+ xIncludeAware = state;
+ }
+
+ /**
+ * Sets the value of the specified feature.
+ * @param name the feature name (URI)
+ * @param value whether to enable the feature or not
+ * @exception ParserConfigurationException if the feature is not
+ * supported.
+ * @since 1.5
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws ParserConfigurationException;
+
+ /**
+ * Returns the value of the specified feature.
+ * @param name the feature name (URI)
+ * @exception ParserConfigurationException if the feature is not
+ * supported.
+ * @since 1.5
+ */
+ public abstract boolean getFeature(String name)
+ throws ParserConfigurationException;
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/FactoryConfigurationError.java b/libjava/classpath/javax/xml/parsers/FactoryConfigurationError.java
new file mode 100644
index 000000000..6e2ebfadb
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/FactoryConfigurationError.java
@@ -0,0 +1,113 @@
+/* FactoryConfigurationError.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+/**
+ * An error occurred during configuration of the parser factory.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class FactoryConfigurationError
+ extends Error
+{
+
+ /**
+ * The underlying cause of this exception, if any.
+ */
+ private Exception exception;
+
+ /**
+ * Constructor with no detail message.
+ */
+ public FactoryConfigurationError()
+ {
+ super();
+ }
+
+ /**
+ * Constructor with the specified detail message.
+ * @param msg the detail message
+ */
+ public FactoryConfigurationError(String msg)
+ {
+ super(msg);
+ }
+
+ /**
+ * Constructor with the specified underlying cause.
+ * @param e the underlying cause of this exception
+ */
+ public FactoryConfigurationError(Exception e)
+ {
+ super(e);
+ exception = e;
+ }
+
+ /**
+ * Constructor with the specified underlying cause and detail message.
+ * @param e the underlying cause of this exception
+ * @param msg the detail message
+ */
+ public FactoryConfigurationError(Exception e, String msg)
+ {
+ super(msg, e);
+ exception = e;
+ }
+
+ /**
+ * Returns the message for this error, if any.
+ */
+ public String getMessage()
+ {
+ String message = super.getMessage();
+ if (message == null && exception != null)
+ {
+ message = exception.getMessage();
+ }
+ return message;
+ }
+
+ /**
+ * Returns the underlying cause of this exception, if any.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/ParserConfigurationException.java b/libjava/classpath/javax/xml/parsers/ParserConfigurationException.java
new file mode 100644
index 000000000..a58decedb
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/ParserConfigurationException.java
@@ -0,0 +1,66 @@
+/* ParserConfigurationException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+/**
+ * An exception occurred during configuration of the XML parser.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class ParserConfigurationException
+ extends Exception
+{
+
+ /**
+ * Constructor with no detail message.
+ */
+ public ParserConfigurationException()
+ {
+ super();
+ }
+
+ /**
+ * Constructor with the specified detail message.
+ * @param msg the detail message
+ */
+ public ParserConfigurationException(String msg)
+ {
+ super(msg);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/SAXParser.java b/libjava/classpath/javax/xml/parsers/SAXParser.java
new file mode 100644
index 000000000..e53558760
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/SAXParser.java
@@ -0,0 +1,340 @@
+/* SAXParser.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import javax.xml.validation.Schema;
+import org.xml.sax.HandlerBase;
+import org.xml.sax.InputSource;
+import org.xml.sax.Parser;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Convenience class for using or accessing a SAX version 1 or 2 parser.
+ * Instances of this class are <em>not</em> guaranteed to be thread safe.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class SAXParser
+{
+
+ protected SAXParser()
+ {
+ }
+
+ /**
+ * Parse the specifed input stream, reporting SAX1 events to the given
+ * handler.
+ * Prefer the SAX2 version of this method, since the HandlerBase class is
+ * now deprecated.
+ * Also prefer the version of this method that specifies a system ID, in
+ * order to resolve external references correctly.
+ * @param is an XML input stream
+ * @param hb the SAX1 handler
+ * @exception IllegalArgumentException if the input stream is null
+ * @see #parse(java.io.InputStream,org.xml.sax.helpers.DefaultHandler)
+ */
+ public void parse(InputStream is, HandlerBase hb)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ parse(new InputSource(is), hb);
+ }
+
+ /**
+ * Parse the specified input stream, reporting SAX1 events to the given
+ * handler.
+ * Prefer the SAX2 version of this method, since the HandlerBase class is
+ * now deprecated.
+ * @param is an XML input stream
+ * @param hb the SAX1 handler
+ * @param systemId the system ID of the XML document
+ * @exception IllegalArgumentException if the input stream is null
+ * @see #parse(java.io.InputStream,org.xml.sax.helpers.DefaultHandler,java.lang.String)
+ */
+ public void parse(InputStream is, HandlerBase hb, String systemId)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ InputSource source = new InputSource(is);
+ source.setSystemId(systemId);
+ parse(source, hb);
+ }
+
+ /**
+ * Parse the specified input stream, reporting SAX2 events to the given
+ * handler.
+ * Prefer the version of this method that specifies a system ID, in
+ * order to resolve external references correctly.
+ * @param is an XML input stream
+ * @param dh the SAX2 handler
+ * @exception IllegalArgumentException if the input stream is null
+ */
+ public void parse(InputStream is, DefaultHandler dh)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ parse(new InputSource(is), dh);
+ }
+
+ /**
+ * Parse the specified input stream, reporting SAX2 events to the given
+ * handler.
+ * @param is an XML input stream
+ * @param dh the SAX2 handler
+ * @param systemId the system ID of the XML document
+ * @exception IllegalArgumentException if the input stream is null
+ */
+ public void parse (InputStream is, DefaultHandler dh, String systemId)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input stream is null");
+ }
+ InputSource source = new InputSource(is);
+ source.setSystemId(systemId);
+ parse(source, dh);
+ }
+
+ /**
+ * Parse the content of the specified URI, reporting SAX1 events to the
+ * given handler.
+ * Prefer the SAX2 version of this method, since the HandlerBase class is
+ * now deprecated.
+ * @param uri an XML system ID
+ * @param hb the SAX1 handler
+ * @exception IllegalArgumentException if the URI is null
+ * @see #parse(java.lang.String,org.xml.sax.helpers.DefaultHandler)
+ */
+ public void parse(String uri, HandlerBase hb)
+ throws SAXException, IOException
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("URI is null");
+ }
+ parse(new InputSource(uri), hb);
+ }
+
+ /**
+ * Parse the content of the specified URI, reporting SAX2 events to the
+ * given handler.
+ * @param uri an XML system ID
+ * @param dh the SAX2 handler
+ * @exception IllegalArgumentException if the URI is null
+ */
+ public void parse(String uri, DefaultHandler dh)
+ throws SAXException, IOException
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("URI is null");
+ }
+ parse(new InputSource(uri), dh);
+ }
+
+ /**
+ * Parse the content of the specified file, reporting SAX1 events to the
+ * given handler.
+ * Prefer the SAX2 version of this method, since the HandlerBase class is
+ * now deprecated.
+ * @param f an XML file
+ * @param hb the SAX1 handler
+ * @exception IllegalArgumentException if the file is null
+ * @see #parse(java.io.File,org.xml.sax.helpers.DefaultHandler)
+ */
+ public void parse(File f, HandlerBase hb)
+ throws SAXException, IOException
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("file is null");
+ }
+ InputSource source = new InputSource(new FileInputStream(f));
+ source.setSystemId(f.toURL().toString());
+ parse(source, hb);
+ }
+
+ /**
+ * Parse the content of the specified file, reporting SAX2 events to the
+ * given handler.
+ * @param f an XML file
+ * @param dh the SAX2 handler
+ * @exception IllegalArgumentException if the file is null
+ */
+ public void parse(File f, DefaultHandler dh)
+ throws SAXException, IOException
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("file is null");
+ }
+ InputSource source = new InputSource(new FileInputStream(f));
+ source.setSystemId(f.toURL().toString());
+ parse(source, dh);
+ }
+
+ /**
+ * Parse the specified input source, reporting SAX1 events to the
+ * given handler.
+ * Prefer the SAX2 version of this method, since the HandlerBase class is
+ * now deprecated.
+ * @param is the SAX input source
+ * @param hb the SAX1 handler
+ * @exception IllegalArgumentException if the input source is null
+ * @see #parse(org.xml.sax.InputSource,org.xml.sax.helpers.DefaultHandler)
+ */
+ public void parse(InputSource is, HandlerBase hb)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input source is null");
+ }
+ Parser parser = getParser();
+ parser.setDocumentHandler(hb);
+ parser.setDTDHandler(hb);
+ parser.setEntityResolver(hb);
+ parser.setErrorHandler(hb);
+ parser.parse(is);
+ }
+
+ /**
+ * Parse the specified input source, reporting SAX2 events to the
+ * given handler.
+ * @param is an XML file
+ * @param dh the SAX2 handler
+ * @exception IllegalArgumentException if the input source is null
+ */
+ public void parse(InputSource is, DefaultHandler dh)
+ throws SAXException, IOException
+ {
+ if (is == null)
+ {
+ throw new IllegalArgumentException("input source is null");
+ }
+ XMLReader reader = getXMLReader();
+ reader.setContentHandler(dh);
+ reader.setDTDHandler(dh);
+ reader.setEntityResolver(dh);
+ reader.setErrorHandler(dh);
+ reader.parse(is);
+ }
+
+ /**
+ * Returns the underlying SAX1 parser.
+ */
+ public abstract Parser getParser() throws SAXException;
+
+ /**
+ * Returns the underlying SAX2 parser.
+ * @since 1.1
+ */
+ public abstract XMLReader getXMLReader() throws SAXException;
+
+ /**
+ * Indicates whether this parser is XML Namespace aware.
+ */
+ public abstract boolean isNamespaceAware();
+
+ /**
+ * Indicates whether this parser will validate its input.
+ */
+ public abstract boolean isValidating();
+
+ /**
+ * Sets the specified SAX2 parser property.
+ * @param name the name of the property
+ * @param value the value of the property
+ */
+ public abstract void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+ /**
+ * Returns the value of the specified SAX2 parser property.
+ * @param name the name of the property
+ */
+ public abstract Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+ // -- JAXP 1.3 methods --
+
+ /**
+ * Resets this parser to its original configuration.
+ * @since 1.3
+ */
+ public void reset()
+ {
+ }
+
+ /**
+ * Returns the schema in use by this parser.
+ * @since 1.3
+ */
+ public Schema getSchema()
+ {
+ return null;
+ }
+
+ /**
+ * Indicates whether this parser is XInclude-aware.
+ * @since 1.3
+ */
+ public boolean isXIncludeAware()
+ {
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/SAXParserFactory.java b/libjava/classpath/javax/xml/parsers/SAXParserFactory.java
new file mode 100644
index 000000000..13aca0f2b
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/SAXParserFactory.java
@@ -0,0 +1,273 @@
+/* SAXParserFactory.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.parsers;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Properties;
+import javax.xml.validation.Schema;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * Factory for obtaining SAX parsers.
+ * Instances of this class are <em>not</em> guaranteed to be thread safe.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class SAXParserFactory
+{
+
+ private boolean validating;
+ private boolean namespaceAware;
+ private Schema schema;
+ private boolean xIncludeAware;
+
+ protected SAXParserFactory()
+ {
+ }
+
+ /**
+ * Creates a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.parsers.SAXParserFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/jaxp.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.parsers.SAXParserFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ public static SAXParserFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = SAXParserFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (SAXParserFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.SAXParserFactory();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.parsers.SAXParserFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "jaxp.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ SAXParserFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new parser instance using the currently specified factory
+ * configuration.
+ * @exception ParserConfigurationException if the specified configuration
+ * is not supported
+ */
+ public abstract SAXParser newSAXParser()
+ throws ParserConfigurationException, SAXException;
+
+ /**
+ * Sets whether parsers obtained from this factory will be XML Namespace
+ * aware.
+ */
+ public void setNamespaceAware(boolean awareness)
+ {
+ namespaceAware = awareness;
+ }
+
+ /**
+ * Sets whether parsers obtained from this factory will validate their
+ * input.
+ */
+ public void setValidating(boolean validating)
+ {
+ this.validating = validating;
+ }
+
+ /**
+ * Indicates whether parsers obtained from this factory will be XML
+ * Namespace aware.
+ */
+ public boolean isNamespaceAware()
+ {
+ return namespaceAware;
+ }
+
+ /**
+ * Indicates whether parsers obtained from this factory will validate
+ * their input.
+ */
+ public boolean isValidating()
+ {
+ return validating;
+ }
+
+ /**
+ * Sets the specified feature for SAX2 parsers obtained from this factory.
+ * @param name the feature name
+ * @param value the featurevalue
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws ParserConfigurationException, SAXNotRecognizedException,
+ SAXNotSupportedException;
+
+ /**
+ * Returns the specified feature for SAX2 parsers obtained from this
+ * factory.
+ * @param name the feature name
+ */
+ public abstract boolean getFeature(String name)
+ throws ParserConfigurationException, SAXNotRecognizedException,
+ SAXNotSupportedException;
+
+ // -- JAXP 1.3 methods --
+
+ /**
+ * Returns the schema.
+ * @since 1.3
+ * @see #setSchema
+ */
+ public Schema getSchema()
+ {
+ return schema;
+ }
+
+ /**
+ * Sets the schema.
+ * @since 1.3
+ * @see #getSchema
+ */
+ public void setSchema(Schema schema)
+ {
+ this.schema = schema;
+ }
+
+ /**
+ * Indicates whether parsers obtained from this factory will be XInclude
+ * aware.
+ * @since 1.3
+ */
+ public boolean isXIncludeAware()
+ {
+ return xIncludeAware;
+ }
+
+ /**
+ * Sets whether parsers obtained from this factory will be XInclude aware.
+ * @since 1.3
+ */
+ public void setXIncludeAware(boolean state)
+ {
+ xIncludeAware = state;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/parsers/package.html b/libjava/classpath/javax/xml/parsers/package.html
new file mode 100644
index 000000000..71739b92c
--- /dev/null
+++ b/libjava/classpath/javax/xml/parsers/package.html
@@ -0,0 +1,16 @@
+<html><head>javax.xml.parsers</head><body>
+
+<p>Bootstrapping APIs for JAXP parsers.
+This is the first portable API defined for bootstrapping DOM.
+
+<p>JAXP parsers bootstrap in two stages.
+First is getting a factory, and configuring it.
+Second is asking that factory for a parser.
+
+<p>The SAX bootstrapping support corresponds to functionality
+found in the <em>org.xml.sax.helpers</em> package, except
+that it uses the JAXP two stage bootstrap paradigm and
+that the parser that's bootstrapped is normally wrapping
+a SAX parser rather than exposing it for direct use.
+
+</body></html>
diff --git a/libjava/classpath/javax/xml/stream/EventFilter.java b/libjava/classpath/javax/xml/stream/EventFilter.java
new file mode 100644
index 000000000..eed54f8a9
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/EventFilter.java
@@ -0,0 +1,53 @@
+/* EventFilter.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Simple filter interface for XML events.
+ */
+public interface EventFilter
+{
+
+ /**
+ * Indicates whether this filter can accept the specified event.
+ */
+ boolean accept(XMLEvent event);
+
+}
diff --git a/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java b/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java
new file mode 100644
index 000000000..104b160cd
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java
@@ -0,0 +1,85 @@
+/* FactoryConfigurationError.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Error indicating that a factory could not be configured.
+ */
+public class FactoryConfigurationError
+ extends Error
+{
+
+ private final Exception exception;
+
+ public FactoryConfigurationError()
+ {
+ this((String) null, (Exception) null);
+ }
+
+ public FactoryConfigurationError(Exception e)
+ {
+ this(e, null);
+ }
+
+ public FactoryConfigurationError(Exception e, String msg)
+ {
+ super(msg);
+ exception = e;
+ }
+
+ public FactoryConfigurationError(String msg, Exception e)
+ {
+ this(e, msg);
+ }
+
+ public FactoryConfigurationError(String msg)
+ {
+ this(null, msg);
+ }
+
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ public String getMessage()
+ {
+ return super.getMessage();
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/stream/Location.java b/libjava/classpath/javax/xml/stream/Location.java
new file mode 100644
index 000000000..6e3483a5c
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/Location.java
@@ -0,0 +1,75 @@
+/* Location.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Information about the location of an XML event within the underlying
+ * stream.
+ */
+public interface Location
+{
+
+ /**
+ * Returns the line number at which the current event ends,
+ * or -1 if this is not available.
+ */
+ int getLineNumber();
+
+ /**
+ * Returns the column number at which the current event ends,
+ * or -1 if this is not available.
+ */
+ int getColumnNumber();
+
+ /**
+ * Returns the offset from the start of the source, in bytes or characters
+ * depending on the nature of the source, or -1 if this is not available.
+ */
+ int getCharacterOffset();
+
+ /**
+ * Returns the public identifier for this location, if any.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifier for the underlying source.
+ */
+ String getSystemId();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/StreamFilter.java b/libjava/classpath/javax/xml/stream/StreamFilter.java
new file mode 100644
index 000000000..a0ff2c8f3
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/StreamFilter.java
@@ -0,0 +1,52 @@
+/* StreamFilter.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Simple filter interface for XMLStreamReaders.
+ */
+public interface StreamFilter
+{
+
+ /**
+ * Indicates whether the current state of the specified reader in part of
+ * this stream.
+ */
+ boolean accept(XMLStreamReader reader);
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLEventFactory.java b/libjava/classpath/javax/xml/stream/XMLEventFactory.java
new file mode 100644
index 000000000..fc2d493d5
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLEventFactory.java
@@ -0,0 +1,352 @@
+/* XMLEventFactory.java --
+ Copyright (C) 2005,2006,2009 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Properties;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EndDocument;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+
+/**
+ * Factory for XML events.
+ */
+public abstract class XMLEventFactory
+{
+
+ protected XMLEventFactory()
+ {
+ }
+
+ /**
+ * Create a new factory instance.
+ * @see #newInstance(String,ClassLoader)
+ */
+ public static XMLEventFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ return newInstance(null, null);
+ }
+
+ /**
+ * Create a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLEventFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLEventFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ * @param factoryId name of the factory to find, same as a property name
+ * @param classLoader the class loader to use
+ * @return the factory implementation
+ * @exception FactoryConfigurationError if an instance of this factory
+ * cannot be loaded
+ */
+ public static XMLEventFactory newInstance(String factoryId,
+ ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = classLoader;
+ if (loader == null)
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+ if (loader == null)
+ {
+ loader = XMLEventFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (XMLEventFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLEventFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLEventFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLEventFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Sets the location for each event created by this factory.
+ */
+ public abstract void setLocation(Location location);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(String prefix, String namespaceURI,
+ String localName, String value);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(String localName, String value);
+
+ /**
+ * Create an attribute event.
+ */
+ public abstract Attribute createAttribute(QName name, String value);
+
+ /**
+ * Create a namespace declaration event.
+ */
+ public abstract Namespace createNamespace(String namespaceURI);
+
+ /**
+ * Create a namespace declaration event.
+ */
+ public abstract Namespace createNamespace(String prefix, String namespaceUri);
+
+ /**
+ * Create a start-element event.
+ */
+ @SuppressWarnings("unchecked")
+ public abstract StartElement createStartElement(QName name,
+ Iterator attributes,
+ Iterator namespaces);
+
+ /**
+ * Create a start-element event.
+ */
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName);
+
+ /**
+ * Create a start-element event.
+ */
+ @SuppressWarnings("unchecked")
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces);
+
+ /**
+ * Create a start-element event.
+ */
+ @SuppressWarnings("unchecked")
+ public abstract StartElement createStartElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator attributes,
+ Iterator namespaces,
+ NamespaceContext context);
+
+ /**
+ * Create an end-element event.
+ */
+ @SuppressWarnings("unchecked")
+ public abstract EndElement createEndElement(QName name,
+ Iterator namespaces);
+
+ /**
+ * Create an end-element event.
+ */
+ public abstract EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName);
+
+ /**
+ * Create an end-element event.
+ */
+ @SuppressWarnings("unchecked")
+ public abstract EndElement createEndElement(String prefix,
+ String namespaceUri,
+ String localName,
+ Iterator namespaces);
+
+ /**
+ * Create a text event.
+ */
+ public abstract Characters createCharacters(String content);
+
+ /**
+ * Create a text event of type CDATA section.
+ */
+ public abstract Characters createCData(String content);
+
+ /**
+ * Create a text event of type whitespace.
+ */
+ public abstract Characters createSpace(String content);
+
+ /**
+ * Create a text event of type ignorable whitespace.
+ */
+ public abstract Characters createIgnorableSpace(String content);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument();
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding,
+ String version,
+ boolean standalone);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding,
+ String version);
+
+ /**
+ * Create a start-document event.
+ */
+ public abstract StartDocument createStartDocument(String encoding);
+
+ /**
+ * Create an end-document event.
+ */
+ public abstract EndDocument createEndDocument();
+
+ /**
+ * Create an entity reference event.
+ */
+ public abstract EntityReference createEntityReference(String name,
+ EntityDeclaration declaration);
+
+ /**
+ * Create a comment event.
+ */
+ public abstract Comment createComment(String text);
+
+ /**
+ * Create a processing instruction event.
+ */
+ public abstract ProcessingInstruction createProcessingInstruction(String target,
+ String data);
+
+ /**
+ * Create a DOCTYPE declaration event.
+ */
+ public abstract DTD createDTD(String dtd);
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLEventReader.java b/libjava/classpath/javax/xml/stream/XMLEventReader.java
new file mode 100644
index 000000000..d5c76b6b1
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLEventReader.java
@@ -0,0 +1,102 @@
+/* XMLEventReader.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import java.util.Iterator;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * An XML parser.
+ */
+@SuppressWarnings("unchecked")
+public interface XMLEventReader
+ extends Iterator
+{
+
+ /**
+ * Returns the next XML event.
+ */
+ XMLEvent nextEvent()
+ throws XMLStreamException;
+
+ /**
+ * Indicates whether there are more XML events to be read.
+ */
+ boolean hasNext();
+
+ /**
+ * Looks at the next XML event without advancing the cursor in the stream.
+ * Returns <code>null</code> if there are no more events to read.
+ */
+ XMLEvent peek()
+ throws XMLStreamException;
+
+ /**
+ * Reads the text context of an element.
+ * When invoked, the current event must be START_ELEMENT.
+ * On completion, the current event will be END_ELEMENT.
+ */
+ String getElementText()
+ throws XMLStreamException;
+
+ /**
+ * Returns the next element event.
+ * This method skips insignificant space until a START_ELEMENT or
+ * END_ELEMENT event is found.
+ * @exception XMLStreamException if an event that was not an insignificant
+ * space event was encountered
+ */
+ XMLEvent nextTag()
+ throws XMLStreamException;
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Free any resources associated with this parser.
+ * This method will not close the underlying input source.
+ */
+ void close()
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLEventWriter.java b/libjava/classpath/javax/xml/stream/XMLEventWriter.java
new file mode 100644
index 000000000..5eb18760a
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLEventWriter.java
@@ -0,0 +1,108 @@
+/* XMLEventWriter.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventConsumer;
+
+/**
+ * Interface for writing XML documents from a series of events.
+ */
+public interface XMLEventWriter
+ extends XMLEventConsumer
+{
+
+ /**
+ * Ensures that any cached events are written to the underlying output
+ * sink.
+ */
+ void flush()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this writer.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Adds the specified event to this writer.
+ */
+ void add(XMLEvent event)
+ throws XMLStreamException;
+
+ /**
+ * Adds the specified XML stream to this writer.
+ * The implementation will call <code>next</code> on the given argument
+ * while <code>hasNext</code> returns true.
+ */
+ void add(XMLEventReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace prefix the specified URI is currently associated
+ * with.
+ */
+ String getPrefix(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Associates the given namespace prefix and URI.
+ */
+ void setPrefix(String prefix, String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the current default namespace URI.
+ */
+ void setDefaultNamespace(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the namespace context for managing namespace prefixes and URIs.
+ */
+ void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace context.
+ */
+ NamespaceContext getNamespaceContext();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLInputFactory.java b/libjava/classpath/javax/xml/stream/XMLInputFactory.java
new file mode 100644
index 000000000..39ba8e3b4
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLInputFactory.java
@@ -0,0 +1,451 @@
+/* XMLInputFactory.java --
+ Copyright (C) 2005,2006,2009 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Properties;
+import javax.xml.stream.util.XMLEventAllocator;
+import javax.xml.transform.Source;
+
+/**
+ * Factory for creating stream and event readers from various kinds of input
+ * source.
+ * <h3>Parameters</h3>
+ * <table>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Type</th>
+ * <th>Default</th>
+ * <th>Required</th>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isValidating</td>
+ * <td>Controls DTD validation</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>no</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isNamespaceAware</td>
+ * <td>Controls namespace processing for XML 1.0</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>true is required, false is optional</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isCoalescing</td>
+ * <td>Controls coalescing (normalization of adjacent character data)</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isReplacingEntityReferences</td>
+ * <td>Controls replacement of entity references with their replacement
+ * text</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isSupportingExternalEntities</td>
+ * <td>Controls whether to resolve external entities</td>
+ * <td>Boolean</td>
+ * <td>not specified</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.supportDTD</td>
+ * <td>Controls whether to support DTDs</td>
+ * <td>Boolean</td>
+ * <td>Boolean.TRUE</td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.reporter</td>
+ * <td></td>
+ * <td>javax.xml.stream.XMLReporter</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.resolver</td>
+ * <td></td>
+ * <td>javax.xml.stream.XMLResolver</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.allocator</td>
+ * <td></td>
+ * <td>javax.xml.stream.util.XMLEventAllocator</td>
+ * <td></td>
+ * <td>yes</td>
+ * </tr>
+ * </table>
+ */
+public abstract class XMLInputFactory
+{
+
+ /**
+ * Property used to control namespace support.
+ */
+ public static final String IS_NAMESPACE_AWARE =
+ "javax.xml.stream.isNamespaceAware";
+
+ /**
+ * Property used to control DTD validation.
+ */
+ public static final String IS_VALIDATING = "javax.xml.stream.isValidating";
+
+ /**
+ * Property used to control whether to coalesce adjacent text events.
+ */
+ public static final String IS_COALESCING = "javax.xml.stream.isCoalescing";
+
+ /**
+ * Property used to control whether to replace entity references with
+ * their replacement text.
+ */
+ public static final String IS_REPLACING_ENTITY_REFERENCES =
+ "javax.xml.stream.isReplacingEntityReferences";
+
+ /**
+ * Property used to control whether to resolve external entities.
+ */
+ public static final String IS_SUPPORTING_EXTERNAL_ENTITIES =
+ "javax.xml.stream.isSupportingExternalEntities";
+
+ /**
+ * Property used to indicate whether to support DTDs.
+ */
+ public static final String SUPPORT_DTD = "javax.xml.stream.supportDTD";
+
+ /**
+ * Property used to control the error reporter implementation.
+ */
+ public static final String REPORTER = "javax.xml.stream.reporter";
+
+ /**
+ * Property used to control the entity resolver implementation.
+ */
+ public static final String RESOLVER = "javax.xml.stream.resolver";
+
+ /**
+ * Property used to control the event allocator implementation.
+ */
+ public static final String ALLOCATOR = "javax.xml.stream.allocator";
+
+ protected XMLInputFactory()
+ {
+ }
+
+ /**
+ * Creates a new factory instance.
+ * @see #newInstance(String,ClassLoader)
+ */
+ public static XMLInputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ return newInstance(null, null);
+ }
+
+ /**
+ * Creates a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLInputFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLInputFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ * @param factoryId name of the factory, same as a property name
+ * @param classLoader the class loader to use
+ * @return the factory implementation
+ * @exception FactoryConfigurationError if an instance of this factory
+ * cannot be loaded
+ */
+ public static XMLInputFactory newInstance(String factoryId,
+ ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ ClassLoader loader = classLoader;
+ if (loader == null)
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+ if (loader == null)
+ {
+ loader = XMLInputFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (XMLInputFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLInputFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLInputFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLInputFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(Source source)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(InputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(String systemId,
+ InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream reader.
+ */
+ public abstract XMLStreamReader createXMLStreamReader(String systemId,
+ Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(String systemId,
+ Reader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(Source source)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(InputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event reader.
+ */
+ public abstract XMLEventReader createXMLEventReader(String systemId,
+ InputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Create a new filtered reader.
+ */
+ public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader,
+ StreamFilter filter)
+ throws XMLStreamException;
+
+ /**
+ * Create a new filtered reader.
+ */
+ public abstract XMLEventReader createFilteredReader(XMLEventReader reader,
+ EventFilter filter)
+ throws XMLStreamException;
+
+ /**
+ * Returns the entity resolver.
+ */
+ public abstract XMLResolver getXMLResolver();
+
+ /**
+ * Sets the entity resolver.
+ */
+ public abstract void setXMLResolver(XMLResolver resolver);
+
+ /**
+ * Returns the error reporter.
+ */
+ public abstract XMLReporter getXMLReporter();
+
+ /**
+ * Sets the error reporter.
+ */
+ public abstract void setXMLReporter(XMLReporter reporter);
+
+ /**
+ * Sets the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract void setProperty(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Indicates whether the specified property is supported.
+ */
+ public abstract boolean isPropertySupported(String name);
+
+ /**
+ * Sets the event allocator.
+ */
+ public abstract void setEventAllocator(XMLEventAllocator allocator);
+
+ /**
+ * Returns the event allocator.
+ */
+ public abstract XMLEventAllocator getEventAllocator();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLOutputFactory.java b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java
new file mode 100644
index 000000000..a8579aa31
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java
@@ -0,0 +1,279 @@
+/* XMLOutputFactory.java --
+ Copyright (C) 2005,2006,2009 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+import javax.xml.transform.Result;
+
+/**
+ * Factory for obtaining XML stream and event writers for various kinds of
+ * output sink.
+ * <h3>Configuration</h3>
+ * <table>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Type</th>
+ * <th>Default</th>
+ * <th>Required</th>
+ * </tr>
+ * <tr>
+ * <td>javax.xml.stream.isRepairingNamespaces</td>
+ * <td>default namespace prefixes</td>
+ * <td>Boolean</td>
+ * <td>Boolean.FALSE</td>
+ * <td>yes</td>
+ * </tr>
+ * </table>
+ */
+public abstract class XMLOutputFactory
+{
+
+ /**
+ * Property used to control whether to default namespace prefixes.
+ * If true, the writer will create a namespace declaration for any
+ * attribute that doesn't have a namespace declaration in scope.
+ */
+ public static final java.lang.String IS_REPAIRING_NAMESPACES =
+ "javax.xml.stream.isRepairingNamespaces";
+
+ protected XMLOutputFactory()
+ {
+ }
+
+ /**
+ * Creates a new <b>output</b> factory.
+ * @see #newInstance(String,ClassLoader)
+ */
+ public static XMLOutputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+ return newInstance(null, null);
+ }
+
+ /**
+ * Creates a new <b>output</b> factory.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.stream.XMLOutputFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.stream.XMLOutputFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ * @param factoryId the name of the factory, same as the property
+ * @param classLoader the class loader to use
+ * @return a new factory instance
+ * @exception FactoryConfigurationError if an instance of this factory
+ * could not be loaded
+ */
+ public static XMLOutputFactory newInstance(String factoryId,
+ ClassLoader classLoader)
+ throws FactoryConfigurationError
+ {
+ if (classLoader == null)
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ if (classLoader == null)
+ {
+ classLoader = XMLOutputFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(classLoader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (classLoader != null) ?
+ classLoader.loadClass(className) :
+ Class.forName(className);
+ return (XMLOutputFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ return new gnu.xml.stream.XMLOutputFactoryImpl();
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.stream.XMLOutputFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "stax.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XMLOutputFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(Writer stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new stream writer.
+ * @exception UnsupportedOperationException if this method is not
+ * supported
+ */
+ public abstract XMLStreamWriter createXMLStreamWriter(Result result)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ * @exception UnsupportedOperationException if this method is not
+ * supported
+ */
+ public abstract XMLEventWriter createXMLEventWriter(Result result)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(OutputStream stream)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(OutputStream stream,
+ String encoding)
+ throws XMLStreamException;
+
+ /**
+ * Creates a new event writer.
+ */
+ public abstract XMLEventWriter createXMLEventWriter(Writer stream)
+ throws XMLStreamException;
+
+ /**
+ * Sets the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract void setProperty(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the implementation-specific property of the given name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Indicates whether the specified property is supported.
+ */
+ public abstract boolean isPropertySupported(String name);
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLReporter.java b/libjava/classpath/javax/xml/stream/XMLReporter.java
new file mode 100644
index 000000000..389437542
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLReporter.java
@@ -0,0 +1,57 @@
+/* XMLReporter.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Interface used to report non-fatal errors during parsing.
+ */
+public interface XMLReporter
+{
+
+ /**
+ * Reports an error.
+ * @param message the error message
+ * @param errorType an implementation-specific error type
+ * @param relatedInformation additional information, if any
+ * @param location the error location, if available
+ */
+ void report(String message, String errorType,
+ Object relatedInformation, Location location)
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLResolver.java b/libjava/classpath/javax/xml/stream/XMLResolver.java
new file mode 100644
index 000000000..e537bb74c
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLResolver.java
@@ -0,0 +1,65 @@
+/* XMLResolver.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Interface used to resolve XML external entities during parsing.
+ */
+public interface XMLResolver
+{
+
+ /**
+ * Returns an input source from which the specified external entity can be
+ * read. The following return types are possible:
+ * <ol>
+ * <li><code>java.io.InputStream</code></li>
+ * <li><code>javax.xml.stream.XMLStreamReader</code></li>
+ * <li><code>java.xml.stream.XMLEventReader</code></li>
+ * </ol>
+ * If <code>null</code> is returned, the processor will attempt to resolve
+ * the entity itself.
+ * @param publicID the public ID of the external entity
+ * @param systemID the system ID of the external entity
+ * @param baseURI the absolute base URI of the referring entity
+ * @param namespace the namespace of the external entity
+ */
+ Object resolveEntity(String publicID, String systemID,
+ String baseURI, String namespace)
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLStreamConstants.java b/libjava/classpath/javax/xml/stream/XMLStreamConstants.java
new file mode 100644
index 000000000..60541344e
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLStreamConstants.java
@@ -0,0 +1,121 @@
+/* XMLStreamConstants.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * STaX constants.
+ */
+public interface XMLStreamConstants
+{
+
+ /**
+ * A start element event.
+ */
+ static final int START_ELEMENT = 1;
+
+ /**
+ * An end element event.
+ */
+ static final int END_ELEMENT = 2;
+
+ /**
+ * A processing instruction event.
+ */
+ static final int PROCESSING_INSTRUCTION = 3;
+
+ /**
+ * A text event.
+ */
+ static final int CHARACTERS = 4;
+
+ /**
+ * A comment event.
+ */
+ static final int COMMENT = 5;
+
+ /**
+ * An ignorable whitespace event.
+ */
+ static final int SPACE = 6;
+
+ /**
+ * A start document event.
+ */
+ static final int START_DOCUMENT = 7;
+
+ /**
+ * An end document event.
+ */
+ static final int END_DOCUMENT = 8;
+
+ /**
+ * An entity reference event.
+ */
+ static final int ENTITY_REFERENCE = 9;
+
+ /**
+ * An attribute event.
+ */
+ static final int ATTRIBUTE = 10;
+
+ /**
+ * A DOCTYPE declaration event.
+ */
+ static final int DTD = 11;
+
+ /**
+ * A CDATA section event.
+ */
+ static final int CDATA = 12;
+
+ /**
+ * A namespace event.
+ */
+ static final int NAMESPACE = 13;
+
+ /**
+ * A notation declaration event.
+ */
+ static final int NOTATION_DECLARATION = 14;
+
+ /**
+ * An entity declaration event.
+ */
+ static final int ENTITY_DECLARATION = 15;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLStreamException.java b/libjava/classpath/javax/xml/stream/XMLStreamException.java
new file mode 100644
index 000000000..929afbb75
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLStreamException.java
@@ -0,0 +1,98 @@
+/* XMLStreamException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+/**
+ * Exception indicating an XML stream processing error.
+ */
+public class XMLStreamException
+ extends Exception
+{
+
+ protected Location location;
+ protected Throwable nested;
+
+ public XMLStreamException()
+ {
+ this(null, null, null);
+ }
+
+ public XMLStreamException(String msg)
+ {
+ this(msg, null, null);
+ }
+
+ public XMLStreamException(Throwable th)
+ {
+ this(null, null, th);
+ }
+
+ public XMLStreamException(String msg, Throwable th)
+ {
+ this(msg, null, th);
+ }
+
+ public XMLStreamException(String msg, Location location, Throwable th)
+ {
+ super(msg);
+ this.location = location;
+ nested = th;
+ }
+
+ public XMLStreamException(String msg, Location location)
+ {
+ this(msg, location, null);
+ }
+
+ /**
+ * Returns the nested exception.
+ */
+ public Throwable getNestedException()
+ {
+ return nested;
+ }
+
+ /**
+ * Returns the location of the exception.
+ */
+ public Location getLocation()
+ {
+ return location;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLStreamReader.java b/libjava/classpath/javax/xml/stream/XMLStreamReader.java
new file mode 100644
index 000000000..10bc4a5a5
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLStreamReader.java
@@ -0,0 +1,300 @@
+/* XMLStreamReader.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * Interface implemented by an XML parser.
+ */
+public interface XMLStreamReader
+ extends XMLStreamConstants
+{
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the next parsing event.
+ */
+ int next()
+ throws XMLStreamException;
+
+ /**
+ * Tests whether the current event is of the given type and namespace.
+ * @exception XMLStreamException if the test fails
+ */
+ void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Returns the text content of a text-only element.
+ * When invoked, the current event must be START_ELEMENT.
+ * On completion, the current event will be END_ELEMENT.
+ */
+ String getElementText()
+ throws XMLStreamException;
+
+ /**
+ * Skips any ignorable whitespace, comments, and processing instructions
+ * until a START_ELEMENT or END_ELEMENT event is encountered.
+ * @exception XMLStreamException if an event of any other type is
+ * encountered
+ */
+ int nextTag()
+ throws XMLStreamException;
+
+ /**
+ * Indicates whether there are any remaining events to be read.
+ */
+ boolean hasNext()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this parser.
+ * This method will not close the underlying input source.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Returns the namespace URI for the given prefix.
+ */
+ String getNamespaceURI(String prefix);
+
+ /**
+ * Indicates whether the current event is START_ELEMENT.
+ */
+ boolean isStartElement();
+
+ /**
+ * Indicates whether the current event is END_ELEMENT.
+ */
+ boolean isEndElement();
+
+ /**
+ * Indicates whether the current event is character data.
+ */
+ boolean isCharacters();
+
+ /**
+ * Indicates whether the current event is ignorable whitespace.
+ */
+ boolean isWhiteSpace();
+
+ /**
+ * Returns the normalized attribute value for the given attribute.
+ */
+ String getAttributeValue(String namespaceURI, String localName);
+
+ /**
+ * Returns the number of attributes on this element.
+ * This method can only be invoked on a START_ELEMENT event.
+ */
+ int getAttributeCount();
+
+ /**
+ * Returns the QName of the attribute at the given index.
+ */
+ QName getAttributeName(int index);
+
+ /**
+ * Returns the namespace URI of the attribute at the given index.
+ */
+ String getAttributeNamespace(int index);
+
+ /**
+ * Returns the local-name of the attribute at the given index.
+ */
+ String getAttributeLocalName(int index);
+
+ /**
+ * Returns the namespace prefix of the attribute at the given index.
+ */
+ String getAttributePrefix(int index);
+
+ /**
+ * Returns the type of the attribute at the specified index.
+ */
+ String getAttributeType(int index);
+
+ /**
+ * Returns the normalized value of the attribute at the given index.
+ */
+ String getAttributeValue(int index);
+
+ /**
+ * Indicates whether the attribute at the given index was specified in the
+ * underlying XML source or created by default.
+ */
+ boolean isAttributeSpecified(int index);
+
+ /**
+ * Returns the number of namespaces declared on this event.
+ * This method is only valid on a START_ELEMENT, END_ELEMENT, or NAMESPACE
+ * event.
+ */
+ int getNamespaceCount();
+
+ /**
+ * Returns the prefix of the namespace at the given index, or null if this
+ * is the default namespace declaration.
+ */
+ String getNamespacePrefix(int index);
+
+ /**
+ * Returns the URI of the namespace at the given index.
+ */
+ String getNamespaceURI(int index);
+
+ /**
+ * Returns the namespace context for the current position.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the type of the current event.
+ */
+ int getEventType();
+
+ /**
+ * Returns the string value of the current event.
+ */
+ String getText();
+
+ /**
+ * Returns the string value of the current event as a character array.
+ */
+ char[] getTextCharacters();
+
+ /**
+ * Copies the string value of the current event into the specified
+ * character array.
+ */
+ int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length)
+ throws XMLStreamException;
+
+ /**
+ * Returns the offset of the first character in the text character array.
+ */
+ int getTextStart();
+
+ /**
+ * Returns the length of the characters in the text character array.
+ */
+ int getTextLength();
+
+ /**
+ * Returns the input encoding.
+ */
+ String getEncoding();
+
+ /**
+ * Indicates whether the current event has text.
+ */
+ boolean hasText();
+
+ /**
+ * Returns the current location of the parser cursor in the underlying
+ * input source.
+ */
+ Location getLocation();
+
+ /**
+ * Returns the QName of the current element.
+ * This method is only valid on a START_ELEMENT or END_ELEMENT event.
+ */
+ QName getName();
+
+ /**
+ * Returns the local-name of the current element.
+ */
+ String getLocalName();
+
+ /**
+ * Indicates whether the current event has a name.
+ */
+ boolean hasName();
+
+ /**
+ * Returns the namespace URI of the current element.
+ */
+ String getNamespaceURI();
+
+ /**
+ * Returns the namespace prefix of the current element.
+ */
+ String getPrefix();
+
+ /**
+ * Returns the XML version declared in the XML declaration.
+ */
+ String getVersion();
+
+ /**
+ * Returns the standalone flag declared in the XML declaration.
+ */
+ boolean isStandalone();
+
+ /**
+ * Indicates whether the standalone flag was set in the document.
+ */
+ boolean standaloneSet();
+
+ /**
+ * Returns the encoding declared in the XML declaration.
+ */
+ String getCharacterEncodingScheme();
+
+ /**
+ * Returns the target of the current processing instruction event.
+ */
+ String getPITarget();
+
+ /**
+ * Returns the data of the current processing instruction event.
+ */
+ String getPIData();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/XMLStreamWriter.java b/libjava/classpath/javax/xml/stream/XMLStreamWriter.java
new file mode 100644
index 000000000..d7d739660
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/XMLStreamWriter.java
@@ -0,0 +1,243 @@
+/* XMLStreamWriter.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * Interface for writing XML to a stream.
+ */
+public interface XMLStreamWriter
+{
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write the start of a tag.
+ */
+ void writeStartElement(String prefix, String localName, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String namespaceURI, String localName)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String prefix, String localName, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write an empty tag.
+ */
+ void writeEmptyElement(String localName)
+ throws XMLStreamException;
+
+ /**
+ * Closes the currently open tag.
+ */
+ void writeEndElement()
+ throws XMLStreamException;
+
+ /**
+ * Closes any currently open tags.
+ */
+ void writeEndDocument()
+ throws XMLStreamException;
+
+ /**
+ * Frees any resources used by this writer.
+ * This will not close the underlying output sink.
+ */
+ void close()
+ throws XMLStreamException;
+
+ /**
+ * Flushes any cached information to the underlying output sink.
+ */
+ void flush()
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String prefix, String namespaceURI,
+ String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write an attribute.
+ */
+ void writeAttribute(String namespaceURI, String localName, String value)
+ throws XMLStreamException;
+
+ /**
+ * Write a namespace declaration.
+ */
+ void writeNamespace(String prefix, String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write a default namespace declaration.
+ */
+ void writeDefaultNamespace(String namespaceURI)
+ throws XMLStreamException;
+
+ /**
+ * Write a comment.
+ */
+ void writeComment(String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a processing instruction.
+ */
+ void writeProcessingInstruction(String target)
+ throws XMLStreamException;
+
+ /**
+ * Write a processing instruction.
+ */
+ void writeProcessingInstruction(String target, String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a CDATA section.
+ */
+ void writeCData(String data)
+ throws XMLStreamException;
+
+ /**
+ * Write a DOCTYPE declaration.
+ */
+ void writeDTD(String dtd)
+ throws XMLStreamException;
+
+ /**
+ * Write an entity reference.
+ */
+ void writeEntityRef(String name)
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration.
+ */
+ void writeStartDocument()
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration with the specified XML version.
+ */
+ void writeStartDocument(String version)
+ throws XMLStreamException;
+
+ /**
+ * Write an XML declaration with the specifed XML version and encoding.
+ */
+ void writeStartDocument(String encoding, String version)
+ throws XMLStreamException;
+
+ /**
+ * Write the specified text.
+ */
+ void writeCharacters(String text)
+ throws XMLStreamException;
+
+ /**
+ * Write the specified text.
+ */
+ void writeCharacters(char[] text, int start, int len)
+ throws XMLStreamException;
+
+ /**
+ * Returns the prefix associated with the given namespace URI.
+ */
+ String getPrefix(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the prefix for the given namespace URI.
+ */
+ void setPrefix(String prefix, String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the URI for the default namespace.
+ */
+ void setDefaultNamespace(String uri)
+ throws XMLStreamException;
+
+ /**
+ * Sets the namespace context for namespace resolution.
+ */
+ void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException;
+
+ /**
+ * Returns the current namespace context.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the implementation-specific feature or property of the given
+ * name.
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ Object getProperty(String name)
+ throws IllegalArgumentException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/Attribute.java b/libjava/classpath/javax/xml/stream/events/Attribute.java
new file mode 100644
index 000000000..1824a9c02
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/Attribute.java
@@ -0,0 +1,70 @@
+/* Attribute.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An attribute event.
+ */
+public interface Attribute
+ extends XMLEvent
+{
+
+ /**
+ * Returns the name of this attribute.
+ */
+ QName getName();
+
+ /**
+ * Returns the normalized value of this attribute.
+ */
+ String getValue();
+
+ /**
+ * Returns the type of this attribute.
+ */
+ String getDTDType();
+
+ /**
+ * Indicates whether this attribute was specified in the input source, or
+ * just defaulted by the DTD.
+ */
+ boolean isSpecified();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/Characters.java b/libjava/classpath/javax/xml/stream/events/Characters.java
new file mode 100644
index 000000000..d82009247
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/Characters.java
@@ -0,0 +1,67 @@
+/* Characters.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A character data (text) event.
+ */
+public interface Characters
+ extends XMLEvent
+{
+
+ /**
+ * Returns the character data assocated with this event.
+ */
+ String getData();
+
+ /**
+ * Indicates whether this text is all whitespace.
+ */
+ boolean isWhiteSpace();
+
+ /**
+ * Indicates whether this is a CDATA section.
+ */
+ boolean isCData();
+
+ /**
+ * Indicates whether this text is all ignorable whitespace.
+ */
+ boolean isIgnorableWhiteSpace();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/Comment.java b/libjava/classpath/javax/xml/stream/events/Comment.java
new file mode 100644
index 000000000..4419e58f2
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/Comment.java
@@ -0,0 +1,52 @@
+/* Comment.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A comment event.
+ */
+public interface Comment
+ extends XMLEvent
+{
+
+ /**
+ * Returns the comment text.
+ */
+ String getText();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/DTD.java b/libjava/classpath/javax/xml/stream/events/DTD.java
new file mode 100644
index 000000000..b1a906919
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/DTD.java
@@ -0,0 +1,72 @@
+/* DTD.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+import java.util.List;
+
+/**
+ * A DOCTYPE declaration event.
+ */
+public interface DTD
+ extends XMLEvent
+{
+
+ /**
+ * Returns the body of the DTD, including the internal DTD subset.
+ */
+ String getDocumentTypeDeclaration();
+
+ /**
+ * Returns an implementation-specific representation of the DTD, or null
+ * if no such representation is available.
+ */
+ Object getProcessedDTD();
+
+ /**
+ * Returns the notations declared in the DTD.
+ */
+ @SuppressWarnings("unchecked")
+ List getNotations();
+
+ /**
+ * Returns the entities declared in the DTD.
+ */
+ @SuppressWarnings("unchecked")
+ List getEntities();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/EndDocument.java b/libjava/classpath/javax/xml/stream/events/EndDocument.java
new file mode 100644
index 000000000..fd7e3fa4f
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/EndDocument.java
@@ -0,0 +1,46 @@
+/* EndDocument.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * An end-document event.
+ */
+public interface EndDocument
+ extends XMLEvent
+{
+}
diff --git a/libjava/classpath/javax/xml/stream/events/EndElement.java b/libjava/classpath/javax/xml/stream/events/EndElement.java
new file mode 100644
index 000000000..a6b5c3fa2
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/EndElement.java
@@ -0,0 +1,61 @@
+/* EndElement.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+import java.util.Iterator;
+import javax.xml.namespace.QName;
+
+/**
+ * An end-element event.
+ */
+public interface EndElement
+ extends XMLEvent
+{
+
+ /**
+ * Returns the element name.
+ */
+ QName getName();
+
+ /**
+ * Returns the namespaces that have gone out of scope.
+ */
+ @SuppressWarnings("unchecked")
+ Iterator getNamespaces();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java b/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java
new file mode 100644
index 000000000..61fa177f9
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java
@@ -0,0 +1,77 @@
+/* EntityDeclaration.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * An entity declaration event.
+ */
+public interface EntityDeclaration
+ extends XMLEvent
+{
+
+ /**
+ * Returns the public identifier of the entity.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifier of the entity.
+ */
+ String getSystemId();
+
+ /**
+ * Returns the name of the entity.
+ */
+ String getName();
+
+ /**
+ * Returns the name of the associated notation.
+ */
+ String getNotationName();
+
+ /**
+ * Returns the replacement text for the entity.
+ */
+ String getReplacementText();
+
+ /**
+ * Returns the base URI for the entity.
+ */
+ String getBaseURI();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/EntityReference.java b/libjava/classpath/javax/xml/stream/events/EntityReference.java
new file mode 100644
index 000000000..27bcb040f
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/EntityReference.java
@@ -0,0 +1,57 @@
+/* EntityReference.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * An entity reference event.
+ */
+public interface EntityReference
+ extends XMLEvent
+{
+
+ /**
+ * Returns the declaration of this reference.
+ */
+ EntityDeclaration getDeclaration();
+
+ /**
+ * Returns the entity name.
+ */
+ String getName();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/Namespace.java b/libjava/classpath/javax/xml/stream/events/Namespace.java
new file mode 100644
index 000000000..05de86c96
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/Namespace.java
@@ -0,0 +1,62 @@
+/* Namespace.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A namespace declaration event.
+ */
+public interface Namespace
+ extends Attribute
+{
+
+ /**
+ * Returns the namespace prefix, if any.
+ */
+ String getPrefix();
+
+ /**
+ * Returns the namespace URI.
+ */
+ String getNamespaceURI();
+
+ /**
+ * Indicates whether this event declares the default namespace.
+ */
+ boolean isDefaultNamespaceDeclaration();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java b/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java
new file mode 100644
index 000000000..708beb5f5
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java
@@ -0,0 +1,62 @@
+/* NotationDeclaration.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A notation declaration event.
+ */
+public interface NotationDeclaration
+ extends XMLEvent
+{
+
+ /**
+ * Returns the name of the notation.
+ */
+ String getName();
+
+ /**
+ * Returns the public identifier of the notation.
+ */
+ String getPublicId();
+
+ /**
+ * Returns the system identifier of the notation.
+ */
+ String getSystemId();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java b/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java
new file mode 100644
index 000000000..340202300
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java
@@ -0,0 +1,57 @@
+/* ProcessingInstruction.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A processing instruction event.
+ */
+public interface ProcessingInstruction
+ extends XMLEvent
+{
+
+ /**
+ * Returns the processing instruction target.
+ */
+ String getTarget();
+
+ /**
+ * Returns the processing instruction data.
+ */
+ String getData();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/StartDocument.java b/libjava/classpath/javax/xml/stream/events/StartDocument.java
new file mode 100644
index 000000000..7a5434624
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/StartDocument.java
@@ -0,0 +1,79 @@
+/* StartDocument.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+/**
+ * A start-document event.
+ */
+public interface StartDocument
+ extends XMLEvent
+{
+
+ /**
+ * Returns the system identifier of the document entity.
+ */
+ String getSystemId();
+
+ /**
+ * Returns the character encoding of the document.
+ */
+ String getCharacterEncodingScheme();
+
+ /**
+ * Indicates whether the character encoding was set in the XML
+ * declaration.
+ */
+ boolean encodingSet();
+
+ /**
+ * Indicates whether the document is standalone.
+ */
+ boolean isStandalone();
+
+ /**
+ * Indicates whether the standalone parameter was set in the XML
+ * declaration.
+ */
+ boolean standaloneSet();
+
+ /**
+ * Returns the XML version of the document.
+ */
+ String getVersion();
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/StartElement.java b/libjava/classpath/javax/xml/stream/events/StartElement.java
new file mode 100644
index 000000000..359b57eef
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/StartElement.java
@@ -0,0 +1,83 @@
+/* StartElement.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+import java.util.Iterator;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * A start-element event.
+ */
+public interface StartElement
+ extends XMLEvent
+{
+
+ /**
+ * Returns the element name.
+ */
+ QName getName();
+
+ /**
+ * Returns the attributes declared on this element.
+ */
+ @SuppressWarnings("unchecked")
+ Iterator getAttributes();
+
+ /**
+ * Returns the namespaces declared on this element.
+ */
+ @SuppressWarnings("unchecked")
+ Iterator getNamespaces();
+
+ /**
+ * Returns an attribute by name.
+ */
+ Attribute getAttributeByName(QName name);
+
+ /**
+ * Returns a read-only namespace context associated with this event.
+ */
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Returns the namespace URI associated with the given prefix.
+ */
+ String getNamespaceURI(String prefix);
+
+}
diff --git a/libjava/classpath/javax/xml/stream/events/XMLEvent.java b/libjava/classpath/javax/xml/stream/events/XMLEvent.java
new file mode 100644
index 000000000..90f354667
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/events/XMLEvent.java
@@ -0,0 +1,135 @@
+/* XMLEvent.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.events;
+
+import java.io.Writer;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * An XML stream event.
+ */
+public interface XMLEvent
+ extends XMLStreamConstants
+{
+
+ /**
+ * Returns the type of this event.
+ */
+ int getEventType();
+
+ /**
+ * Returns the location of this event.
+ */
+ Location getLocation();
+
+ /**
+ * Indicates whether this event is a start-element event.
+ */
+ boolean isStartElement();
+
+ /**
+ * Indicates whether this event is an attribute event.
+ */
+ boolean isAttribute();
+
+ /**
+ * Indicates whether this event is a namespace declaration event.
+ */
+ boolean isNamespace();
+
+ /**
+ * Indicates whether this event is an end-element event.
+ */
+ boolean isEndElement();
+
+ /**
+ * Indicates whether this event is an entity reference event.
+ */
+ boolean isEntityReference();
+
+ /**
+ * Indicates whether this event is a processing instruction event.
+ */
+ boolean isProcessingInstruction();
+
+ /**
+ * Indicates whether this event is a text event.
+ */
+ boolean isCharacters();
+
+ /**
+ * Indicates whether this event is a start-document event.
+ */
+ boolean isStartDocument();
+
+ /**
+ * Indicates whether this event is an end-document event.
+ */
+ boolean isEndDocument();
+
+ /**
+ * Returns this event as a start-element event.
+ */
+ StartElement asStartElement();
+
+ /**
+ * Returns this event as an end-element event.
+ */
+ EndElement asEndElement();
+
+ /**
+ * Returns this event as a text event.
+ */
+ Characters asCharacters();
+
+ /**
+ * Returns schema-related type information about this event, or null if
+ * not available.
+ */
+ QName getSchemaType();
+
+ /**
+ * Writes this event to the specified writer.
+ */
+ void writeAsEncodedUnicode(Writer writer)
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java b/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java
new file mode 100644
index 000000000..2c04c09de
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java
@@ -0,0 +1,151 @@
+/* EventReaderDelegate.java --
+ Copyright (C) 2005,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.util;
+
+import java.util.NoSuchElementException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Base class for event reader filters.
+ */
+public class EventReaderDelegate
+ implements XMLEventReader
+{
+
+ private XMLEventReader parent;
+
+ /**
+ * Constructs an empty filter with no parent set.
+ */
+ public EventReaderDelegate()
+ {
+ }
+
+ /**
+ * Constructs an empty filter with the given parent.
+ */
+ public EventReaderDelegate(XMLEventReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Sets the parent.
+ */
+ public void setParent(XMLEventReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Returns the parent.
+ */
+ public XMLEventReader getParent()
+ {
+ return parent;
+ }
+
+ public XMLEvent nextEvent()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.nextEvent();
+ throw new NoSuchElementException();
+ }
+
+ public Object next()
+ {
+ if (parent != null)
+ return parent.next();
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasNext()
+ {
+ if (parent != null)
+ return parent.hasNext();
+ return false;
+ }
+
+ public XMLEvent peek()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.peek();
+ return null;
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getElementText();
+ throw new XMLStreamException();
+ }
+
+ public XMLEvent nextTag()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.nextTag();
+ throw new XMLStreamException();
+ }
+
+ public Object getProperty(String name)
+ throws IllegalArgumentException
+ {
+ if (parent != null)
+ return parent.getProperty(name);
+ throw new IllegalArgumentException(name);
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ parent.close();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java b/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java
new file mode 100644
index 000000000..75a7ca597
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java
@@ -0,0 +1,408 @@
+/* StreamReaderDelegate.java --
+ Copyright (C) 2005,2006,2009 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.util;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Base class for XML stream reader filters.
+ */
+public class StreamReaderDelegate
+ implements XMLStreamReader, XMLStreamConstants
+{
+
+ private XMLStreamReader parent;
+
+ /**
+ * Constructs an empty filter with no parent set.
+ */
+ public StreamReaderDelegate()
+ {
+ }
+
+ /**
+ * Constructs an empty filter with the specfied parent.
+ */
+ public StreamReaderDelegate(XMLStreamReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Sets the parent.
+ */
+ public void setParent(XMLStreamReader reader)
+ {
+ parent = reader;
+ }
+
+ /**
+ * Returns the parent.
+ */
+ public XMLStreamReader getParent()
+ {
+ return parent;
+ }
+
+ public int next()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.next();
+ throw new XMLStreamException();
+ }
+
+ public int nextTag()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.nextTag();
+ throw new XMLStreamException();
+ }
+
+ public String getElementText()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getElementText();
+ throw new XMLStreamException();
+ }
+
+ public void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException
+ {
+ if (parent != null)
+ parent.require(type, namespaceURI, localName);
+ }
+
+ public boolean hasNext()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.hasNext();
+ return false;
+ }
+
+ public void close()
+ throws XMLStreamException
+ {
+ if (parent != null)
+ parent.close();
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ if (parent != null)
+ return parent.getNamespaceURI(prefix);
+ return null;
+ }
+
+ public NamespaceContext getNamespaceContext()
+ {
+ if (parent != null)
+ return parent.getNamespaceContext();
+ return null;
+ }
+
+ public boolean isStartElement()
+ {
+ if (parent != null)
+ return parent.isStartElement();
+ return false;
+ }
+
+ public boolean isEndElement()
+ {
+ if (parent != null)
+ return parent.isEndElement();
+ return false;
+ }
+
+ public boolean isCharacters()
+ {
+ if (parent != null)
+ return parent.isCharacters();
+ return false;
+ }
+
+ public boolean isWhiteSpace()
+ {
+ if (parent != null)
+ return parent.isWhiteSpace();
+ return false;
+ }
+
+ public String getAttributeValue(String namespaceUri, String localName)
+ {
+ if (parent != null)
+ return parent.getAttributeValue(namespaceUri, localName);
+ return null;
+ }
+
+ public int getAttributeCount()
+ {
+ if (parent != null)
+ return parent.getAttributeCount();
+ return 0;
+ }
+
+ public QName getAttributeName(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeName(index);
+ return null;
+ }
+
+ public String getAttributePrefix(int index)
+ {
+ if (parent != null)
+ return parent.getAttributePrefix(index);
+ return null;
+ }
+
+ public String getAttributeNamespace(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeNamespace(index);
+ return null;
+ }
+
+ public String getAttributeLocalName(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeLocalName(index);
+ return null;
+ }
+
+ public String getAttributeType(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeType(index);
+ return null;
+ }
+
+ public String getAttributeValue(int index)
+ {
+ if (parent != null)
+ return parent.getAttributeValue(index);
+ return null;
+ }
+
+ public boolean isAttributeSpecified(int index)
+ {
+ if (parent != null)
+ return parent.isAttributeSpecified(index);
+ return false;
+ }
+
+ public int getNamespaceCount()
+ {
+ if (parent != null)
+ return parent.getNamespaceCount();
+ return 0;
+ }
+
+ public String getNamespacePrefix(int index)
+ {
+ if (parent != null)
+ return parent.getNamespacePrefix(index);
+ return null;
+ }
+
+ public String getNamespaceURI(int index)
+ {
+ if (parent != null)
+ return parent.getNamespaceURI(index);
+ return null;
+ }
+
+ public int getEventType()
+ {
+ if (parent != null)
+ return parent.getEventType();
+ return 0;
+ }
+
+ public String getText()
+ {
+ if (parent != null)
+ return parent.getText();
+ return null;
+ }
+
+ public int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length)
+ throws XMLStreamException
+ {
+ if (parent != null)
+ return parent.getTextCharacters(sourceStart, target, targetStart, length);
+ return 0;
+ }
+
+ public char[] getTextCharacters()
+ {
+ if (parent != null)
+ return parent.getTextCharacters();
+ return null;
+ }
+
+ public int getTextStart()
+ {
+ if (parent != null)
+ return parent.getTextStart();
+ return 0;
+ }
+
+ public int getTextLength()
+ {
+ if (parent != null)
+ return parent.getTextLength();
+ return 0;
+ }
+
+ public String getEncoding()
+ {
+ if (parent != null)
+ return parent.getEncoding();
+ return null;
+ }
+
+ public boolean hasText()
+ {
+ if (parent != null)
+ return parent.hasText();
+ return false;
+ }
+
+ public Location getLocation()
+ {
+ if (parent != null)
+ return parent.getLocation();
+ return null;
+ }
+
+ public QName getName()
+ {
+ if (parent != null)
+ return parent.getName();
+ return null;
+ }
+
+ public String getLocalName()
+ {
+ if (parent != null)
+ return parent.getLocalName();
+ return null;
+ }
+
+ public boolean hasName()
+ {
+ if (parent != null)
+ return parent.hasName();
+ return false;
+ }
+
+ public String getNamespaceURI()
+ {
+ if (parent != null)
+ return parent.getNamespaceURI();
+ return null;
+ }
+
+ public String getPrefix()
+ {
+ if (parent != null)
+ return parent.getPrefix();
+ return null;
+ }
+
+ public String getVersion()
+ {
+ if (parent != null)
+ return parent.getVersion();
+ return null;
+ }
+
+ public boolean isStandalone()
+ {
+ if (parent != null)
+ return parent.isStandalone();
+ return false;
+ }
+
+ public boolean standaloneSet()
+ {
+ if (parent != null)
+ return parent.standaloneSet();
+ return false;
+ }
+
+ public String getCharacterEncodingScheme()
+ {
+ if (parent != null)
+ return parent.getCharacterEncodingScheme();
+ return null;
+ }
+
+ public String getPITarget()
+ {
+ if (parent != null)
+ return parent.getPITarget();
+ return null;
+ }
+
+ public String getPIData()
+ {
+ if (parent != null)
+ return parent.getPIData();
+ return null;
+ }
+
+ public Object getProperty(String name)
+ {
+ if (parent != null)
+ return parent.getProperty(name);
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java b/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java
new file mode 100644
index 000000000..b8a7ddab8
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java
@@ -0,0 +1,68 @@
+/* XMLEventAllocator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.util;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Interface for allocating events according to a stream reader.
+ */
+public interface XMLEventAllocator
+{
+
+ /**
+ * Creates a new allocator.
+ */
+ XMLEventAllocator newInstance();
+
+ /**
+ * Allocates an event based on the current state of the stream reader.
+ */
+ XMLEvent allocate(XMLStreamReader reader)
+ throws XMLStreamException;
+
+ /**
+ * Allocates one or more events based on the current state of the stream
+ * reader and adds those events to the specified consumer.
+ */
+ void allocate(XMLStreamReader reader, XMLEventConsumer consumer)
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java b/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java
new file mode 100644
index 000000000..3a825f9de
--- /dev/null
+++ b/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java
@@ -0,0 +1,55 @@
+/* XMLEventConsumer.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.stream.util;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ * Interface for consuming XML events.
+ */
+public interface XMLEventConsumer
+{
+
+ /**
+ * Consumes an event.
+ */
+ void add(XMLEvent event)
+ throws XMLStreamException;
+
+}
diff --git a/libjava/classpath/javax/xml/transform/ErrorListener.java b/libjava/classpath/javax/xml/transform/ErrorListener.java
new file mode 100644
index 000000000..ac236642a
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/ErrorListener.java
@@ -0,0 +1,66 @@
+/* ErrorListener.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * Error reporting callback handler.
+ * Equivalent to the SAX ErrorHandler.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface ErrorListener
+{
+
+ /**
+ * Reports a warning condition.
+ */
+ public void warning(TransformerException exception)
+ throws TransformerException;
+
+ /**
+ * Reports a recoverable error.
+ */
+ public void error(TransformerException exception)
+ throws TransformerException;
+
+ /**
+ * Reports a fatal error.
+ */
+ public void fatalError(TransformerException exception)
+ throws TransformerException;
+
+}
diff --git a/libjava/classpath/javax/xml/transform/OutputKeys.java b/libjava/classpath/javax/xml/transform/OutputKeys.java
new file mode 100644
index 000000000..09cf96cb9
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/OutputKeys.java
@@ -0,0 +1,103 @@
+/* OutputKeys.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+/**
+ * Constants for XSLT output attributes.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class OutputKeys
+{
+
+ /**
+ * The output method (xml, html, or text).
+ */
+ public static final String METHOD = "method";
+
+ /**
+ * The version of the output method.
+ */
+ public static final String VERSION = "version";
+
+ /**
+ * The preferred output character encoding.
+ */
+ public static final String ENCODING = "encoding";
+
+ /**
+ * Whether not to output an XML declaration (yes or no).
+ */
+ public static final String OMIT_XML_DECLARATION = "omit-xml-declaration";
+
+ /**
+ * Whether to output a standalone document declaration (yes or no).
+ */
+ public static final String STANDALONE = "standalone";
+
+ /**
+ * The public ID to output in the doctype declaration.
+ */
+ public static final String DOCTYPE_PUBLIC = "doctype-public";
+
+ /**
+ * The system ID to output in the doctype declaration.
+ */
+ public static final String DOCTYPE_SYSTEM = "doctype-system";
+
+ /**
+ * Whitespace-separated list of element names for which text children
+ * should be output as CDATA sections.
+ */
+ public static final String CDATA_SECTION_ELEMENTS = "cdata-section-elements";
+
+ /**
+ * Whether to indent the result tree (yes or no).
+ */
+ public static final String INDENT = "indent";
+
+ /**
+ * The MIME content type of the output data.
+ */
+ public static final String MEDIA_TYPE = "media-type";
+
+ private OutputKeys()
+ {
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/Result.java b/libjava/classpath/javax/xml/transform/Result.java
new file mode 100644
index 000000000..8f4d6c714
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/Result.java
@@ -0,0 +1,72 @@
+/* Result.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * The result of an XSL transformation.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface Result
+{
+
+ /**
+ * Constant for the processing instruction sent when the result disables
+ * output escaping.
+ */
+ public static final String PI_DISABLE_OUTPUT_ESCAPING =
+ "javax.xml.transform.disable-output-escaping";
+
+ /**
+ * Constant for the processing instruction sent when the result enables
+ * output escaping.
+ */
+ public static final String PI_ENABLE_OUTPUT_ESCAPING =
+ "javax.xml.transform.enable-output-escaping";
+
+ /**
+ * Sets the XML system ID for this result.
+ * @param systemId the system ID URI
+ */
+ public void setSystemId(String systemId);
+
+ /**
+ * Returns the system ID for this result.
+ */
+ public String getSystemId();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/Source.java b/libjava/classpath/javax/xml/transform/Source.java
new file mode 100644
index 000000000..f109dcc35
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/Source.java
@@ -0,0 +1,60 @@
+/* Source.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * An XML input source.
+ * This is equivalent to a SAX InputSource.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface Source
+{
+
+ /**
+ * Sets the XML system ID for this source.
+ * This can be used to resolve external entities in the source.
+ * @param systemId the system ID URI
+ */
+ public void setSystemId(String systemId);
+
+ /**
+ * Returns the system ID for this source.
+ */
+ public String getSystemId();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/SourceLocator.java b/libjava/classpath/javax/xml/transform/SourceLocator.java
new file mode 100644
index 000000000..190a3b165
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/SourceLocator.java
@@ -0,0 +1,70 @@
+/* SourceLocator.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * The location in an XML resource at which an event occurred.
+ * Tis is equivalent to the SAX Locator.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface SourceLocator
+{
+
+ /**
+ * Returns the XML public ID for the document.
+ */
+ public String getPublicId();
+
+ /**
+ * Returns the XML system ID for the document.
+ */
+ public String getSystemId();
+
+ /**
+ * Returns the line number at which the event occurred.
+ * @return the line number, or -1 if not available
+ */
+ public int getLineNumber();
+
+ /**
+ * Returns the column number at which the event occurred.
+ * @return the column number, or -1 if not available
+ */
+ public int getColumnNumber();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/Templates.java b/libjava/classpath/javax/xml/transform/Templates.java
new file mode 100644
index 000000000..34d953327
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/Templates.java
@@ -0,0 +1,67 @@
+/* Templates.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+import java.util.Properties;
+
+/**
+ * A compiled, reusable XSL transformation.
+ * Implementations of this class are guaranteed to be thread safe.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface Templates
+{
+
+ /**
+ * Creates a new transformer based on this transformation.
+ */
+ public Transformer newTransformer()
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns the static properties for the <code>xsl:output</code>
+ * instruction. Missing properties are defaulted according the
+ * <a href='http://www.w3.org/TR/xslt#output'>XSLT Recommendation, section
+ * 16</a>: <code>getProperty(String)</code> returns all properties
+ * including defaulted ones, and <code>get(Object)</code> returns only the
+ * properties explicitly set in the stylesheet.
+ */
+ public Properties getOutputProperties();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/Transformer.java b/libjava/classpath/javax/xml/transform/Transformer.java
new file mode 100644
index 000000000..316675b41
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/Transformer.java
@@ -0,0 +1,164 @@
+/* Transformer.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+import java.util.Properties;
+
+/**
+ * An XSL transformation.
+ * Instances of this class may be reused, but the same instance may not be
+ * used concurrently by different threads.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class Transformer
+{
+
+ protected Transformer()
+ {
+ }
+
+ /**
+ * Transforms the source XML to a result tree.
+ * @param xmlSource the XML source
+ * @param outputTarget the result of the transformation
+ */
+ public abstract void transform(Source xmlSource, Result outputTarget)
+ throws TransformerException;
+
+ /**
+ * Sets a parameter value for the transformation.
+ * Parameters may be referenced in the XSLT stylesheet.
+ * @param name the parameter name (an XML Name, or a namespace-prefixed
+ * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
+ * @param value the value to assign
+ */
+ public abstract void setParameter(String name, Object value);
+
+ /**
+ * Returns the specified parameter value.
+ * @param name the parameter name (an XML Name, or a namespace-prefixed
+ * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
+ */
+ public abstract Object getParameter(String name);
+
+ /**
+ * Clears all parameter values.
+ */
+ public abstract void clearParameters();
+
+ /**
+ * Sets the callback used to resolve entities referenced by
+ * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath
+ * <code>document()</code> function.
+ */
+ public abstract void setURIResolver(URIResolver resolver);
+
+ /**
+ * Returns the callback used to resolve entities referenced by
+ * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath
+ * <code>document()</code> function.
+ */
+ public abstract URIResolver getURIResolver();
+
+ /**
+ * Sets the output properties for the transformation, overriding any
+ * properties defined in the stylesheet.
+ * The format of property keys is as in the
+ * {@link #setOutputProperty(java.lang.String,java.lang.String)} method.
+ * @param oformat a set of output properties, or null to reset all the
+ * properties to their default values
+ */
+ public abstract void setOutputProperties(Properties oformat)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a copy of the output properties for the transformation.
+ * Missing properties are defaulted according the
+ * <a href='http://www.w3.org/TR/xslt#output'>XSLT Recommendation, section
+ * 16</a>: <code>getProperty(String)</code> returns all properties
+ * including defaulted ones, and <code>get(Object)</code> returns only the
+ * properties explicitly set in the stylesheet.
+ */
+ public abstract Properties getOutputProperties();
+
+ /**
+ * Sets an output property for the transformation, overriding any property
+ * of the same name defined in the stylesheet.
+ * @param name the property name (an XML Name, or a namespace-prefixed
+ * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
+ * @param value the string value of the property
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract void setOutputProperty(String name, String value)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the value of an output property for the transformation.
+ * Only explicit properties set programmatically or defined in the
+ * stylesheet, not defaulted properties, are returned by this method.
+ * @param name the property name (an XML Name, or a namespace-prefixed
+ * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
+ * @exception IllegalArgumentException if the property is not supported
+ */
+ public abstract String getOutputProperty(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Sets the callback used to report errors during the transformation.
+ * @exception IllegalArgumentException if the listener is null
+ */
+ public abstract void setErrorListener(ErrorListener listener)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the callback used to report errors during the transformation.
+ */
+ public abstract ErrorListener getErrorListener();
+
+ // -- JAXP 1.3 methods --
+
+ /**
+ * Reset this Transformer to its original configuration.
+ * @since 1.3
+ */
+ public void reset()
+ {
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/TransformerConfigurationException.java b/libjava/classpath/javax/xml/transform/TransformerConfigurationException.java
new file mode 100644
index 000000000..3343a8041
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/TransformerConfigurationException.java
@@ -0,0 +1,101 @@
+/* TransformerConfigurationException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+/**
+ * An exception occurred during configuration of the transformer.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class TransformerConfigurationException
+ extends TransformerException
+{
+ private static final long serialVersionUID = 1285547467942875745L;
+
+ /**
+ * Constructor with no detail message.
+ */
+ public TransformerConfigurationException()
+ {
+ this(null, null, null);
+ }
+
+ /**
+ * Constructor with a detail message.
+ */
+ public TransformerConfigurationException(String msg)
+ {
+ this(msg, null, null);
+ }
+
+ /**
+ * Constructor with underlying cause.
+ */
+ public TransformerConfigurationException(Throwable e)
+ {
+ this(e.getMessage(), null, e);
+ }
+
+ /**
+ * Constructor with detail message and underlyinmg cause.
+ */
+ public TransformerConfigurationException(String msg, Throwable e)
+ {
+ this(msg, null, e);
+ }
+
+ /**
+ * Constructor with detail message and locator.
+ */
+ public TransformerConfigurationException(String message,
+ SourceLocator locator)
+ {
+ this(message, locator, null);
+ }
+
+ /**
+ * Constructor with detail message, locator and underlying cause.
+ */
+ public TransformerConfigurationException(String message,
+ SourceLocator locator,
+ Throwable e)
+ {
+ super(message, locator, e);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/TransformerException.java b/libjava/classpath/javax/xml/transform/TransformerException.java
new file mode 100644
index 000000000..ac83e969c
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/TransformerException.java
@@ -0,0 +1,246 @@
+/* TransformerException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * An exception occurred during the transformation process.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class TransformerException
+ extends Exception
+{
+ private static final long serialVersionUID = 975798773772956428L;
+
+ // Field names fixed by serialization spec.
+ private SourceLocator locator;
+ private Throwable containedException;
+
+ /**
+ * Constructor with a detail message.
+ */
+ public TransformerException(String msg)
+ {
+ this(msg, null, null);
+ }
+
+ /**
+ * Constructor with an underlying cause.
+ */
+ public TransformerException(Throwable cause)
+ {
+ this(cause.getMessage(), null, cause);
+ }
+
+ /**
+ * Constructor with a detail message and underlying cause.
+ */
+ public TransformerException(String msg, Throwable cause)
+ {
+ this(msg, null, cause);
+ }
+
+ /**
+ * Constructor with a detail message and locator.
+ */
+ public TransformerException(String msg, SourceLocator locator)
+ {
+ this(msg, locator, null);
+ }
+
+ /**
+ * Constructor with detail message, locator and underlying cause.
+ */
+ public TransformerException(String msg, SourceLocator locator,
+ Throwable cause)
+ {
+ super(msg);
+ this.locator = locator;
+ if (cause != null)
+ {
+ initCause(cause);
+ this.containedException = cause;
+ }
+ }
+
+ /**
+ * Returns a locator indicating where the error occurred.
+ */
+ public SourceLocator getLocator()
+ {
+ return locator;
+ }
+
+ /**
+ * Sets the locator indicating where the error occurred.
+ */
+ public void setLocator(SourceLocator location)
+ {
+ locator = location;
+ }
+
+ /**
+ * Returns the underlying cause of this exception.
+ */
+ public Throwable getException()
+ {
+ return containedException;
+ }
+
+ /**
+ * Returns the underlying cause of this exception.
+ */
+ public Throwable getCause()
+ {
+ return containedException;
+ }
+
+ /**
+ * Initializes the root cause of this exception.
+ * This method may be called only once, and will be called by the
+ * constructor if a non-null cause is specified.
+ * Really phenomenally poor API design.
+ * @param cause the underlying cause
+ * @exception IllegalArgumentException if this exception is passed as the
+ * argument
+ * @exception IllegalStateException if a cause has already been
+ * initialized
+ */
+ public Throwable initCause(Throwable cause)
+ {
+ if (this.containedException != null)
+ {
+ throw new IllegalStateException();
+ }
+ if (cause == this)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.containedException = cause;
+ return this;
+ }
+
+ /**
+ * Returns the exception message with location information appended.
+ */
+ public String getMessageAndLocation()
+ {
+ return (locator == null) ? getMessage() :
+ getMessage() + ": " + getLocationAsString();
+ }
+
+ /**
+ * Returns the location information as a string.
+ */
+ public String getLocationAsString()
+ {
+ if (locator == null)
+ {
+ return null;
+ }
+ String publicId = locator.getPublicId();
+ String systemId = locator.getSystemId();
+ int lineNumber = locator.getLineNumber();
+ int columnNumber = locator.getColumnNumber();
+ CPStringBuilder buffer = new CPStringBuilder ();
+ if (publicId != null)
+ {
+ buffer.append ("publicId=");
+ buffer.append (publicId);
+ }
+ if (systemId != null)
+ {
+ if (buffer.length() > 0)
+ {
+ buffer.append(' ');
+ }
+ buffer.append ("systemId=");
+ buffer.append (systemId);
+ }
+ if (lineNumber != -1)
+ {
+ if (buffer.length() > 0)
+ {
+ buffer.append(' ');
+ }
+ buffer.append ("lineNumber=");
+ buffer.append (lineNumber);
+ }
+ if (columnNumber != -1)
+ {
+ if (buffer.length() > 0)
+ {
+ buffer.append(' ');
+ }
+ buffer.append ("columnNumber=");
+ buffer.append (columnNumber);
+ }
+ return buffer.toString();
+ }
+
+ public void printStackTrace()
+ {
+ printStackTrace(System.out);
+ }
+
+ public void printStackTrace(PrintStream s)
+ {
+ super.printStackTrace(s);
+ if (containedException != null)
+ {
+ s.print("caused by ");
+ containedException.printStackTrace(s);
+ }
+ }
+
+ public void printStackTrace(PrintWriter s)
+ {
+ super.printStackTrace(s);
+ if (containedException != null)
+ {
+ s.print("caused by ");
+ containedException.printStackTrace(s);
+ }
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/TransformerFactory.java b/libjava/classpath/javax/xml/transform/TransformerFactory.java
new file mode 100644
index 000000000..0bcc48627
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/TransformerFactory.java
@@ -0,0 +1,284 @@
+/* TransformerFactory.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Factory for obtaining transformation contexts.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class TransformerFactory
+{
+
+ protected TransformerFactory()
+ {
+ }
+
+ /**
+ * Creates a new factory instance.
+ * The implementation class to load is the first found in the following
+ * locations:
+ * <ol>
+ * <li>the <code>javax.xml.transform.TransformerFactory</code> system
+ * property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/jaxp.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.parsers.DocumentBuilderFactory</code>
+ * system resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ */
+ public static TransformerFactory newInstance()
+ throws TransformerFactoryConfigurationError
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = TransformerFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (TransformerFactory) t.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new TransformerFactoryConfigurationError(e,
+ "error instantiating class " + className);
+ }
+ }
+ }
+ while (className == null && count < 3);
+ try
+ {
+ Class<?> t =
+ Class.forName("gnu.xml.transform.TransformerFactoryImpl");
+ return (TransformerFactory) t.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new TransformerFactoryConfigurationError(e);
+ }
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = "javax.xml.transform.TransformerFactory";
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "jaxp.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ TransformerFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Creates a new transformer using the specified stylesheet.
+ * @param source the source of an <a href='http://www.w3.org/TR/xslt'>XSLT
+ * stylesheet</a> specifying the transformation to apply
+ */
+ public abstract Transformer newTransformer(Source source)
+ throws TransformerConfigurationException;
+
+ /**
+ * Creates a new transformer that applies the identity transform.
+ */
+ public abstract Transformer newTransformer()
+ throws TransformerConfigurationException;
+
+ /**
+ * Creates a new compiled transformation using the specified stylesheet.
+ * @param source the source of an <a href='http://www.w3.org/TR/xslt'>XSLT
+ * stylesheet</a> specifying the transformation to apply
+ */
+ public abstract Templates newTemplates(Source source)
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns a source object representing the XML resource specified by the
+ * <a href='http://www.w3.org/TR/xml-stylesheet/'>xml-stylesheet</a>
+ * processing instruction and matching the given criteria.
+ * Note that if multiple stylesheets are selected, the source represents a
+ * stylesheet composed of a list of imports.
+ * @param source the source XML document
+ * @param media the media attribute to match, or <code>null</code> to match
+ * the preferred templates
+ * @param title the title attribute to match, or <code>null</code> to match
+ * any
+ * @param charset the charset attribute to match, or <code>null</code> to
+ * match any
+ */
+ public abstract Source getAssociatedStylesheet(Source source,
+ String media,
+ String title,
+ String charset)
+ throws TransformerConfigurationException;
+
+ /**
+ * Set the resolver callback to be used by transformers obtained from
+ * this factory.
+ */
+ public abstract void setURIResolver(URIResolver resolver);
+
+ /**
+ * Returns the resolver callback to be used by transformers obtained from
+ * this factory.
+ */
+ public abstract URIResolver getURIResolver();
+
+ /**
+ * Sets a feature of transformers and templates obtained from this
+ * factory.
+ * Feature names are fully qualified URIs, and may depend on the factory
+ * implementation.
+ * @param name the name of the feature
+ * @param value the feature state
+ * @exception TransformerConfigurationException if the feature is
+ * unsupported
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns the state of a feature in the factory implementation.
+ * Feature names are fully qualified URIs, and may depend on the factory
+ * implementation. JAXP also predefines several features, including the
+ * constants in {@link javax.xml.XMLConstants} and
+ * <ul>
+ * <li>{@link javax.xml.transform.dom.DOMSource#FEATURE}</li>
+ * <li>{@link javax.xml.transform.dom.DOMResult#FEATURE}</li>
+ * <li>{@link javax.xml.transform.sax.SAXSource#FEATURE}</li>
+ * <li>{@link javax.xml.transform.sax.SAXResult#FEATURE}</li>
+ * <li>{@link javax.xml.transform.sax.SAXTransformerFactory#FEATURE}</li>
+ * <li>{@link javax.xml.transform.sax.SAXTransformerFactory#FEATURE_XMLFILTER}</li>
+ * <li>{@link javax.xml.transform.stream.StreamSource#FEATURE}</li>
+ * <li>{@link javax.xml.transform.stream.StreamResult#FEATURE}</li>
+ * </ul>
+ * The latter expose various capabilities of the factory implementation.
+ */
+ public abstract boolean getFeature(String name);
+
+ /**
+ * Set a named attribute on the underlying implementation.
+ * @param name the attribute name
+ * @param value the value to assign
+ * @exception IllegalArgumentException if the attribute is not supported
+ */
+ public abstract void setAttribute(String name, Object value)
+ throws IllegalArgumentException;
+
+ /**
+ * Retrieve the specified named attribute value.
+ * @param name the attribute name
+ * @exception IllegalArgumentException if the attribute is not supported
+ */
+ public abstract Object getAttribute(String name)
+ throws IllegalArgumentException;
+
+ /**
+ * Sets the callback to be used by transformers obtained from this factory
+ * to report transformation errors.
+ */
+ public abstract void setErrorListener(ErrorListener listener)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the callback to be used by transformers obtained from this
+ * factory to report transformation errors.
+ */
+ public abstract ErrorListener getErrorListener();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/TransformerFactoryConfigurationError.java b/libjava/classpath/javax/xml/transform/TransformerFactoryConfigurationError.java
new file mode 100644
index 000000000..45e3d3928
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/TransformerFactoryConfigurationError.java
@@ -0,0 +1,106 @@
+/* TransformerFactoryConfigurationError.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * An error occurred during configuration of the transformer factory.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class TransformerFactoryConfigurationError
+ extends Error
+{
+ private static final long serialVersionUID = -6527718720676281516L;
+
+ // Name is fixed by the serialization spec.
+ private final Exception exception;
+
+ /**
+ * Constructor with no detail message.
+ */
+ public TransformerFactoryConfigurationError()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Constructor with a detail message.
+ */
+ public TransformerFactoryConfigurationError(String msg)
+ {
+ this(null, msg);
+ }
+
+ /**
+ * Constructor with an underlying cause.
+ */
+ public TransformerFactoryConfigurationError(Exception e)
+ {
+ this(e, null);
+ }
+
+ /**
+ * Constructor with an underlying cause and detail message.
+ */
+ public TransformerFactoryConfigurationError(Exception e, String msg)
+ {
+ super(msg);
+ exception = e;
+ }
+
+ /**
+ * Returns the detail message.
+ */
+ public String getMessage()
+ {
+ String message = super.getMessage();
+ if (message == null && exception != null)
+ {
+ message = exception.getMessage();
+ }
+ return message;
+ }
+
+ /**
+ * Returns the underlying cause.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/URIResolver.java b/libjava/classpath/javax/xml/transform/URIResolver.java
new file mode 100644
index 000000000..e6315bba4
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/URIResolver.java
@@ -0,0 +1,58 @@
+/* URIResolver.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package javax.xml.transform;
+
+/**
+ * Callback that can resolve a URI into source XML for transformation.
+ * Equivalent to the SAX EntityResolver.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface URIResolver
+{
+
+ /**
+ * Resolves an <code>xsl:include</code>, <code>xsl:import</code>, or
+ * XPath <code>document()</code> function.
+ * @param href the URI to resolve (relative or absolute)
+ * @param base the base URI relative to which the URI is to be resolved
+ * @return a source, or null if the resource could not be found
+ */
+ public Source resolve(String href, String base)
+ throws TransformerException;
+
+}
diff --git a/libjava/classpath/javax/xml/transform/dom/DOMLocator.java b/libjava/classpath/javax/xml/transform/dom/DOMLocator.java
new file mode 100644
index 000000000..acea08e57
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/dom/DOMLocator.java
@@ -0,0 +1,57 @@
+/* DOMLocator.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.dom;
+
+import javax.xml.transform.SourceLocator;
+import org.w3c.dom.Node;
+
+/**
+ * Locator for reporting a location in a W3C DOM object graph.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface DOMLocator
+ extends SourceLocator
+{
+
+ /**
+ * Returns the node on which the event originated.
+ */
+ public Node getOriginatingNode();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/dom/DOMResult.java b/libjava/classpath/javax/xml/transform/dom/DOMResult.java
new file mode 100644
index 000000000..7577f2d98
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/dom/DOMResult.java
@@ -0,0 +1,163 @@
+/* DOMResult.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.dom;
+
+import javax.xml.transform.Result;
+import org.w3c.dom.Node;
+
+/**
+ * Output result specified as a W3C DOM object graph.
+ * The result tree may be appended to an existing tree.
+ * If no target node is specified, the result tree will be made available by
+ * the {@link #getNode} method after the transformation.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class DOMResult
+ implements Result
+{
+
+ /**
+ * Factory feature indicating that DOM results are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.dom.DOMResult/feature";
+
+ private Node node;
+ private Node nextSibling;
+ private String systemId;
+
+ /**
+ * Default constructor.
+ */
+ public DOMResult()
+ {
+ this(null, null, null);
+ }
+
+ /**
+ * Constructor with the node to append to.
+ */
+ public DOMResult(Node node)
+ {
+ this(node, null, null);
+ }
+
+ /**
+ * Constructor with the node to append to and the child node before which
+ * the result should be appended.
+ * @since 1.3
+ */
+ public DOMResult(Node node, Node nextSibling)
+ {
+ this(node, nextSibling, null);
+ }
+
+ /**
+ * Constructor with the node to append to and the system ID.
+ */
+ public DOMResult(Node node, String systemID)
+ {
+ this(node, null, systemID);
+ }
+
+ /**
+ * Constructor with the node to append to, the child node before which
+ * the result should be appended, and the system ID.
+ * @since 1.3
+ */
+ public DOMResult(Node node, Node nextSibling, String systemID)
+ {
+ this.node = node;
+ this.nextSibling = nextSibling;
+ this.systemId = systemID;
+ }
+
+ /**
+ * Sets the node to which the result tree will be appended.
+ * @param node the node
+ */
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ /**
+ * Returns the node to which the result tree is to be appended,
+ * or the result tree after transformation if no node was previously set.
+ */
+ public Node getNode()
+ {
+ return node;
+ }
+
+ /**
+ * Sets the child node before which the result nodes will be inserted.
+ * @since 1.3
+ */
+ public void setNextSibling(Node nextSibling)
+ {
+ this.nextSibling = nextSibling;
+ }
+
+ /**
+ * Returns the child node before which the result nodes will be inserted.
+ * @since 1.3
+ */
+ public Node getNextSibling()
+ {
+ return nextSibling;
+ }
+
+ /**
+ * Sets the system ID used to resolve external entities.
+ */
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Returns the system ID used to resolve external entities.
+ */
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/dom/DOMSource.java b/libjava/classpath/javax/xml/transform/dom/DOMSource.java
new file mode 100644
index 000000000..5922665a0
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/dom/DOMSource.java
@@ -0,0 +1,118 @@
+/* DOMSource.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.dom;
+
+import javax.xml.transform.Source;
+import org.w3c.dom.Node;
+
+/**
+ * An XML source specified as a W3C DOM node context.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class DOMSource
+ implements Source
+{
+
+ /**
+ * Factory feature indicating that DOM sources are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.dom.DOMSource/feature";
+
+ private Node node;
+ private String systemId;
+
+ /**
+ * Default constructor.
+ */
+ public DOMSource()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Constructor with a context node.
+ */
+ public DOMSource(Node node)
+ {
+ this(node, null);
+ }
+
+ /**
+ * Constructor with a context node and system ID.
+ */
+ public DOMSource(Node node, String systemId)
+ {
+ this.node = node;
+ this.systemId = systemId;
+ }
+
+ /**
+ * Sets the context node.
+ */
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ /**
+ * Returns the context node.
+ */
+ public Node getNode()
+ {
+ return node;
+ }
+
+ /**
+ * Sets the base URI to use as the context for resolving entities.
+ */
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Returns the base URI to use as the context for resolving entities.
+ */
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/dom/package.html b/libjava/classpath/javax/xml/transform/dom/package.html
new file mode 100644
index 000000000..0600fc724
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/dom/package.html
@@ -0,0 +1,5 @@
+<html><head>trax for dom</head><body>
+
+<p>Support for DOM inputs and outputs to transformers.
+
+</body></html>
diff --git a/libjava/classpath/javax/xml/transform/package.html b/libjava/classpath/javax/xml/transform/package.html
new file mode 100644
index 000000000..bc67c2b80
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/package.html
@@ -0,0 +1,38 @@
+<html><head>trax </head><body>
+
+<p>Base "TRAX" API for XSLT transformers.
+This API borrows many structural notions from SAX,
+such as the way error handling and external entity
+resolution are handled, although it does not reuse
+the corresponding SAX classes.
+To use XSLT transformers: <ul>
+
+<li>Start with <em>TransformerFactory.newInstance()</em>;
+
+<li>Then you may wish to configure that factory through
+its features and properties. This includes modifying
+the way errors are handled and URIs are resolved.
+
+<li>Then you have several options for how to perform
+the XSLT transformations. One generic option is to ask the
+factory for a <a href="Transformer.html">Transformer</a>
+and then use <em>Transformer.transform()</em> to pull
+input text onto output text.
+
+<li>Alternatively, most factories support flexible integration
+with SAX event streams. You can cast such factories to a
+<a href="sax/SAXTransformerFactory.html">SAXTransformerFactory</a>
+and perform either push or pull mode transformations.
+
+</ul>
+
+<p>The <a href="OutputKeys.html">OutputKeys</a> class
+holds constants that can be used to configure output
+properties used with <em>Result</em> objects, as if
+they were specified in <em>xslt:output</em> attributes
+in the stylesheet specifying the transform.
+
+<p>The <a href="Templates.html">Templates</a> class
+accomodates the notion of "compiled" transforms.
+
+</body></html>
diff --git a/libjava/classpath/javax/xml/transform/sax/SAXResult.java b/libjava/classpath/javax/xml/transform/sax/SAXResult.java
new file mode 100644
index 000000000..265b9512c
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/SAXResult.java
@@ -0,0 +1,132 @@
+/* SAXResult.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.sax;
+
+import javax.xml.transform.Result;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * Specifies SAX handlers to be used as a result sink during a
+ * transformation.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class SAXResult implements Result
+{
+
+ /**
+ * Factory feature indicating that SAX results are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.sax.SAXResult/feature";
+
+ private ContentHandler handler;
+ private LexicalHandler lexicalHandler;
+ private String systemId;
+
+ /**
+ * Default constructor.
+ */
+ public SAXResult()
+ {
+ }
+
+ /**
+ * Constructor specifying a content handler.
+ */
+ public SAXResult(ContentHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * Sets the content handler to which result document events will be
+ * propagated.
+ */
+ public void setHandler(ContentHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * Returns the content handler to which result document events will be
+ * propagated.
+ */
+ public ContentHandler getHandler()
+ {
+ return handler;
+ }
+
+ /**
+ * Sets the lexical handler to which lexical events will be propagated.
+ * If a lexical handler is not set, the transformer should attempt to cast
+ * the content handler to a lexical handler.
+ */
+ public void setLexicalHandler(LexicalHandler handler)
+ {
+ lexicalHandler = handler;
+ }
+
+ /**
+ * Returns the lexical handler to which lexical events will be propagated.
+ * If a lexical handler is not set, the transformer should attempt to cast
+ * the content handler to a lexical handler.
+ */
+ public LexicalHandler getLexicalHandler()
+ {
+ return lexicalHandler;
+ }
+
+ /**
+ * Sets the system ID which this result represents.
+ */
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Returns the system ID which this result represnts.
+ */
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/sax/SAXSource.java b/libjava/classpath/javax/xml/transform/sax/SAXSource.java
new file mode 100644
index 000000000..1ef4b7391
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/SAXSource.java
@@ -0,0 +1,197 @@
+/* SAXSource.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.sax;
+
+import java.io.InputStream;
+import java.io.Reader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * Specifies a SAX XML source. This is a tuple of input source and SAX
+ * parser.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class SAXSource
+ implements Source
+{
+
+ /**
+ * Factory feature indicating that SAX sources are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.sax.SAXSource/feature";
+
+ private XMLReader xmlReader;
+ private InputSource inputSource;
+
+ /**
+ * Default constructor.
+ */
+ public SAXSource()
+ {
+ }
+
+ /**
+ * Constructor with a SAX parser and input source.
+ */
+ public SAXSource(XMLReader reader, InputSource inputSource)
+ {
+ xmlReader = reader;
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Constructor with an input source.
+ * The SAX parser will be instantiated by the transformer.
+ */
+ public SAXSource(InputSource inputSource)
+ {
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Sets the SAX parser to be used by this source.
+ * If null, the transformer will instantiate its own parser.
+ */
+ public void setXMLReader(XMLReader reader)
+ {
+ xmlReader = reader;
+ }
+
+ /**
+ * Returns the SAX parser to be used by this source.
+ * If null, the transformer will instantiate its own parser.
+ */
+ public XMLReader getXMLReader()
+ {
+ return xmlReader;
+ }
+
+ /**
+ * Sets the input source to parse.
+ */
+ public void setInputSource(InputSource inputSource)
+ {
+ this.inputSource = inputSource;
+ }
+
+ /**
+ * Returns the input source to parse.
+ */
+ public InputSource getInputSource()
+ {
+ return inputSource;
+ }
+
+ /**
+ * Sets the system ID for this source.
+ */
+ public void setSystemId(String systemId)
+ {
+ if (inputSource != null)
+ {
+ inputSource.setSystemId(systemId);
+ }
+ }
+
+ /**
+ * Returns the system ID for this source.
+ */
+ public String getSystemId()
+ {
+ if (inputSource != null)
+ {
+ return inputSource.getSystemId();
+ }
+ return null;
+ }
+
+ /**
+ * Converts a source into a SAX input source.
+ * This method can use a StreamSource or the system ID.
+ * @return an input source or null
+ */
+ public static InputSource sourceToInputSource(Source source)
+ {
+ InputSource in = null;
+ if (source instanceof SAXSource)
+ {
+ in = ((SAXSource) source).getInputSource();
+ }
+ else if (source instanceof StreamSource)
+ {
+ StreamSource streamSource = (StreamSource) source;
+ InputStream inputStream = streamSource.getInputStream();
+ if (inputStream != null)
+ {
+ in = new InputSource(inputStream);
+ }
+ else
+ {
+ Reader reader = streamSource.getReader();
+ if (reader != null)
+ {
+ in = new InputSource(reader);
+ }
+ }
+ String publicId = streamSource.getPublicId();
+ if (publicId != null && in != null)
+ {
+ in.setPublicId(publicId);
+ }
+ }
+ String systemId = source.getSystemId();
+ if (systemId != null)
+ {
+ if (in == null)
+ {
+ in = new InputSource(systemId);
+ }
+ else
+ {
+ in.setSystemId(systemId);
+ }
+ }
+ return in;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/sax/SAXTransformerFactory.java b/libjava/classpath/javax/xml/transform/sax/SAXTransformerFactory.java
new file mode 100644
index 000000000..2e3713760
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/SAXTransformerFactory.java
@@ -0,0 +1,115 @@
+/* SAXTransformerFactory.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.sax;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import org.xml.sax.XMLFilter;
+
+/**
+ * Specialized transformer factory with support for SAX-specific factory
+ * methods.
+ * This factory provides SAX content handlers that can create transformation
+ * templates and transformers.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public abstract class SAXTransformerFactory extends TransformerFactory
+{
+
+ /**
+ * Factory feature indicating that the factory can be cast to this class.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.sax.SAXTransformerFactory/feature";
+
+ /**
+ * Factory feature indicating that this factory can create new XMLFilters.
+ */
+ public static final String FEATURE_XMLFILTER =
+ "http://javax.xml.transform.sax.SAXTransformerFactory/feature/xmlfilter";
+
+ protected SAXTransformerFactory()
+ {
+ }
+
+ /**
+ * Returns a content handler that can process SAX events into a result,
+ * using the specified transformation.
+ * @param src the source stylesheet
+ */
+ public abstract TransformerHandler newTransformerHandler(Source src)
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns a content handler that can process SAX events into a result,
+ * using the specified transformation.
+ * @param templates the compiled stylesheet
+ */
+ public abstract TransformerHandler newTransformerHandler(Templates templates)
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns a content handler that can process SAX events into a result,
+ * using the identity transform.
+ */
+ public abstract TransformerHandler newTransformerHandler()
+ throws TransformerConfigurationException;
+
+ /**
+ * Returns a content handler that can process SAX events into a
+ * transformation template.
+ */
+ public abstract TemplatesHandler newTemplatesHandler()
+ throws TransformerConfigurationException;
+
+ /**
+ * Creates an XML filter for the specified source.
+ */
+ public abstract XMLFilter newXMLFilter(Source src)
+ throws TransformerConfigurationException;
+
+ /**
+ * Creates an XML filter for the specified compiled stylesheet.
+ */
+ public abstract XMLFilter newXMLFilter(Templates templates)
+ throws TransformerConfigurationException;
+
+}
diff --git a/libjava/classpath/javax/xml/transform/sax/TemplatesHandler.java b/libjava/classpath/javax/xml/transform/sax/TemplatesHandler.java
new file mode 100644
index 000000000..86d46aceb
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/TemplatesHandler.java
@@ -0,0 +1,68 @@
+/* TemplatesHandler.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.sax;
+
+import javax.xml.transform.Templates;
+import org.xml.sax.ContentHandler;
+
+/**
+ * A content handler that processes SAX parse events into a compiled
+ * transformation template.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface TemplatesHandler
+ extends ContentHandler
+{
+
+ /**
+ * Returns the templates object created by the parsing of the SAX events.
+ */
+ public Templates getTemplates();
+
+ /**
+ * Sets the system ID for the templates object created by this processor.
+ */
+ public void setSystemId(String systemId);
+
+ /**
+ * Returns the system ID for the templates object created by this processor.
+ */
+ public String getSystemId();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/sax/TransformerHandler.java b/libjava/classpath/javax/xml/transform/sax/TransformerHandler.java
new file mode 100644
index 000000000..aae56e2a9
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/TransformerHandler.java
@@ -0,0 +1,78 @@
+/* TransformerHandler.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.sax;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * A content handler that transforms SAX events into a result tree.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public interface TransformerHandler
+ extends ContentHandler, LexicalHandler, DTDHandler
+{
+
+ /**
+ * Sets the result sink to be used as the output of the transformation.
+ * @exception IllegalArgumentException if the result is not a valid target
+ */
+ public void setResult(Result result)
+ throws IllegalArgumentException;
+
+ /**
+ * Sets the system ID relative to which URLs will be resolved.
+ */
+ public void setSystemId(String systemID);
+
+ /**
+ * Returns the system ID relative to which URLs will be resolved.
+ */
+ public String getSystemId();
+
+ /**
+ * Returns the transformer associated with this handler in order to set
+ * parameters and output properties.
+ */
+ public Transformer getTransformer();
+
+}
diff --git a/libjava/classpath/javax/xml/transform/sax/package.html b/libjava/classpath/javax/xml/transform/sax/package.html
new file mode 100644
index 000000000..b2d2978a3
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/sax/package.html
@@ -0,0 +1,9 @@
+<html><head>trax for sax</head><body>
+
+<p>Support for SAX2-based XSLT transformers.
+Normally you would cast a TransformerFactory to a
+<a href="SAXTransformerFactory.html">SAXTransformerFactory</a>
+and use that to in any of the various modes supported
+(such as push or pull).
+
+</body></html>
diff --git a/libjava/classpath/javax/xml/transform/stream/StreamResult.java b/libjava/classpath/javax/xml/transform/stream/StreamResult.java
new file mode 100644
index 000000000..b44e6ce58
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/stream/StreamResult.java
@@ -0,0 +1,173 @@
+/* StreamResult.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.stream;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import javax.xml.transform.Result;
+
+/**
+ * Specifies a stream to which to write the transformation result.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class StreamResult
+ implements Result
+{
+
+ /**
+ * Factory feature indicating that stream results are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.stream.StreamResult/feature";
+
+ private String systemId;
+ private OutputStream outputStream;
+ private Writer writer;
+
+ /**
+ * Default constructor.
+ */
+ public StreamResult()
+ {
+ }
+
+ /**
+ * Constructor with an output stream.
+ */
+ public StreamResult(OutputStream stream)
+ {
+ this.outputStream = stream;
+ }
+
+ /**
+ * Constructor with a writer.
+ * Prefer to use an output stream rather than a writer, so that the
+ * output encoding can be controlled by transformation properties.
+ */
+ public StreamResult(Writer writer)
+ {
+ this.writer = writer;
+ }
+
+ /**
+ * Constructor with a system ID.
+ */
+ public StreamResult(String systemID)
+ {
+ this.systemId = systemID;
+ }
+
+ /**
+ * Constructor with a system ID specified as a File object.
+ */
+ public StreamResult(File file)
+ {
+ setSystemId(file);
+ }
+
+ /**
+ * Sets the target output stream.
+ */
+ public void setOutputStream(OutputStream outputStream)
+ {
+ this.outputStream = outputStream;
+ }
+
+ /**
+ * Returns the target output stream.
+ */
+ public OutputStream getOutputStream()
+ {
+ return outputStream;
+ }
+
+ /**
+ * Sets the target writer.
+ * Prefer to use an output stream rather than a writer, so that the
+ * output encoding can be controlled by transformation properties.
+ */
+ public void setWriter(Writer writer)
+ {
+ this.writer = writer;
+ }
+
+ /**
+ * Returns the target writer.
+ */
+ public Writer getWriter()
+ {
+ return writer;
+ }
+
+ /**
+ * Sets the system ID.
+ * If neither the out stream nor the writer have been specified, the
+ * system ID will be treated as a URL for writing to.
+ */
+ public void setSystemId(String systemID)
+ {
+ this.systemId = systemID;
+ }
+
+ /**
+ * Sets the system ID from a File reference.
+ */
+ public void setSystemId(File f)
+ {
+ try
+ {
+ systemId = f.toURL().toString();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Returns the system ID.
+ */
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/stream/StreamSource.java b/libjava/classpath/javax/xml/transform/stream/StreamSource.java
new file mode 100644
index 000000000..def73d8c0
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/stream/StreamSource.java
@@ -0,0 +1,210 @@
+/* StreamSource.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.transform.stream;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import javax.xml.transform.Source;
+
+/**
+ * Specifies a stream from which to read the source XML data.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ */
+public class StreamSource
+ implements Source
+{
+
+ /**
+ * Factory feature indicating that stream sources are supported.
+ */
+ public static final String FEATURE =
+ "http://javax.xml.transform.stream.StreamSource/feature";
+
+ private String publicId;
+ private String systemId;
+ private InputStream inputStream;
+ private Reader reader;
+
+ /**
+ * Default constructor.
+ */
+ public StreamSource()
+ {
+ }
+
+ /**
+ * Constructor with an input stream.
+ */
+ public StreamSource(InputStream stream)
+ {
+ this.inputStream = stream;
+ }
+
+ /**
+ * Constructor with an input stream and system ID.
+ */
+ public StreamSource(InputStream stream, String systemId)
+ {
+ this.inputStream = stream;
+ this.systemId = systemId;
+ }
+
+ /**
+ * Constructor with a reader.
+ * Prefer an input stream to a reader, so that the parser can use the
+ * character encoding specified in the XML.
+ */
+ public StreamSource(Reader reader)
+ {
+ this.reader = reader;
+ }
+
+ /**
+ * Constructor with a reader and system ID.
+ * Prefer an input stream to a reader, so that the parser can use the
+ * character encoding specified in the XML.
+ */
+ public StreamSource(Reader reader, String systemId)
+ {
+ this.reader = reader;
+ this.systemId = systemId;
+ }
+
+ /**
+ * Constructor with a system ID.
+ */
+ public StreamSource(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Constructor with a system ID specified as a File reference.
+ */
+ public StreamSource(File file)
+ {
+ setSystemId(file);
+ }
+
+ /**
+ * Sets the source input stream.
+ */
+ public void setInputStream(InputStream stream)
+ {
+ this.inputStream = stream;
+ }
+
+ /**
+ * Returns the source input stream.
+ */
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ /**
+ * Sets the source reader.
+ * Prefer an input stream to a reader, so that the parser can use the
+ * character encoding specified in the XML.
+ */
+ public void setReader(Reader reader)
+ {
+ this.reader = reader;
+ }
+
+ /**
+ * Returns the source reader.
+ */
+ public Reader getReader()
+ {
+ return reader;
+ }
+
+ /**
+ * Sets the public ID for this source.
+ */
+ public void setPublicId(String publicId)
+ {
+ this.publicId = publicId;
+ }
+
+ /**
+ * Returns the public ID for this source.
+ */
+ public String getPublicId()
+ {
+ return publicId;
+ }
+
+ /**
+ * Sets the system ID for this source.
+ * If the input stream and reader are absent, the system ID will be used
+ * as a readable URL to locate the source data.
+ */
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Returns the system ID for this source.
+ */
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ /**
+ * Sets the system ID using a File reference.
+ */
+ public void setSystemId(File f)
+ {
+ try
+ {
+ this.systemId = f.toURL().toString();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/transform/stream/package.html b/libjava/classpath/javax/xml/transform/stream/package.html
new file mode 100644
index 000000000..f9d052b19
--- /dev/null
+++ b/libjava/classpath/javax/xml/transform/stream/package.html
@@ -0,0 +1,6 @@
+<html><head>trax for streams</head><body>
+
+<p>Support for text stream inputs and outputs to transformers.
+
+</body></html>
+
diff --git a/libjava/classpath/javax/xml/validation/Schema.java b/libjava/classpath/javax/xml/validation/Schema.java
new file mode 100644
index 000000000..1329eabf2
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/Schema.java
@@ -0,0 +1,61 @@
+/* Schema.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+/**
+ * An immutable grammar.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class Schema
+{
+
+ protected Schema()
+ {
+ }
+
+ /**
+ * Returns a new validator that can check the set of constraints this
+ * schema represents.
+ */
+ public abstract Validator newValidator();
+
+ public abstract ValidatorHandler newValidatorHandler();
+
+}
diff --git a/libjava/classpath/javax/xml/validation/SchemaFactory.java b/libjava/classpath/javax/xml/validation/SchemaFactory.java
new file mode 100644
index 000000000..1c099bbe2
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/SchemaFactory.java
@@ -0,0 +1,264 @@
+/* SchemaFactory.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * Factory for obtaining schemata.
+ *
+ * @author Chris Burdess (dog@gnu.org)
+ * @since 1.5
+ */
+public abstract class SchemaFactory
+{
+ protected SchemaFactory()
+ {
+ }
+
+ /**
+ * Returns an implementation of <code>SchemaFactory</code> that supports
+ * the specified schema language.
+ * @param schemaLanguage the URI of a schema language (see
+ * <code>XMLConstants</code>)
+ */
+ public static final SchemaFactory newInstance(String schemaLanguage)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = SchemaFactory.class.getClassLoader();
+ }
+ final String factoryClassName = "javax.xml.validation.SchemaFactory";
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, schemaLanguage, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ return (SchemaFactory) t.newInstance();
+ }
+ catch (Exception e)
+ {
+ // Ignore any errors and continue algorithm.
+ // This method doesn't have a means of propagating
+ // class instantiation errors.
+ className = null;
+ }
+ }
+ }
+ while (className == null && count < 2);
+ try
+ {
+ String serviceKey = "/META-INF/services/" + factoryClassName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ SchemaFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ try
+ {
+ for (String line = r.readLine(); line != null;
+ line = r.readLine())
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ SchemaFactory ret = (SchemaFactory) t.newInstance();
+ if (ret.isSchemaLanguageSupported(schemaLanguage))
+ return ret;
+ }
+ }
+ catch (Exception e)
+ {
+ // Fall through. See above.
+ }
+ finally
+ {
+ r.close();
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ // Default schema factories for Classpath
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schemaLanguage))
+ return new gnu.xml.validation.xmlschema.XMLSchemaSchemaFactory();
+ if (XMLConstants.RELAXNG_NS_URI.equals(schemaLanguage))
+ return new gnu.xml.validation.relaxng.RELAXNGSchemaFactory();
+ throw new IllegalArgumentException(schemaLanguage);
+ }
+
+ private static String getFactoryClassName(ClassLoader loader,
+ String schemaLanguage, int attempt)
+ {
+ final String factoryClassName = "javax.xml.validation.SchemaFactory";
+ final String propertyName = factoryClassName + ":" + schemaLanguage;
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "jaxp.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Indicates whether the specified schema language is supported.
+ * @param schemaLanguage the URI of a schema language (see
+ * <code>XMLConstants</code>)
+ */
+ public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
+
+ public boolean getFeature(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setFeature(String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public abstract ErrorHandler getErrorHandler();
+
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ public abstract LSResourceResolver getResourceResolver();
+
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ /**
+ * Returns a schema based on the specified source resource.
+ * @param schema the source resource
+ */
+ public Schema newSchema(Source schema)
+ throws SAXException
+ {
+ return newSchema(new Source[] { schema });
+ }
+
+ /**
+ * Returns a schema based on the specified source file.
+ * @param schema the source resource
+ */
+ public Schema newSchema(File schema)
+ throws SAXException
+ {
+ return newSchema(new StreamSource(schema));
+ }
+
+ /**
+ * Returns a schema based on the specified URL.
+ * @param schema the source resource
+ */
+ public Schema newSchema(URL schema)
+ throws SAXException
+ {
+ return newSchema(new StreamSource(schema.toString()));
+ }
+
+ /**
+ * Parses the specified sources, and combine them into a single schema.
+ * The exact procedure and semantics of this depends on the schema
+ * language.
+ * @param schemata the schema resources to load
+ */
+ public abstract Schema newSchema(Source[] schemata)
+ throws SAXException;
+
+ /**
+ * Creates a special schema.
+ * The exact semantics of this depends on the schema language.
+ */
+ public abstract Schema newSchema()
+ throws SAXException;
+
+}
diff --git a/libjava/classpath/javax/xml/validation/SchemaFactoryLoader.java b/libjava/classpath/javax/xml/validation/SchemaFactoryLoader.java
new file mode 100644
index 000000000..7d6013835
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/SchemaFactoryLoader.java
@@ -0,0 +1,52 @@
+/* SchemaFactory.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+/**
+ * API compatibility class. Do not use.
+ */
+public abstract class SchemaFactoryLoader
+{
+
+ protected SchemaFactoryLoader()
+ {
+ }
+
+ public abstract SchemaFactory newFactory(String schemaLanguage);
+
+}
diff --git a/libjava/classpath/javax/xml/validation/TypeInfoProvider.java b/libjava/classpath/javax/xml/validation/TypeInfoProvider.java
new file mode 100644
index 000000000..c8bb227ec
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/TypeInfoProvider.java
@@ -0,0 +1,83 @@
+/* TypeInfoProvider.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Provides access to the PSVI type info supplied by
+ * <code>ValidatorHandler</code>.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class TypeInfoProvider
+{
+
+ protected TypeInfoProvider()
+ {
+ }
+
+ /**
+ * Returns the type information for the current element.
+ */
+ public abstract TypeInfo getElementTypeInfo();
+
+ /**
+ * Returns the type information for the specified attribute of the current
+ * element.
+ * @param index the attribute index as for the Attributes object passed to
+ * the startElement callback
+ */
+ public abstract TypeInfo getAttributeTypeInfo(int index);
+
+ /**
+ * Indicates if the attribute at the specified index is of the ID type.
+ * @param index the attribute index as for the Attributes object passed to
+ * the startElement callback
+ */
+ public abstract boolean isIdAttribute(int index);
+
+ /**
+ * Returns false if the attribute was defaulted (added by the validator).
+ * @param index the attribute index as for the Attributes object passed to
+ * the startElement callback
+ */
+ public abstract boolean isSpecified(int index);
+
+}
diff --git a/libjava/classpath/javax/xml/validation/Validator.java b/libjava/classpath/javax/xml/validation/Validator.java
new file mode 100644
index 000000000..f12401a68
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/Validator.java
@@ -0,0 +1,117 @@
+/* Validator.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+import java.io.IOException;
+import javax.xml.transform.Source;
+import javax.xml.transform.Result;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * A processor that validates a document against a schema.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class Validator
+{
+
+ protected Validator()
+ {
+ }
+
+ /**
+ * Reset this validator to its original state.
+ */
+ public abstract void reset();
+
+ /**
+ * Validate the specified input.
+ * @param source the document to validate
+ */
+ public void validate(Source source)
+ throws SAXException, IOException
+ {
+ validate(source, null);
+ }
+
+ /**
+ * Validate the specified input.
+ * @param source the document to validate
+ * @param result the PSVI document to output
+ */
+ public abstract void validate(Source source, Result result)
+ throws SAXException, IOException;
+
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ public abstract ErrorHandler getErrorHandler();
+
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ public abstract LSResourceResolver getResourceResolver();
+
+ public boolean getFeature(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setFeature(String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/validation/ValidatorHandler.java b/libjava/classpath/javax/xml/validation/ValidatorHandler.java
new file mode 100644
index 000000000..639086bbf
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/ValidatorHandler.java
@@ -0,0 +1,115 @@
+/* ValidatorHandler.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.validation;
+
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/**
+ * A streaming validator that operates on a SAX event stream.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class ValidatorHandler
+ implements ContentHandler
+{
+
+ static final String NS_FEATURE =
+ "http://xml.org/sax/features/namespace-prefixes";
+
+ protected ValidatorHandler()
+ {
+ }
+
+ /**
+ * Sets the ContentHandler to receive PSVI SAX events.
+ */
+ public abstract void setContentHandler(ContentHandler receiver);
+
+ /**
+ * Returns the ContentHandler to receive PSVI SAX events.
+ */
+ public abstract ContentHandler getContentHandler();
+
+ public abstract void setErrorHandler(ErrorHandler errorHandler);
+
+ public abstract ErrorHandler getErrorHandler();
+
+ public abstract void setResourceResolver(LSResourceResolver resourceResolver);
+
+ public abstract LSResourceResolver getResourceResolver();
+
+ public abstract TypeInfoProvider getTypeInfoProvider();
+
+ public boolean getFeature(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (name.equals(NS_FEATURE))
+ {
+ return true;
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setFeature(String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (name.equals(NS_FEATURE))
+ {
+ throw new SAXNotSupportedException();
+ }
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+ public void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/validation/package.html b/libjava/classpath/javax/xml/validation/package.html
new file mode 100644
index 000000000..b4daa143a
--- /dev/null
+++ b/libjava/classpath/javax/xml/validation/package.html
@@ -0,0 +1,9 @@
+<html>
+<body>
+
+<div>
+API for the validation of XML documents using a range of schema languages.
+</div>
+
+</body>
+</html>
diff --git a/libjava/classpath/javax/xml/xpath/XPath.java b/libjava/classpath/javax/xml/xpath/XPath.java
new file mode 100644
index 000000000..eb652b1ae
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPath.java
@@ -0,0 +1,115 @@
+/* XPath.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import org.xml.sax.InputSource;
+
+/**
+ * Interface to the XPath evaluation environment.
+ * @since 1.3
+ */
+public interface XPath
+{
+
+ /**
+ * Resets the environment.
+ */
+ void reset();
+
+ void setXPathVariableResolver(XPathVariableResolver resolver);
+
+ XPathVariableResolver getXPathVariableResolver();
+
+ void setXPathFunctionResolver(XPathFunctionResolver resolver);
+
+ XPathFunctionResolver getXPathFunctionResolver();
+
+ void setNamespaceContext(NamespaceContext nsContext);
+
+ NamespaceContext getNamespaceContext();
+
+ /**
+ * Compiles an XPath expression for future evaluation.
+ * @param expression the expression
+ */
+ XPathExpression compile(String expression)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates an expression.
+ * @param expression the expression
+ * @param item the expression context
+ * @param returnType the desired return type
+ */
+ Object evaluate(String expression,
+ Object item,
+ QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates an expression and returns the result as a string.
+ * @param expression the expression
+ * @param item the expression context
+ */
+ String evaluate(String expression,
+ Object item)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates an expression.
+ * @param expression the expression
+ * @param source the source to load the expression context from
+ * @param returnType the desired return type
+ */
+ Object evaluate(String expression,
+ InputSource source,
+ QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates an expression and returns the result as a string.
+ * @param expression the expression
+ * @param source the source to load the expression context from
+ */
+ String evaluate(String expression,
+ InputSource source)
+ throws XPathExpressionException;
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathConstants.java b/libjava/classpath/javax/xml/xpath/XPathConstants.java
new file mode 100644
index 000000000..9c39db9f3
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathConstants.java
@@ -0,0 +1,91 @@
+/* XPathConstants.java --
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * XPath constants.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.5
+ */
+public class XPathConstants
+{
+ private XPathConstants()
+ {
+ // to prevent instantiation
+ }
+
+ /**
+ * The XPath 1.0 number data type.
+ */
+ public static final QName NUMBER =
+ new QName("http://java.sun.com/jaxp/xpath/dom#number", "");
+
+ /**
+ * The XPath 1.0 string data type.
+ */
+ public static final QName STRING =
+ new QName("http://java.sun.com/jaxp/xpath/dom#string", "");
+
+ /**
+ * The XPath 1.0 boolean data type.
+ */
+ public static final QName BOOLEAN =
+ new QName("http://java.sun.com/jaxp/xpath/dom#boolean", "");
+
+ /**
+ * The XPath 1.0 node-set data type.
+ */
+ public static final QName NODESET =
+ new QName("http://java.sun.com/jaxp/xpath/dom#node-set", "");
+
+ /**
+ * The XPath 1.0 node data type.
+ */
+ public static final QName NODE =
+ new QName("http://java.sun.com/jaxp/xpath/dom#node", "");
+
+ /**
+ * The URL for the JAXP DOM object model.
+ */
+ public static final String DOM_OBJECT_MODEL =
+ "http://java.sun.com/jaxp/xpath/dom";
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathException.java b/libjava/classpath/javax/xml/xpath/XPathException.java
new file mode 100644
index 000000000..7d45fa747
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathException.java
@@ -0,0 +1,88 @@
+/* XPathException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * A generic XPath exception.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public class XPathException
+ extends Exception
+{
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ // Name is fixed by serialization spec.
+ Throwable cause;
+
+ public XPathException(String message)
+ {
+ super(message);
+ }
+
+ public XPathException(Throwable cause)
+ {
+ super(cause);
+ this.cause = cause;
+ }
+
+ public Throwable getCause()
+ {
+ return cause;
+ }
+
+ public void printStackTrace()
+ {
+ super.printStackTrace();
+ }
+
+ public void printStackTrace(PrintStream out)
+ {
+ super.printStackTrace(out);
+ }
+
+ public void printStackTrace(PrintWriter out)
+ {
+ super.printStackTrace(out);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathExpression.java b/libjava/classpath/javax/xml/xpath/XPathExpression.java
new file mode 100644
index 000000000..89c6494c2
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathExpression.java
@@ -0,0 +1,86 @@
+/* XPathExpression.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+import org.xml.sax.InputSource;
+
+/**
+ * An XPath expression.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public interface XPathExpression
+{
+
+ /**
+ * Evaluates this expression against the specified context.
+ * @param item the evaluation context
+ * @param returnType the desired return type
+ */
+ Object evaluate(Object item,
+ QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates this expression against the specified context, returning the
+ * result as a string.
+ * @param item the evaluation context
+ */
+ String evaluate(Object item)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates this expression against the specified context.
+ * @param source the source to load the context from
+ * @param returnType the desired return type
+ */
+ Object evaluate(InputSource source,
+ QName returnType)
+ throws XPathExpressionException;
+
+ /**
+ * Evaluates this expression against the specified context, returning the
+ * result as a string.
+ * @param source the source to load the context from
+ */
+ String evaluate(InputSource source)
+ throws XPathExpressionException;
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathExpressionException.java b/libjava/classpath/javax/xml/xpath/XPathExpressionException.java
new file mode 100644
index 000000000..543570485
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathExpressionException.java
@@ -0,0 +1,61 @@
+/* XPathExpressionException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+/**
+ * An exception in an XPath expression.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public class XPathExpressionException
+ extends XPathException
+{
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ public XPathExpressionException(String message)
+ {
+ super(message);
+ }
+
+ public XPathExpressionException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathFactory.java b/libjava/classpath/javax/xml/xpath/XPathFactory.java
new file mode 100644
index 000000000..62c17154a
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathFactory.java
@@ -0,0 +1,227 @@
+/* XPathFactory.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Factory for creating XPath environments.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public abstract class XPathFactory
+{
+
+ /**
+ * The default property name according to the JAXP specification.
+ */
+ public static final String DEFAULT_PROPERTY_NAME =
+ "javax.xml.xpath.XPathFactory";
+
+ /**
+ * The default object model URI.
+ */
+ public static final String DEFAULT_OBJECT_MODEL_URI =
+ XPathConstants.DOM_OBJECT_MODEL;
+
+ protected XPathFactory()
+ {
+ }
+
+ /**
+ * Returns a new factory for the default (DOM) object model.
+ */
+ public static final XPathFactory newInstance()
+ {
+ try
+ {
+ return newInstance(DEFAULT_OBJECT_MODEL_URI);
+ }
+ catch (XPathFactoryConfigurationException e)
+ {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ /**
+ * Returns a new factory for the given object model URI.
+ * The implementation class to load is the first found in the following
+ * locations that advertises support for the given model URI:
+ * <ol>
+ * <li>the <code>javax.xml.xpath.XPathFactory</code> system property</li>
+ * <li>the above named property value in the
+ * <code><i>$JAVA_HOME</i>/lib/jaxp.properties</code> file</li>
+ * <li>the class name specified in the
+ * <code>META-INF/services/javax.xml.xpath.XPathFactory</code> system
+ * resource</li>
+ * <li>the default factory class</li>
+ * </ol>
+ * @param uri the object model URI
+ */
+ public static final XPathFactory newInstance(String uri)
+ throws XPathFactoryConfigurationException
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ {
+ loader = XPathFactory.class.getClassLoader();
+ }
+ String className = null;
+ int count = 0;
+ do
+ {
+ className = getFactoryClassName(loader, count++);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> t = (loader != null) ? loader.loadClass(className) :
+ Class.forName(className);
+ XPathFactory ret = (XPathFactory) t.newInstance();
+ if (ret.isObjectModelSupported(uri))
+ {
+ return ret;
+ }
+ className = null;
+ }
+ catch (ClassNotFoundException e)
+ {
+ className = null;
+ }
+ catch (Exception e)
+ {
+ throw new XPathFactoryConfigurationException(e);
+ }
+ }
+ }
+ while (className == null && count < 4);
+ String msg = "no factories with support for " + uri;
+ throw new XPathFactoryConfigurationException(msg);
+ }
+
+ private static String getFactoryClassName(ClassLoader loader, int attempt)
+ {
+ final String propertyName = DEFAULT_PROPERTY_NAME;
+ switch (attempt)
+ {
+ case 0:
+ return System.getProperty(propertyName);
+ case 1:
+ try
+ {
+ File file = new File(System.getProperty("java.home"));
+ file = new File(file, "lib");
+ file = new File(file, "jaxp.properties");
+ InputStream in = new FileInputStream(file);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props.getProperty(propertyName);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ case 2:
+ try
+ {
+ String serviceKey = "/META-INF/services/" + propertyName;
+ InputStream in = (loader != null) ?
+ loader.getResourceAsStream(serviceKey) :
+ XPathFactory.class.getResourceAsStream(serviceKey);
+ if (in != null)
+ {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(in));
+ String ret = r.readLine();
+ r.close();
+ return ret;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ case 3:
+ return "gnu.xml.xpath.XPathFactoryImpl";
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Indicates whether the specified object model URI is supported by
+ * this factory.
+ */
+ public abstract boolean isObjectModelSupported(String objectModel);
+
+ /**
+ * Sets the state of the named feature.
+ */
+ public abstract void setFeature(String name, boolean value)
+ throws XPathFactoryConfigurationException;
+
+ /**
+ * Returns the state of the named feature.
+ */
+ public abstract boolean getFeature(String name)
+ throws XPathFactoryConfigurationException;
+
+ /**
+ * Sets the XPath variable resolver calback.
+ */
+ public abstract void setXPathVariableResolver(XPathVariableResolver resolver);
+
+ /**
+ * Sets the XPath extension function resolver calback.
+ */
+ public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver);
+
+ /**
+ * Returns a new XPath evaluation environment.
+ */
+ public abstract XPath newXPath();
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathFactoryConfigurationException.java b/libjava/classpath/javax/xml/xpath/XPathFactoryConfigurationException.java
new file mode 100644
index 000000000..929cbe64b
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathFactoryConfigurationException.java
@@ -0,0 +1,61 @@
+/* XPathFactoryConfigurationException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+/**
+ * A configuration exception in an XPath factory environment.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public class XPathFactoryConfigurationException
+ extends XPathException
+{
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ public XPathFactoryConfigurationException(String message)
+ {
+ super(message);
+ }
+
+ public XPathFactoryConfigurationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathFunction.java b/libjava/classpath/javax/xml/xpath/XPathFunction.java
new file mode 100644
index 000000000..4406e318c
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathFunction.java
@@ -0,0 +1,59 @@
+/* XPathFunction.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import java.util.List;
+
+/**
+ * An XPath extension function.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public interface XPathFunction
+{
+
+ /**
+ * Evaluate the function with the specified arguments.
+ * @param args the list of arguments
+ */
+ @SuppressWarnings("unchecked")
+ Object evaluate(List args)
+ throws XPathFunctionException;
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathFunctionException.java b/libjava/classpath/javax/xml/xpath/XPathFunctionException.java
new file mode 100644
index 000000000..c1d3b98cd
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathFunctionException.java
@@ -0,0 +1,61 @@
+/* XPathFunctionException.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+/**
+ * An exception in an XPath function.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public class XPathFunctionException
+ extends XPathExpressionException
+{
+ private static final long serialVersionUID = -1837080260374986980L;
+
+ public XPathFunctionException(String message)
+ {
+ super(message);
+ }
+
+ public XPathFunctionException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathFunctionResolver.java b/libjava/classpath/javax/xml/xpath/XPathFunctionResolver.java
new file mode 100644
index 000000000..e896690e6
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathFunctionResolver.java
@@ -0,0 +1,59 @@
+/* XPathFunctionResolver.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface providing the means to access XPath extension functions.
+ *
+ * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @since 1.3
+ */
+public interface XPathFunctionResolver
+{
+
+ /**
+ * Returns the function with the specified name and arity.
+ * @param functionName the function name
+ * @param arity the number of arguments
+ */
+ XPathFunction resolveFunction(QName functionName,
+ int arity);
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/XPathVariableResolver.java b/libjava/classpath/javax/xml/xpath/XPathVariableResolver.java
new file mode 100644
index 000000000..2da4a6e63
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/XPathVariableResolver.java
@@ -0,0 +1,52 @@
+/* XPathVariableResolver.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.xml.xpath;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface providing the means to access the values of XPath variable
+ * references.
+ * @since 1.3
+ */
+public interface XPathVariableResolver
+{
+
+ Object resolveVariable(QName variableName);
+
+}
diff --git a/libjava/classpath/javax/xml/xpath/package.html b/libjava/classpath/javax/xml/xpath/package.html
new file mode 100644
index 000000000..458cff843
--- /dev/null
+++ b/libjava/classpath/javax/xml/xpath/package.html
@@ -0,0 +1,9 @@
+<html>
+<body>
+
+<div>
+This package provides access to an XPath evaluation environment and expressions.
+</div>
+
+</body>
+</html>