diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-02 00:42:32 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-02 00:42:32 +0000 |
commit | 795e6e36d7ac5de19f2eddace76e1036519860e5 (patch) | |
tree | d6f5216c5e8b86e821ab50a8cb46c7eec16e0a52 /libjava/javax | |
parent | deac3726d786d71a31243f1348e467cb0251a522 (diff) | |
download | gcc-795e6e36d7ac5de19f2eddace76e1036519860e5.tar.gz |
* external/w3c_dom/Makefile.am: New file.
* external/w3c_dom/Makefile.in: New file.
* external/sax/Makefile.am: New file.
* external/sax/Makefile.in: New file.
* external/Makefile.in: New file.
* external/Makefile.am: New file.
* external/README: New file from Classpath.
* configure, aclocal.m4, Makefile.in: Rebuilt.
* configure.ac (AC_CONFIG_FILES): Create new Makefiles.
* Makefile.am (SUBDIRS): Added external.
(toolexeclib_LTLIBRARIES): Removed lib-org-xml-sax.la,
lib-org-w3c-dom.la, lib-org-ietf-gss.la.
(BOOTCLASSPATH): New variable.
(AM_GCJFLAGS): Use it.
(gnu_xml_source_files): New variable.
(libgcj_la_SOURCES): Use it.
(libgcj_la_LDADD): Include new convenience libraries.
(lib_org_ietf_jgss_la_SOURCES): Removed.
(lib_org_ietf_jgss_la_DEPENDENCIES): Likewise.
(lib_org_ietf_jgss_la_LIBADD): Likewise.
(lib_org_w3c_dom_la_SOURCES): Removed.
(lib_org_w3c_dom_la_DEPENDENCIES): Likewise.
(lib_org_w3c_dom_la_LIBADD): Likewise.
(lib_org_xml_sax_la_SOURCES): Removed.
(lib_org_xml_sax_la_DEPENDENCIES): Likewise.
(lib_org_xml_sax_la_LIBADD): Likewise.
(all_java_source_files): Updated.
(property_files): Likewise.
(libgcj-@gcc_version@.jar): Include classes from external/.
(javax_source_files): Updated.
(ordinary_java_source_files): Updated.
* javax/xml/XMLConstants.java,
javax/xml/datatype/DatatypeConfigurationException.java,
javax/xml/datatype/DatatypeConstants.java,
javax/xml/datatype/DatatypeFactory.java,
javax/xml/datatype/Duration.java,
javax/xml/datatype/XMLGregorianCalendar.java,
javax/xml/datatype/package.html,
javax/xml/namespace/NamespaceContext.java,
javax/xml/namespace/QName.java, javax/xml/namespace/package.html,
javax/xml/parsers/DocumentBuilder.java,
javax/xml/parsers/DocumentBuilderFactory.java,
javax/xml/parsers/FactoryConfigurationError.java,
javax/xml/parsers/ParserConfigurationException.java,
javax/xml/parsers/SAXParser.java,
javax/xml/parsers/SAXParserFactory.java,
javax/xml/parsers/package.html,
javax/xml/transform/ErrorListener.java,
javax/xml/transform/OutputKeys.java,
javax/xml/transform/Result.java, javax/xml/transform/Source.java,
javax/xml/transform/SourceLocator.java,
javax/xml/transform/Templates.java,
javax/xml/transform/Transformer.java,
javax/xml/transform/TransformerConfigurationException.java,
javax/xml/transform/TransformerException.java,
javax/xml/transform/TransformerFactory.java,
javax/xml/transform/TransformerFactoryConfigurationError.java,
javax/xml/transform/URIResolver.java,
javax/xml/transform/package.html,
javax/xml/transform/dom/DOMLocator.java,
javax/xml/transform/dom/DOMResult.java,
javax/xml/transform/dom/DOMSource.java,
javax/xml/transform/dom/package.html,
javax/xml/transform/sax/SAXResult.java,
javax/xml/transform/sax/SAXSource.java,
javax/xml/transform/sax/SAXTransformerFactory.java,
javax/xml/transform/sax/TemplatesHandler.java,
javax/xml/transform/sax/TransformerHandler.java,
javax/xml/transform/sax/package.html,
javax/xml/transform/stream/StreamResult.java,
javax/xml/transform/stream/StreamSource.java,
javax/xml/transform/stream/package.html,
javax/xml/validation/Schema.java,
javax/xml/validation/SchemaFactory.java,
javax/xml/validation/TypeInfoProvider.java,
javax/xml/validation/Validator.java,
javax/xml/validation/ValidatorHandler.java,
javax/xml/validation/package.html, javax/xml/xpath/XPath.java,
javax/xml/xpath/XPathConstants.java,
javax/xml/xpath/XPathException.java,
javax/xml/xpath/XPathExpression.java,
javax/xml/xpath/XPathExpressionException.java,
javax/xml/xpath/XPathFactory.java,
javax/xml/xpath/XPathFactoryConfigurationException.java,
javax/xml/xpath/XPathFunction.java,
javax/xml/xpath/XPathFunctionException.java,
javax/xml/xpath/XPathFunctionResolver.java,
javax/xml/xpath/XPathVariableResolver.java,
javax/xml/xpath/package.html: New files, from GNU JAXP.
* org/w3c/dom/Attr.java, org/w3c/dom/CDATASection.java,
org/w3c/dom/CharacterData.java, org/w3c/dom/Comment.java,
org/w3c/dom/DOMException.java, org/w3c/dom/DOMImplementation.java,
org/w3c/dom/Document.java, org/w3c/dom/DocumentFragment.java,
org/w3c/dom/DocumentType.java, org/w3c/dom/Element.java,
org/w3c/dom/Entity.java, org/w3c/dom/EntityReference.java,
org/w3c/dom/NamedNodeMap.java, org/w3c/dom/Node.java,
org/w3c/dom/NodeList.java, org/w3c/dom/Notation.java,
org/w3c/dom/ProcessingInstruction.java, org/w3c/dom/Text.java,
org/w3c/dom/ranges/DocumentRange.java,
org/w3c/dom/ranges/Range.java,
org/w3c/dom/ranges/RangeException.java,
org/w3c/dom/traversal/DocumentTraversal.java,
org/w3c/dom/traversal/NodeFilter.java,
org/w3c/dom/traversal/NodeIterator.java,
org/w3c/dom/traversal/TreeWalker.java,
org/xml/sax/AttributeList.java, org/xml/sax/Attributes.java,
org/xml/sax/ContentHandler.java, org/xml/sax/DTDHandler.java,
org/xml/sax/DocumentHandler.java, org/xml/sax/EntityResolver.java,
org/xml/sax/ErrorHandler.java, org/xml/sax/HandlerBase.java,
org/xml/sax/InputSource.java, org/xml/sax/Locator.java,
org/xml/sax/Parser.java, org/xml/sax/SAXException.java,
org/xml/sax/SAXNotRecognizedException.java,
org/xml/sax/SAXNotSupportedException.java,
org/xml/sax/SAXParseException.java, org/xml/sax/XMLFilter.java,
org/xml/sax/XMLReader.java, org/xml/sax/package.html,
org/xml/sax/ext/DeclHandler.java,
org/xml/sax/ext/LexicalHandler.java, org/xml/sax/ext/package.html,
org/xml/sax/helpers/AttributeListImpl.java,
org/xml/sax/helpers/AttributesImpl.java,
org/xml/sax/helpers/DefaultHandler.java,
org/xml/sax/helpers/LocatorImpl.java,
org/xml/sax/helpers/NamespaceSupport.java,
org/xml/sax/helpers/NewInstance.java,
org/xml/sax/helpers/ParserAdapter.java,
org/xml/sax/helpers/ParserFactory.java,
org/xml/sax/helpers/XMLFilterImpl.java,
org/xml/sax/helpers/XMLReaderAdapter.java,
org/xml/sax/helpers/XMLReaderFactory.java,
org/xml/sax/helpers/package.html: Moved to external/.
* external/sax/README,
external/sax/org/xml/sax/AttributeList.java,
external/sax/org/xml/sax/Attributes.java,
external/sax/org/xml/sax/ContentHandler.java,
external/sax/org/xml/sax/DTDHandler.java,
external/sax/org/xml/sax/DocumentHandler.java,
external/sax/org/xml/sax/EntityResolver.java,
external/sax/org/xml/sax/ErrorHandler.java,
external/sax/org/xml/sax/HandlerBase.java,
external/sax/org/xml/sax/InputSource.java,
external/sax/org/xml/sax/Locator.java,
external/sax/org/xml/sax/Parser.java,
external/sax/org/xml/sax/SAXException.java,
external/sax/org/xml/sax/SAXNotRecognizedException.java,
external/sax/org/xml/sax/SAXNotSupportedException.java,
external/sax/org/xml/sax/SAXParseException.java,
external/sax/org/xml/sax/XMLFilter.java,
external/sax/org/xml/sax/XMLReader.java,
external/sax/org/xml/sax/package.html,
external/sax/org/xml/sax/ext/Attributes2.java,
external/sax/org/xml/sax/ext/Attributes2Impl.java,
external/sax/org/xml/sax/ext/DeclHandler.java,
external/sax/org/xml/sax/ext/DefaultHandler2.java,
external/sax/org/xml/sax/ext/EntityResolver2.java,
external/sax/org/xml/sax/ext/LexicalHandler.java,
external/sax/org/xml/sax/ext/Locator2.java,
external/sax/org/xml/sax/ext/Locator2Impl.java,
external/sax/org/xml/sax/ext/package.html,
external/sax/org/xml/sax/helpers/AttributeListImpl.java,
external/sax/org/xml/sax/helpers/AttributesImpl.java,
external/sax/org/xml/sax/helpers/DefaultHandler.java,
external/sax/org/xml/sax/helpers/LocatorImpl.java,
external/sax/org/xml/sax/helpers/NamespaceSupport.java,
external/sax/org/xml/sax/helpers/NewInstance.java,
external/sax/org/xml/sax/helpers/ParserAdapter.java,
external/sax/org/xml/sax/helpers/ParserFactory.java,
external/sax/org/xml/sax/helpers/XMLFilterImpl.java,
external/sax/org/xml/sax/helpers/XMLReaderAdapter.java,
external/sax/org/xml/sax/helpers/XMLReaderFactory.java,
external/sax/org/xml/sax/helpers/package.html,
external/w3c_dom/COPYRIGHT.html, external/w3c_dom/README,
external/w3c_dom/org/w3c/dom/Attr.java,
external/w3c_dom/org/w3c/dom/CDATASection.java,
external/w3c_dom/org/w3c/dom/CharacterData.java,
external/w3c_dom/org/w3c/dom/Comment.java,
external/w3c_dom/org/w3c/dom/DOMConfiguration.java,
external/w3c_dom/org/w3c/dom/DOMError.java,
external/w3c_dom/org/w3c/dom/DOMErrorHandler.java,
external/w3c_dom/org/w3c/dom/DOMException.java,
external/w3c_dom/org/w3c/dom/DOMImplementation.java,
external/w3c_dom/org/w3c/dom/DOMImplementationList.java,
external/w3c_dom/org/w3c/dom/DOMImplementationSource.java,
external/w3c_dom/org/w3c/dom/DOMLocator.java,
external/w3c_dom/org/w3c/dom/DOMStringList.java,
external/w3c_dom/org/w3c/dom/Document.java,
external/w3c_dom/org/w3c/dom/DocumentFragment.java,
external/w3c_dom/org/w3c/dom/DocumentType.java,
external/w3c_dom/org/w3c/dom/Element.java,
external/w3c_dom/org/w3c/dom/Entity.java,
external/w3c_dom/org/w3c/dom/EntityReference.java,
external/w3c_dom/org/w3c/dom/NameList.java,
external/w3c_dom/org/w3c/dom/NamedNodeMap.java,
external/w3c_dom/org/w3c/dom/Node.java,
external/w3c_dom/org/w3c/dom/NodeList.java,
external/w3c_dom/org/w3c/dom/Notation.java,
external/w3c_dom/org/w3c/dom/ProcessingInstruction.java,
external/w3c_dom/org/w3c/dom/Text.java,
external/w3c_dom/org/w3c/dom/TypeInfo.java,
external/w3c_dom/org/w3c/dom/UserDataHandler.java,
external/w3c_dom/org/w3c/dom/bootstrap/DOMImplementationRegistry.java,
external/w3c_dom/org/w3c/dom/css/CSS2Properties.java,
external/w3c_dom/org/w3c/dom/css/CSSCharsetRule.java,
external/w3c_dom/org/w3c/dom/css/CSSFontFaceRule.java,
external/w3c_dom/org/w3c/dom/css/CSSImportRule.java,
external/w3c_dom/org/w3c/dom/css/CSSMediaRule.java,
external/w3c_dom/org/w3c/dom/css/CSSPageRule.java,
external/w3c_dom/org/w3c/dom/css/CSSPrimitiveValue.java,
external/w3c_dom/org/w3c/dom/css/CSSRule.java,
external/w3c_dom/org/w3c/dom/css/CSSRuleList.java,
external/w3c_dom/org/w3c/dom/css/CSSStyleDeclaration.java,
external/w3c_dom/org/w3c/dom/css/CSSStyleRule.java,
external/w3c_dom/org/w3c/dom/css/CSSStyleSheet.java,
external/w3c_dom/org/w3c/dom/css/CSSUnknownRule.java,
external/w3c_dom/org/w3c/dom/css/CSSValue.java,
external/w3c_dom/org/w3c/dom/css/CSSValueList.java,
external/w3c_dom/org/w3c/dom/css/Counter.java,
external/w3c_dom/org/w3c/dom/css/DOMImplementationCSS.java,
external/w3c_dom/org/w3c/dom/css/DocumentCSS.java,
external/w3c_dom/org/w3c/dom/css/ElementCSSInlineStyle.java,
external/w3c_dom/org/w3c/dom/css/RGBColor.java,
external/w3c_dom/org/w3c/dom/css/Rect.java,
external/w3c_dom/org/w3c/dom/css/ViewCSS.java,
external/w3c_dom/org/w3c/dom/events/DocumentEvent.java,
external/w3c_dom/org/w3c/dom/events/Event.java,
external/w3c_dom/org/w3c/dom/events/EventException.java,
external/w3c_dom/org/w3c/dom/events/EventListener.java,
external/w3c_dom/org/w3c/dom/events/EventTarget.java,
external/w3c_dom/org/w3c/dom/events/MouseEvent.java,
external/w3c_dom/org/w3c/dom/events/MutationEvent.java,
external/w3c_dom/org/w3c/dom/events/UIEvent.java,
external/w3c_dom/org/w3c/dom/html2/HTMLAnchorElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLAppletElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLAreaElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLBRElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLBaseElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLBaseFontElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLBodyElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLButtonElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLCollection.java,
external/w3c_dom/org/w3c/dom/html2/HTMLDListElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLDirectoryElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLDivElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLDocument.java,
external/w3c_dom/org/w3c/dom/html2/HTMLElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLFieldSetElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLFontElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLFormElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLFrameElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLFrameSetElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLHRElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLHeadElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLHeadingElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLHtmlElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLIFrameElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLImageElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLInputElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLIsIndexElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLLIElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLLabelElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLLegendElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLLinkElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLMapElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLMenuElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLMetaElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLModElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLOListElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLObjectElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLOptGroupElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLOptionElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLOptionsCollection.java,
external/w3c_dom/org/w3c/dom/html2/HTMLParagraphElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLParamElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLPreElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLQuoteElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLScriptElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLSelectElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLStyleElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableCaptionElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableCellElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableColElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableRowElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTableSectionElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTextAreaElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLTitleElement.java,
external/w3c_dom/org/w3c/dom/html2/HTMLUListElement.java,
external/w3c_dom/org/w3c/dom/ls/DOMImplementationLS.java,
external/w3c_dom/org/w3c/dom/ls/LSException.java,
external/w3c_dom/org/w3c/dom/ls/LSInput.java,
external/w3c_dom/org/w3c/dom/ls/LSLoadEvent.java,
external/w3c_dom/org/w3c/dom/ls/LSOutput.java,
external/w3c_dom/org/w3c/dom/ls/LSParser.java,
external/w3c_dom/org/w3c/dom/ls/LSParserFilter.java,
external/w3c_dom/org/w3c/dom/ls/LSProgressEvent.java,
external/w3c_dom/org/w3c/dom/ls/LSResourceResolver.java,
external/w3c_dom/org/w3c/dom/ls/LSSerializer.java,
external/w3c_dom/org/w3c/dom/ls/LSSerializerFilter.java,
external/w3c_dom/org/w3c/dom/ranges/DocumentRange.java,
external/w3c_dom/org/w3c/dom/ranges/Range.java,
external/w3c_dom/org/w3c/dom/ranges/RangeException.java,
external/w3c_dom/org/w3c/dom/stylesheets/DocumentStyle.java,
external/w3c_dom/org/w3c/dom/stylesheets/LinkStyle.java,
external/w3c_dom/org/w3c/dom/stylesheets/MediaList.java,
external/w3c_dom/org/w3c/dom/stylesheets/StyleSheet.java,
external/w3c_dom/org/w3c/dom/stylesheets/StyleSheetList.java,
external/w3c_dom/org/w3c/dom/traversal/DocumentTraversal.java,
external/w3c_dom/org/w3c/dom/traversal/NodeFilter.java,
external/w3c_dom/org/w3c/dom/traversal/NodeIterator.java,
external/w3c_dom/org/w3c/dom/traversal/TreeWalker.java,
external/w3c_dom/org/w3c/dom/views/AbstractView.java,
external/w3c_dom/org/w3c/dom/views/DocumentView.java,
external/w3c_dom/org/w3c/dom/xpath/XPathEvaluator.java,
external/w3c_dom/org/w3c/dom/xpath/XPathException.java,
external/w3c_dom/org/w3c/dom/xpath/XPathExpression.java,
external/w3c_dom/org/w3c/dom/xpath/XPathNSResolver.java,
external/w3c_dom/org/w3c/dom/xpath/XPathNamespace.java,
external/w3c_dom/org/w3c/dom/xpath/XPathResult.java: New files
from Classpath.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94577 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/javax')
61 files changed, 7297 insertions, 0 deletions
diff --git a/libjava/javax/xml/XMLConstants.java b/libjava/javax/xml/XMLConstants.java new file mode 100644 index 00000000000..4b9b0661736 --- /dev/null +++ b/libjava/javax/xml/XMLConstants.java @@ -0,0 +1,126 @@ +/* XMLConstants.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.3 + */ +public final class XMLConstants +{ + + /** + * 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/javax/xml/datatype/DatatypeConfigurationException.java b/libjava/javax/xml/datatype/DatatypeConfigurationException.java new file mode 100644 index 00000000000..15440798807 --- /dev/null +++ b/libjava/javax/xml/datatype/DatatypeConfigurationException.java @@ -0,0 +1,70 @@ +/* DatatypeConfigurationException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/datatype/DatatypeConstants.java b/libjava/javax/xml/datatype/DatatypeConstants.java new file mode 100644 index 00000000000..a761f88d50e --- /dev/null +++ b/libjava/javax/xml/datatype/DatatypeConstants.java @@ -0,0 +1,259 @@ +/* DatatypeConstants.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.3 + */ +public final class DatatypeConstants +{ + + /** + * 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/javax/xml/datatype/DatatypeFactory.java b/libjava/javax/xml/datatype/DatatypeFactory.java new file mode 100644 index 00000000000..2299435fc4a --- /dev/null +++ b/libjava/javax/xml/datatype/DatatypeFactory.java @@ -0,0 +1,401 @@ +/* DatatypeFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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; + +/** + * Factory class to create new datatype objects mapping XML to and from Java + * objects. + * + * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> + * @since 1.3 + */ +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 java.lang.String DATATYPEFACTORY_IMPLEMENTATION_CLASS = "gnu.xml.datatype.JAXPDatatypeFactory"; + + protected DatatypeFactory() + { + } + + /** + * Returns a new factory instance. + */ + public static DatatypeFactory newInstance() + throws DatatypeConfigurationException + { + try + { + 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, + BigDecimal seconds) + { + return newDuration(isPositive, + null, + null, + days, + hours, + minutes, + 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 + * @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 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 + * @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 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/javax/xml/datatype/Duration.java b/libjava/javax/xml/datatype/Duration.java new file mode 100644 index 00000000000..ed1221dbf20 --- /dev/null +++ b/libjava/javax/xml/datatype/Duration.java @@ -0,0 +1,295 @@ +/* Duration.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.3 + */ +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 Duration multiply(BigDecimal factor) + { + // TODO + throw new UnsupportedOperationException(); + } + + /** + * 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/javax/xml/datatype/XMLGregorianCalendar.java b/libjava/javax/xml/datatype/XMLGregorianCalendar.java new file mode 100644 index 00000000000..c3585a48905 --- /dev/null +++ b/libjava/javax/xml/datatype/XMLGregorianCalendar.java @@ -0,0 +1,217 @@ +/* XMLGregorianCalendar.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/datatype/package.html b/libjava/javax/xml/datatype/package.html new file mode 100644 index 00000000000..ffd850c0413 --- /dev/null +++ b/libjava/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/javax/xml/namespace/NamespaceContext.java b/libjava/javax/xml/namespace/NamespaceContext.java new file mode 100644 index 00000000000..2e790654870 --- /dev/null +++ b/libjava/javax/xml/namespace/NamespaceContext.java @@ -0,0 +1,66 @@ +/* NamespaceContext.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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. + */ + public Iterator getPrefixes(String namespaceURI); + +} diff --git a/libjava/javax/xml/namespace/QName.java b/libjava/javax/xml/namespace/QName.java new file mode 100644 index 00000000000..62dc8cd08a6 --- /dev/null +++ b/libjava/javax/xml/namespace/QName.java @@ -0,0 +1,160 @@ +/* QName.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 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 +{ + + private final String namespaceURI; + private final String localPart; + private final String prefix; + private final String qName; + + 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; + } + this.namespaceURI = namespaceURI; + this.localPart = localPart; + this.prefix = prefix; + + StringBuffer buf = new StringBuffer(); + if (namespaceURI != null && namespaceURI.length() > 0) + { + buf.append('{'); + buf.append(namespaceURI); + buf.append('}'); + } + if (prefix != null && prefix.length() > 0) + { + buf.append(prefix); + buf.append(':'); + } + buf.append(localPart); + qName = buf.toString(); + } + + public QName(String localPart) + { + this(null, localPart, null); + } + + public String getNamespaceURI() + { + return namespaceURI; + } + + public String getLocalPart() + { + return localPart; + } + + public String getPrefix() + { + return prefix; + } + + public 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() + { + return qName.hashCode(); + } + + public String toString() + { + return qName; + } + + public static QName valueOf(String qNameAsString) + { + 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/javax/xml/namespace/package.html b/libjava/javax/xml/namespace/package.html new file mode 100644 index 00000000000..00929f8a0db --- /dev/null +++ b/libjava/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/javax/xml/parsers/DocumentBuilder.java b/libjava/javax/xml/parsers/DocumentBuilder.java new file mode 100644 index 00000000000..13d7658de36 --- /dev/null +++ b/libjava/javax/xml/parsers/DocumentBuilder.java @@ -0,0 +1,204 @@ +/* DocumentBuilder.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.InputSource; +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 is 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/javax/xml/parsers/DocumentBuilderFactory.java b/libjava/javax/xml/parsers/DocumentBuilderFactory.java new file mode 100644 index 00000000000..c531005164d --- /dev/null +++ b/libjava/javax/xml/parsers/DocumentBuilderFactory.java @@ -0,0 +1,349 @@ +/* DocumentBuilderFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 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 + */ + public Schema getSchema() + { + return schema; + } + + /** + * Sets the schema. + * @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/javax/xml/parsers/FactoryConfigurationError.java b/libjava/javax/xml/parsers/FactoryConfigurationError.java new file mode 100644 index 00000000000..e7ff57e2a90 --- /dev/null +++ b/libjava/javax/xml/parsers/FactoryConfigurationError.java @@ -0,0 +1,113 @@ +/* FactoryConfigurationError.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/parsers/ParserConfigurationException.java b/libjava/javax/xml/parsers/ParserConfigurationException.java new file mode 100644 index 00000000000..d7b54cf7b46 --- /dev/null +++ b/libjava/javax/xml/parsers/ParserConfigurationException.java @@ -0,0 +1,66 @@ +/* ParserConfigurationException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/parsers/SAXParser.java b/libjava/javax/xml/parsers/SAXParser.java new file mode 100644 index 00000000000..10289dc6a20 --- /dev/null +++ b/libjava/javax/xml/parsers/SAXParser.java @@ -0,0 +1,340 @@ +/* SAXParser.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 f 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/javax/xml/parsers/SAXParserFactory.java b/libjava/javax/xml/parsers/SAXParserFactory.java new file mode 100644 index 00000000000..143ee620697 --- /dev/null +++ b/libjava/javax/xml/parsers/SAXParserFactory.java @@ -0,0 +1,273 @@ +/* SAXParserFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.aelfred2.JAXPFactory(); + } + + 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/javax/xml/parsers/package.html b/libjava/javax/xml/parsers/package.html new file mode 100644 index 00000000000..71739b92c00 --- /dev/null +++ b/libjava/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/javax/xml/transform/ErrorListener.java b/libjava/javax/xml/transform/ErrorListener.java new file mode 100644 index 00000000000..f2021cd02d3 --- /dev/null +++ b/libjava/javax/xml/transform/ErrorListener.java @@ -0,0 +1,66 @@ +/* ErrorListener.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/OutputKeys.java b/libjava/javax/xml/transform/OutputKeys.java new file mode 100644 index 00000000000..784194c87d6 --- /dev/null +++ b/libjava/javax/xml/transform/OutputKeys.java @@ -0,0 +1,103 @@ +/* OutputKeys.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/Result.java b/libjava/javax/xml/transform/Result.java new file mode 100644 index 00000000000..ec9420f6e41 --- /dev/null +++ b/libjava/javax/xml/transform/Result.java @@ -0,0 +1,72 @@ +/* Result.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/Source.java b/libjava/javax/xml/transform/Source.java new file mode 100644 index 00000000000..4d6002b5344 --- /dev/null +++ b/libjava/javax/xml/transform/Source.java @@ -0,0 +1,60 @@ +/* Source.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/SourceLocator.java b/libjava/javax/xml/transform/SourceLocator.java new file mode 100644 index 00000000000..dfeea46d143 --- /dev/null +++ b/libjava/javax/xml/transform/SourceLocator.java @@ -0,0 +1,70 @@ +/* SourceLocator.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/Templates.java b/libjava/javax/xml/transform/Templates.java new file mode 100644 index 00000000000..3e9293ee122 --- /dev/null +++ b/libjava/javax/xml/transform/Templates.java @@ -0,0 +1,67 @@ +/* Templates.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/Transformer.java b/libjava/javax/xml/transform/Transformer.java new file mode 100644 index 00000000000..3bf1e886de4 --- /dev/null +++ b/libjava/javax/xml/transform/Transformer.java @@ -0,0 +1,164 @@ +/* Transformer.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/TransformerConfigurationException.java b/libjava/javax/xml/transform/TransformerConfigurationException.java new file mode 100644 index 00000000000..006fc2f4f22 --- /dev/null +++ b/libjava/javax/xml/transform/TransformerConfigurationException.java @@ -0,0 +1,103 @@ +/* TransformerConfigurationException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 SourceLocator locator; + + /** + * 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, e); + this.locator = locator; + } + +} diff --git a/libjava/javax/xml/transform/TransformerException.java b/libjava/javax/xml/transform/TransformerException.java new file mode 100644 index 00000000000..c10fa8a4fc2 --- /dev/null +++ b/libjava/javax/xml/transform/TransformerException.java @@ -0,0 +1,241 @@ +/* TransformerException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.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 SourceLocator locator; + private Throwable cause; + + /** + * 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.cause = 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 cause; + } + + /** + * Returns the underlying cause of this exception. + */ + public Throwable getCause() + { + return cause; + } + + /** + * 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.cause != null) + { + throw new IllegalStateException(); + } + if (cause == this) + { + throw new IllegalArgumentException(); + } + this.cause = 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(); + StringBuffer buffer = new StringBuffer (); + 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 (cause != null) + { + s.print("caused by "); + cause.printStackTrace(s); + } + } + + public void printStackTrace(PrintWriter s) + { + super.printStackTrace(s); + if (cause != null) + { + s.print("caused by "); + cause.printStackTrace(s); + } + } + +} diff --git a/libjava/javax/xml/transform/TransformerFactory.java b/libjava/javax/xml/transform/TransformerFactory.java new file mode 100644 index 00000000000..a1f50fc2466 --- /dev/null +++ b/libjava/javax/xml/transform/TransformerFactory.java @@ -0,0 +1,284 @@ +/* TransformerFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/TransformerFactoryConfigurationError.java b/libjava/javax/xml/transform/TransformerFactoryConfigurationError.java new file mode 100644 index 00000000000..3ec8809918b --- /dev/null +++ b/libjava/javax/xml/transform/TransformerFactoryConfigurationError.java @@ -0,0 +1,104 @@ +/* TransformerFactoryConfigurationError.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 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/javax/xml/transform/URIResolver.java b/libjava/javax/xml/transform/URIResolver.java new file mode 100644 index 00000000000..7dca029e836 --- /dev/null +++ b/libjava/javax/xml/transform/URIResolver.java @@ -0,0 +1,58 @@ +/* URIResolver.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/dom/DOMLocator.java b/libjava/javax/xml/transform/dom/DOMLocator.java new file mode 100644 index 00000000000..7e0f8304eda --- /dev/null +++ b/libjava/javax/xml/transform/dom/DOMLocator.java @@ -0,0 +1,57 @@ +/* DOMLocator.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/dom/DOMResult.java b/libjava/javax/xml/transform/dom/DOMResult.java new file mode 100644 index 00000000000..e62e30bfca0 --- /dev/null +++ b/libjava/javax/xml/transform/dom/DOMResult.java @@ -0,0 +1,163 @@ +/* DOMResult.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/dom/DOMSource.java b/libjava/javax/xml/transform/dom/DOMSource.java new file mode 100644 index 00000000000..e002dbf06b9 --- /dev/null +++ b/libjava/javax/xml/transform/dom/DOMSource.java @@ -0,0 +1,118 @@ +/* DOMSource.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/dom/package.html b/libjava/javax/xml/transform/dom/package.html new file mode 100644 index 00000000000..0600fc72449 --- /dev/null +++ b/libjava/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/javax/xml/transform/package.html b/libjava/javax/xml/transform/package.html new file mode 100644 index 00000000000..bc67c2b805c --- /dev/null +++ b/libjava/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/javax/xml/transform/sax/SAXResult.java b/libjava/javax/xml/transform/sax/SAXResult.java new file mode 100644 index 00000000000..d9bf9a57ed3 --- /dev/null +++ b/libjava/javax/xml/transform/sax/SAXResult.java @@ -0,0 +1,132 @@ +/* SAXResult.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/sax/SAXSource.java b/libjava/javax/xml/transform/sax/SAXSource.java new file mode 100644 index 00000000000..15df252c727 --- /dev/null +++ b/libjava/javax/xml/transform/sax/SAXSource.java @@ -0,0 +1,197 @@ +/* SAXSource.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/sax/SAXTransformerFactory.java b/libjava/javax/xml/transform/sax/SAXTransformerFactory.java new file mode 100644 index 00000000000..66d51979b7e --- /dev/null +++ b/libjava/javax/xml/transform/sax/SAXTransformerFactory.java @@ -0,0 +1,118 @@ +/* SAXTransformerFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerFactory; +import org.xml.sax.InputSource; +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/javax/xml/transform/sax/TemplatesHandler.java b/libjava/javax/xml/transform/sax/TemplatesHandler.java new file mode 100644 index 00000000000..8ee840d70f2 --- /dev/null +++ b/libjava/javax/xml/transform/sax/TemplatesHandler.java @@ -0,0 +1,68 @@ +/* TemplatesHandler.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/sax/TransformerHandler.java b/libjava/javax/xml/transform/sax/TransformerHandler.java new file mode 100644 index 00000000000..0b2b1bd24d7 --- /dev/null +++ b/libjava/javax/xml/transform/sax/TransformerHandler.java @@ -0,0 +1,78 @@ +/* TransformerHandler.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/sax/package.html b/libjava/javax/xml/transform/sax/package.html new file mode 100644 index 00000000000..b2d2978a363 --- /dev/null +++ b/libjava/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/javax/xml/transform/stream/StreamResult.java b/libjava/javax/xml/transform/stream/StreamResult.java new file mode 100644 index 00000000000..fe4462d920d --- /dev/null +++ b/libjava/javax/xml/transform/stream/StreamResult.java @@ -0,0 +1,173 @@ +/* StreamResult.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/stream/StreamSource.java b/libjava/javax/xml/transform/stream/StreamSource.java new file mode 100644 index 00000000000..d65dcafed4f --- /dev/null +++ b/libjava/javax/xml/transform/stream/StreamSource.java @@ -0,0 +1,210 @@ +/* StreamSource.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/transform/stream/package.html b/libjava/javax/xml/transform/stream/package.html new file mode 100644 index 00000000000..f9d052b1996 --- /dev/null +++ b/libjava/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/javax/xml/validation/Schema.java b/libjava/javax/xml/validation/Schema.java new file mode 100644 index 00000000000..099a77e0b98 --- /dev/null +++ b/libjava/javax/xml/validation/Schema.java @@ -0,0 +1,61 @@ +/* Schema.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/validation/SchemaFactory.java b/libjava/javax/xml/validation/SchemaFactory.java new file mode 100644 index 00000000000..4310cc5f543 --- /dev/null +++ b/libjava/javax/xml/validation/SchemaFactory.java @@ -0,0 +1,168 @@ +/* SchemaFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.File; +import java.net.URL; +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 <a href='mailto:dog@gnu.org'>Chris Burdess</a> + * @since 1.3 + */ +public abstract class SchemaFactory +{ + + ErrorHandler errorHandler; + + 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) + { + // TODO + throw new IllegalArgumentException(schemaLanguage); + } + + /** + * 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 ErrorHandler getErrorHandler() + { + return errorHandler; + } + + public void setErrorHandler(ErrorHandler errorHandler) + { + this.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/javax/xml/validation/TypeInfoProvider.java b/libjava/javax/xml/validation/TypeInfoProvider.java new file mode 100644 index 00000000000..bec632ca64a --- /dev/null +++ b/libjava/javax/xml/validation/TypeInfoProvider.java @@ -0,0 +1,83 @@ +/* TypeInfoProvider.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/validation/Validator.java b/libjava/javax/xml/validation/Validator.java new file mode 100644 index 00000000000..291bcbdafa9 --- /dev/null +++ b/libjava/javax/xml/validation/Validator.java @@ -0,0 +1,117 @@ +/* Validator.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/validation/ValidatorHandler.java b/libjava/javax/xml/validation/ValidatorHandler.java new file mode 100644 index 00000000000..dc36909ecaa --- /dev/null +++ b/libjava/javax/xml/validation/ValidatorHandler.java @@ -0,0 +1,115 @@ +/* ValidatorHandler.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/validation/package.html b/libjava/javax/xml/validation/package.html new file mode 100644 index 00000000000..b4daa143ac8 --- /dev/null +++ b/libjava/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/javax/xml/xpath/XPath.java b/libjava/javax/xml/xpath/XPath.java new file mode 100644 index 00000000000..d451c5a8d70 --- /dev/null +++ b/libjava/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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/xpath/XPathConstants.java b/libjava/javax/xml/xpath/XPathConstants.java new file mode 100644 index 00000000000..a4b0b163fdb --- /dev/null +++ b/libjava/javax/xml/xpath/XPathConstants.java @@ -0,0 +1,87 @@ +/* XPathConstants.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.3 + */ +public class XPathConstants +{ + + /** + * 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/javax/xml/xpath/XPathException.java b/libjava/javax/xml/xpath/XPathException.java new file mode 100644 index 00000000000..4ca992bb015 --- /dev/null +++ b/libjava/javax/xml/xpath/XPathException.java @@ -0,0 +1,86 @@ +/* XPathException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 +{ + + 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/javax/xml/xpath/XPathExpression.java b/libjava/javax/xml/xpath/XPathExpression.java new file mode 100644 index 00000000000..b7af8f6bb3a --- /dev/null +++ b/libjava/javax/xml/xpath/XPathExpression.java @@ -0,0 +1,86 @@ +/* XPathExpression.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/xpath/XPathExpressionException.java b/libjava/javax/xml/xpath/XPathExpressionException.java new file mode 100644 index 00000000000..4ba19915428 --- /dev/null +++ b/libjava/javax/xml/xpath/XPathExpressionException.java @@ -0,0 +1,60 @@ +/* XPathExpressionException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 +{ + + public XPathExpressionException(String message) + { + super(message); + } + + public XPathExpressionException(Throwable cause) + { + super(cause); + } + +} diff --git a/libjava/javax/xml/xpath/XPathFactory.java b/libjava/javax/xml/xpath/XPathFactory.java new file mode 100644 index 00000000000..64076f51ded --- /dev/null +++ b/libjava/javax/xml/xpath/XPathFactory.java @@ -0,0 +1,227 @@ +/* XPathFactory.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/xpath/XPathFactoryConfigurationException.java b/libjava/javax/xml/xpath/XPathFactoryConfigurationException.java new file mode 100644 index 00000000000..56c45d12e22 --- /dev/null +++ b/libjava/javax/xml/xpath/XPathFactoryConfigurationException.java @@ -0,0 +1,60 @@ +/* XPathFactoryConfigurationException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 +{ + + public XPathFactoryConfigurationException(String message) + { + super(message); + } + + public XPathFactoryConfigurationException(Throwable cause) + { + super(cause); + } + +} diff --git a/libjava/javax/xml/xpath/XPathFunction.java b/libjava/javax/xml/xpath/XPathFunction.java new file mode 100644 index 00000000000..a071eb59620 --- /dev/null +++ b/libjava/javax/xml/xpath/XPathFunction.java @@ -0,0 +1,58 @@ +/* XPathFunction.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 + */ + Object evaluate(List args) + throws XPathFunctionException; + +} diff --git a/libjava/javax/xml/xpath/XPathFunctionException.java b/libjava/javax/xml/xpath/XPathFunctionException.java new file mode 100644 index 00000000000..9a6751a2f32 --- /dev/null +++ b/libjava/javax/xml/xpath/XPathFunctionException.java @@ -0,0 +1,60 @@ +/* XPathFunctionException.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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 +{ + + public XPathFunctionException(String message) + { + super(message); + } + + public XPathFunctionException(Throwable cause) + { + super(cause); + } + +} diff --git a/libjava/javax/xml/xpath/XPathFunctionResolver.java b/libjava/javax/xml/xpath/XPathFunctionResolver.java new file mode 100644 index 00000000000..8fb0bd4234e --- /dev/null +++ b/libjava/javax/xml/xpath/XPathFunctionResolver.java @@ -0,0 +1,59 @@ +/* XPathFunctionResolver.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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/xpath/XPathVariableResolver.java b/libjava/javax/xml/xpath/XPathVariableResolver.java new file mode 100644 index 00000000000..d0f4f57cab3 --- /dev/null +++ b/libjava/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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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/javax/xml/xpath/package.html b/libjava/javax/xml/xpath/package.html new file mode 100644 index 00000000000..458cff84349 --- /dev/null +++ b/libjava/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> |