Index: doc/README.jaxp =================================================================== RCS file: /cvsroot/classpath/classpath/doc/README.jaxp,v retrieving revision 1.2 diff -u -r1.2 README.jaxp --- doc/README.jaxp 4 Sep 2005 14:46:44 -0000 1.2 +++ doc/README.jaxp 24 Dec 2005 13:54:56 -0000 @@ -17,7 +17,7 @@ . gnu.xml.xpath.* ... JAXP XPath implementation . gnu.xml.transform.* ... JAXP XSL transformer implementation . gnu.xml.pipeline.* ... SAX2 event pipeline support -. gnu.xml.stream.* ... StAX pull parser implementation +. gnu.xml.stream.* ... StAX pull parser and SAX-over-StAX driver . gnu.xml.util.* ... various XML utility classes . gnu.xml.libxmlj.dom.* ... libxmlj DOM Level 3 Core and XPath . gnu.xml.libxmlj.sax.* ... libxmlj SAX parser @@ -139,6 +139,9 @@ -Djavax.xml.stream.XMLInputFactory=gnu.xml.stream.XMLInputFactoryImpl -Djavax.xml.stream.XMLOutputFactory=gnu.xml.stream.XMLOutputFactoryImpl + GNU SAX-over-StAX: + -Djavax.xml.parsers.SAXParserFactory=gnu.xml.stream.SAXParserFactory + libxmlj SAX: -Djavax.xml.parsers.SAXParserFactory=gnu.xml.libxmlj.sax.GnomeSAXParserFactory Index: gnu/xml/aelfred2/ContentHandler2.java =================================================================== RCS file: gnu/xml/aelfred2/ContentHandler2.java diff -N gnu/xml/aelfred2/ContentHandler2.java --- gnu/xml/aelfred2/ContentHandler2.java 2 Jul 2005 20:32:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,65 +0,0 @@ -/* ContentHandler2.java -- - Copyright (C) 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.aelfred2; - -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -/** - * Extension to the SAX ContentHandler interface to report parsing events - * and parameters required by DOM Level 3 but not supported by SAX. - * - * @author Chris Burdess - */ -public interface ContentHandler2 - extends ContentHandler -{ - - /** - * Reports the XML declaration. - * @param version the value of the version attribute in the XML - * declaration - * @param encoding the encoding specified in the XML declaration, if any - * @param standalone the standalone attribute from the XML declaration - * @param inputEncoding the encoding of the XML input - */ - void xmlDecl(String version, String encoding, boolean standalone, - String inputEncoding) - throws SAXException; - -} Index: gnu/xml/aelfred2/SAXDriver.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/aelfred2/SAXDriver.java,v retrieving revision 1.8 diff -u -r1.8 SAXDriver.java --- gnu/xml/aelfred2/SAXDriver.java 9 Nov 2005 20:16:53 -0000 1.8 +++ gnu/xml/aelfred2/SAXDriver.java 24 Dec 2005 13:54:57 -0000 @@ -655,21 +655,6 @@ attributesList.clear(); } - void xmlDecl(String version, - String encoding, - boolean standalone, - String inputEncoding) - throws SAXException - { - if (contentHandler instanceof ContentHandler2) - { - ((ContentHandler2) contentHandler).xmlDecl(version, - encoding, - standalone, - inputEncoding); - } - } - void skippedEntity(String name) throws SAXException { Index: gnu/xml/aelfred2/XmlParser.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/aelfred2/XmlParser.java,v retrieving revision 1.7 diff -u -r1.7 XmlParser.java --- gnu/xml/aelfred2/XmlParser.java 2 Jul 2005 20:32:15 -0000 1.7 +++ gnu/xml/aelfred2/XmlParser.java 24 Dec 2005 13:54:58 -0000 @@ -841,9 +841,6 @@ { inputEncoding = encodingName; } - handler.xmlDecl(version, encodingName, docIsStandalone, - inputEncoding); - return encodingName; } Index: gnu/xml/dom/Consumer.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/Consumer.java,v retrieving revision 1.3 diff -u -r1.3 Consumer.java --- gnu/xml/dom/Consumer.java 2 Jul 2005 20:32:15 -0000 1.3 +++ gnu/xml/dom/Consumer.java 24 Dec 2005 13:54:58 -0000 @@ -301,22 +301,6 @@ doc.setBuilding(true); } - /** - * Required by DOM Level 3 to report document parameters - */ - public void xmlDecl(String version, - String encoding, - boolean standalone, - String inputEncoding) - throws SAXException - { - super.xmlDecl(version, encoding, standalone, inputEncoding); - - DomDocument doc = (DomDocument) getDocument(); - doc.setXmlEncoding(encoding); - doc.setInputEncoding(inputEncoding); - } - public void endDocument () throws SAXException { Index: gnu/xml/dom/ls/DomLSParser.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/ls/DomLSParser.java,v retrieving revision 1.3 diff -u -r1.3 DomLSParser.java --- gnu/xml/dom/ls/DomLSParser.java 2 Jul 2005 20:32:16 -0000 1.3 +++ gnu/xml/dom/ls/DomLSParser.java 24 Dec 2005 13:54:58 -0000 @@ -260,6 +260,7 @@ eventSink.coalescing = coalescing; // get and configure reader XMLReader reader = getXMLReader(); + eventSink.reader = reader; try { reader.setContentHandler(eventSink); Index: gnu/xml/dom/ls/SAXEventSink.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/ls/SAXEventSink.java,v retrieving revision 1.4 diff -u -r1.4 SAXEventSink.java --- gnu/xml/dom/ls/SAXEventSink.java 2 Jul 2005 20:32:16 -0000 1.4 +++ gnu/xml/dom/ls/SAXEventSink.java 24 Dec 2005 13:54:58 -0000 @@ -49,13 +49,17 @@ import org.w3c.dom.Node; import org.w3c.dom.Text; import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; import org.xml.sax.DTDHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.XMLReader; import org.xml.sax.ext.Attributes2; import org.xml.sax.ext.DeclHandler; import org.xml.sax.ext.LexicalHandler; -import gnu.xml.aelfred2.ContentHandler2; +import org.xml.sax.ext.Locator2; import gnu.xml.dom.DomAttr; import gnu.xml.dom.DomDocument; import gnu.xml.dom.DomDoctype; @@ -66,7 +70,7 @@ * @author Chris Burdess */ class SAXEventSink - implements ContentHandler2, LexicalHandler, DTDHandler, DeclHandler + implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler { private static final String XMLNS_URI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI; @@ -77,6 +81,8 @@ boolean expandEntityReferences; boolean ignoreComments; boolean coalescing; + + XMLReader reader; // reference back to the parser to get features DomDocument doc; // document being constructed Node ctx; // current context (parent node) @@ -110,20 +116,42 @@ doc.setStrictErrorChecking(false); doc.setBuilding(true); ctx = doc; - } - public void xmlDecl(String version, String encoding, boolean standalone, - String inputEncoding) - throws SAXException - { - if (interrupted) + final String FEATURES = "http://xml.org/sax/features/"; + final String PROPERTIES = "http://xml.org/sax/properties/"; + final String GNU_PROPERTIES = "http://gnu.org/sax/properties/"; + + boolean standalone = reader.getFeature(FEATURES + "is-standalone"); + doc.setXmlStandalone(standalone); + try + { + String version = (String) reader.getProperty(PROPERTIES + + "document-xml-version"); + doc.setXmlVersion(version); + } + catch (SAXNotRecognizedException e) + { + } + catch (SAXNotSupportedException e) + { + } + if (locator != null && locator instanceof Locator2) + { + String encoding = ((Locator2) locator).getEncoding(); + doc.setInputEncoding(encoding); + } + try + { + String encoding = (String) reader.getProperty(GNU_PROPERTIES + + "document-xml-encoding"); + doc.setXmlEncoding(encoding); + } + catch (SAXNotRecognizedException e) + { + } + catch (SAXNotSupportedException e) { - return; } - doc.setXmlVersion(version); - doc.setXmlEncoding(encoding); - doc.setXmlStandalone(standalone); - doc.setInputEncoding(inputEncoding); } public void endDocument() Index: gnu/xml/pipeline/DomConsumer.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/pipeline/DomConsumer.java,v retrieving revision 1.3 diff -u -r1.3 DomConsumer.java --- gnu/xml/pipeline/DomConsumer.java 2 Jul 2005 20:32:16 -0000 1.3 +++ gnu/xml/pipeline/DomConsumer.java 24 Dec 2005 13:54:59 -0000 @@ -37,7 +37,6 @@ package gnu.xml.pipeline; -import gnu.xml.aelfred2.ContentHandler2; import gnu.xml.util.DomParser; import org.xml.sax.Attributes; @@ -330,7 +329,7 @@ * accepted illegal input data).

*/ public static class Handler - implements ContentHandler2, LexicalHandler, + implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler { protected DomConsumer consumer; @@ -430,20 +429,6 @@ top = document; } - // ContentHandler2 - public void xmlDecl(String version, - String encoding, - boolean standalone, - String inputEncoding) - throws SAXException - { - if (document != null) - { - document.setXmlVersion(version); - document.setXmlStandalone(standalone); - } - } - // SAX1 public void endDocument () throws SAXException Index: gnu/xml/pipeline/EventFilter.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/pipeline/EventFilter.java,v retrieving revision 1.2 diff -u -r1.2 EventFilter.java --- gnu/xml/pipeline/EventFilter.java 2 Jul 2005 20:32:16 -0000 1.2 +++ gnu/xml/pipeline/EventFilter.java 24 Dec 2005 13:54:59 -0000 @@ -44,8 +44,6 @@ import org.xml.sax.ext.*; import org.xml.sax.helpers.XMLFilterImpl; -import gnu.xml.aelfred2.ContentHandler2; - /** * A customizable event consumer, used to assemble various kinds of filters * using SAX handlers and an optional second consumer. It can be constructed @@ -138,7 +136,7 @@ * @author David Brownell */ public class EventFilter - implements EventConsumer, ContentHandler2, DTDHandler, + implements EventConsumer, ContentHandler, DTDHandler, LexicalHandler, DeclHandler { // SAX handlers @@ -600,17 +598,6 @@ docNext.startDocument (); } - public void xmlDecl(String version, String encoding, boolean standalone, - String inputEncoding) - throws SAXException - { - if (docNext != null && docNext instanceof ContentHandler2) - { - ((ContentHandler2) docNext).xmlDecl(version, encoding, standalone, - inputEncoding); - } - } - /** SAX2: passes this callback to the next consumer, if any */ public void skippedEntity (String name) throws SAXException { Index: gnu/xml/stream/SAXParser.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/stream/SAXParser.java,v retrieving revision 1.5 diff -u -r1.5 SAXParser.java --- gnu/xml/stream/SAXParser.java 23 Dec 2005 12:43:20 -0000 1.5 +++ gnu/xml/stream/SAXParser.java 24 Dec 2005 13:54:59 -0000 @@ -102,6 +102,7 @@ String encoding; String xmlVersion; boolean xmlStandalone; + String xmlEncoding; public SAXParser() { @@ -143,12 +144,17 @@ { if (parser != null) throw new IllegalStateException("parsing in progress"); - String FEATURES = "http://xml.org/sax/features/"; - String PROPERTIES = "http://xml.org/sax/properties/"; - if ((FEATURES + "namespaces").equals(name)) + final String FEATURES = "http://xml.org/sax/features/"; + final String PROPERTIES = "http://xml.org/sax/properties/"; + if ((FEATURES + "namespaces").equals(name) || + (FEATURES + "namespace-prefixes").equals(name)) namespaceAware = Boolean.TRUE.equals(value); else if ((FEATURES + "string-interning").equals(name)) stringInterning = Boolean.TRUE.equals(value); + else if ((FEATURES + "use-attributes2").equals(name)) + { + // NOOP + } else if ((FEATURES + "validation").equals(name)) validating = Boolean.TRUE.equals(value); else if ((FEATURES + "external-general-entities").equals(name)) @@ -166,11 +172,13 @@ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - String FEATURES = "http://xml.org/sax/features/"; - String PROPERTIES = "http://xml.org/sax/properties/"; + final String FEATURES = "http://xml.org/sax/features/"; + final String PROPERTIES = "http://xml.org/sax/properties/"; + final String GNU_PROPERTIES = "http://gnu.org/sax/properties/"; if ((FEATURES + "is-standalone").equals(name)) return xmlStandalone ? Boolean.TRUE : Boolean.FALSE; - if ((FEATURES + "namespaces").equals(name)) + if ((FEATURES + "namespaces").equals(name) || + (FEATURES + "namespace-prefixes").equals(name)) return namespaceAware ? Boolean.TRUE : Boolean.FALSE; if ((FEATURES + "string-interning").equals(name)) return stringInterning ? Boolean.TRUE : Boolean.FALSE; @@ -194,6 +202,8 @@ return xmlVersion; if ((PROPERTIES + "lexical-handler").equals(name)) return lexicalHandler; + if ((GNU_PROPERTIES + "document-xml-encoding").equals(name)) + return xmlEncoding; throw new SAXNotSupportedException(name); } @@ -385,6 +395,8 @@ { String nsuri = reader.getNamespaceURI(i); String nsprefix = reader.getNamespacePrefix(i); + if ("xml".equals(nsprefix)) + continue; contentHandler.startPrefixMapping(nsprefix, nsuri); } } @@ -413,6 +425,8 @@ for (int i = 0; i < nc; i++) { String nsprefix = reader.getNamespacePrefix(i); + if ("xml".equals(nsprefix)) + continue; contentHandler.endPrefixMapping(nsprefix); } } @@ -439,6 +453,7 @@ encoding = reader.getEncoding(); xmlVersion = reader.getVersion(); xmlStandalone = reader.isStandalone(); + xmlEncoding = reader.getCharacterEncodingScheme(); if (contentHandler != null) contentHandler.startDocument(); startDocumentDone = true; @@ -554,6 +569,29 @@ dtdHandler.notationDecl(name, pub, url); } } + else if ('c' == c) + { + // Comment + if (lexicalHandler != null) + { + String comment = doctype.getComment(name); + char[] b = comment.toCharArray(); + lexicalHandler.comment(b, 0, b.length); + } + } + else if ('p' == c) + { + // Processing instruction + if (contentHandler != null) + { + String[] pi = doctype.getPI(name); + String target = pi[0]; + String data = pi[1]; + if (data == null) + data = ""; + contentHandler.processingInstruction(target, data); + } + } } if (lexicalHandler != null) lexicalHandler.endDTD(); Index: gnu/xml/stream/XMLParser.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/xml/stream/XMLParser.java,v retrieving revision 1.9 diff -u -r1.9 XMLParser.java --- gnu/xml/stream/XMLParser.java 23 Dec 2005 12:43:20 -0000 1.9 +++ gnu/xml/stream/XMLParser.java 24 Dec 2005 13:55:00 -0000 @@ -777,12 +777,12 @@ } else if (tryRead(TEST_COMMENT)) { - readComment(); + readComment(false); event = XMLStreamConstants.COMMENT; } else if (tryRead(TEST_PI)) { - readPI(); + readPI(false); event = XMLStreamConstants.PROCESSING_INSTRUCTION; } else if (tryRead(TEST_CDATA)) @@ -860,12 +860,12 @@ } else if (tryRead(TEST_COMMENT)) { - readComment(); + readComment(false); event = XMLStreamConstants.COMMENT; } else if (tryRead(TEST_PI)) { - readPI(); + readPI(false); event = XMLStreamConstants.PROCESSING_INSTRUCTION; } else if (tryRead(TEST_START_ELEMENT)) @@ -883,12 +883,12 @@ skipWhitespace(); if (tryRead(TEST_COMMENT)) { - readComment(); + readComment(false); event = XMLStreamConstants.COMMENT; } else if (tryRead(TEST_PI)) { - readPI(); + readPI(false); event = XMLStreamConstants.PROCESSING_INSTRUCTION; } else @@ -1056,8 +1056,20 @@ char c = readCh(); if (c == '\uffff') throw new EOFException(); - else if (c < 32 && c != 10 && c != 9 && c != 13) - error("illegal XML character", Character.toString(c)); + else if (input.xml11) + { + if (!isXML11Char((int) c)) + error("illegal XML 1.1 character", Character.toString(c)); + } + else + { + if (c < 32 && c != 10 && c != 9 && c != 13) + error("illegal XML character", Character.toString(c)); + else if (c > '\ud7ff' && c < '\ue000') + error("illegal XML character", Character.toString(c)); + else if (c > '\ufffd') + error("illegal XML character", Character.toString(c)); + } buf.append(c); } } @@ -1215,6 +1227,8 @@ private void pushInput(Input input) { inputStack.addLast(input); + if (this.input != null) + input.xml11 = this.input.xml11; this.input = input; //System.out.println("\n(input:"+input.systemId+")"); } @@ -1326,7 +1340,12 @@ if ("1.0".equals(v)) input.xml11 = false; else if ("1.1".equals(v)) - input.xml11 = true; + { + Input i1 = (Input) inputStack.getFirst(); + if (!i1.xml11) + error("external entity specifies later version number"); + input.xml11 = true; + } else throw new XMLStreamException("illegal XML version: " + v); requireWhitespace(); @@ -1495,12 +1514,12 @@ else if (tryRead(TEST_PI)) { expandPE = saved; - readPI(); + readPI(true); } else if (tryRead(TEST_COMMENT)) { expandPE = saved; - readComment(); + readComment(true); } else if (tryRead("'); expandPE = saved; + if (inDTD) + doctype.addComment(buf.toString()); } /** * Parse a processing instruction. */ - private void readPI() + private void readPI(boolean inDTD) throws IOException, XMLStreamException { boolean saved = expandPE; @@ -2208,6 +2264,8 @@ piData = buf.toString(); } expandPE = saved; + if (inDTD) + doctype.addPI(piTarget, piData); } /** @@ -2650,12 +2708,21 @@ try { int ord = Integer.parseInt(b.toString(), base); - if ((ord < 0x20 && !(ord == 0x0a || ord == 0x09 || ord == 0x0d)) - || (ord >= 0xd800 && ord <= 0xdfff) - || ord == 0xfffe || ord == 0xffff - || ord > 0x0010ffff) - error("illegal XML character reference" + - "U+" + Integer.toHexString(ord)); + if (input.xml11) + { + if (!isXML11Char(ord)) + error("illegal XML 1.1 character reference " + + "U+" + Integer.toHexString(ord)); + } + else + { + if ((ord < 0x20 && !(ord == 0x0a || ord == 0x09 || ord == 0x0d)) + || (ord >= 0xd800 && ord <= 0xdfff) + || ord == 0xfffe || ord == 0xffff + || ord > 0x0010ffff) + error("illegal XML character reference " + + "U+" + Integer.toHexString(ord)); + } return Character.toChars(ord); } catch (NumberFormatException e) @@ -2722,107 +2789,420 @@ while (true); } + private boolean isXML11Char(int c) + { + return ((c >= 0x0001 && c <= 0xD7FF) || + (c >= 0xE000 && c <= 0xFFFD) || + (c >= 0x10000 && c <= 0x10FFFF)); + } + + private boolean isXML11RestrictedChar(int c) + { + return ((c >= 0x0001 && c <= 0x0008) || + (c >= 0x000B && c <= 0x000C) || + (c >= 0x000E && c <= 0x001F) || + (c >= 0x007F && c <= 0x0084) || + (c >= 0x0086 && c <= 0x009F)); + } + private boolean isNameStartCharacter(char c) { if (input.xml11) - { - if ((c < 0x0041 || c > 0x005a) && - (c < 0x0061 || c > 0x007a) && - c != ':' && c != '_' && - (c < 0x00c0 || c > 0x00d6) && - (c < 0x00d8 || c > 0x00f6) && - (c < 0x00f8 || c > 0x02ff) && - (c < 0x0370 || c > 0x037d) && - (c < 0x037f || c > 0x1fff) && - (c < 0x200c || c > 0x200d) && - (c < 0x2070 || c > 0x218f) && - (c < 0x2c00 || c > 0x2fef) && - (c < 0x3001 || c > 0xd7ff) && - (c < 0xf900 || c > 0xfdcf) && - (c < 0xfdf0 || c > 0xfffd) && - (c < 0x10000 || c > 0xeffff)) - return false; - } + return ((c >= 0x0041 && c <= 0x005a) || + (c >= 0x0061 && c <= 0x007a) || + c == ':' | + c == '_' | + (c >= 0xC0 && c <= 0xD6) || + (c >= 0xD8 && c <= 0xF6) || + (c >= 0xF8 && c <= 0x2FF) || + (c >= 0x370 && c <= 0x37D) || + (c >= 0x37F && c <= 0x1FFF) || + (c >= 0x200C && c <= 0x200D) || + (c >= 0x2070 && c <= 0x218F) || + (c >= 0x2C00 && c <= 0x2FEF) || + (c >= 0x3001 && c <= 0xD7FF) || + (c >= 0xF900 && c <= 0xFDCF) || + (c >= 0xFDF0 && c <= 0xFFFD) || + (c >= 0x10000 && c <= 0xEFFFF)); else - { - int type = Character.getType(c); - switch (type) - { - case Character.LOWERCASE_LETTER: // Ll - case Character.UPPERCASE_LETTER: // Lu - case Character.OTHER_LETTER: // Lo - case Character.TITLECASE_LETTER: // Lt - case Character.LETTER_NUMBER: // Nl - if ((c > 0xf900 && c < 0xfffe) || - (c >= 0x20dd && c <= 0x20e0)) - { - // Compatibility area and Unicode 2.0 exclusions - return false; - } - break; - default: - if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && - c != 0x0559 && c != 0x06e5 && c != 0x06e6) - return false; - } - } - return true; + return (c == '_' || c == ':' || isLetter(c)); } private boolean isNameCharacter(char c) { if (input.xml11) - { - if ((c < 0x0041 || c > 0x005a) && - (c < 0x0061 || c > 0x007a) && - (c < 0x0030 || c > 0x0039) && - c != ':' && c != '_' && c != '-' && c != '.' && - (c < 0x00c0 || c > 0x00d6) && - (c < 0x00d8 || c > 0x00f6) && - (c < 0x00f8 || c > 0x02ff) && - (c < 0x0370 || c > 0x037d) && - (c < 0x037f || c > 0x1fff) && - (c < 0x200c || c > 0x200d) && - (c < 0x2070 || c > 0x218f) && - (c < 0x2c00 || c > 0x2fef) && - (c < 0x3001 || c > 0xd7ff) && - (c < 0xf900 || c > 0xfdcf) && - (c < 0xfdf0 || c > 0xfffd) && - (c < 0x10000 || c > 0xeffff) && - c != 0x00b7 && - (c < 0x0300 || c > 0x036f) && - (c < 0x203f || c > 0x2040)) - return false; - } + return ((c >= 0x0041 && c <= 0x005a) || + (c >= 0x0061 && c <= 0x007a) || + (c >= 0x0030 && c <= 0x0039) || + c == ':' | + c == '_' | + c == '-' | + c == '.' | + c == 0xB7 | + (c >= 0xC0 && c <= 0xD6) || + (c >= 0xD8 && c <= 0xF6) || + (c >= 0xF8 && c <= 0x2FF) || + (c >= 0x300 && c <= 0x37D) || + (c >= 0x37F && c <= 0x1FFF) || + (c >= 0x200C && c <= 0x200D) || + (c >= 0x203F && c <= 0x2040) || + (c >= 0x2070 && c <= 0x218F) || + (c >= 0x2C00 && c <= 0x2FEF) || + (c >= 0x3001 && c <= 0xD7FF) || + (c >= 0xF900 && c <= 0xFDCF) || + (c >= 0xFDF0 && c <= 0xFFFD) || + (c >= 0x10000 && c <= 0xEFFFF)); else - { - int type = Character.getType(c); - switch (type) - { - case Character.LOWERCASE_LETTER: // Ll - case Character.UPPERCASE_LETTER: // Lu - case Character.DECIMAL_DIGIT_NUMBER: // Nd - case Character.OTHER_LETTER: // Lo - case Character.TITLECASE_LETTER: // Lt - case Character.LETTER_NUMBER: // Nl - case Character.COMBINING_SPACING_MARK: // Mc - case Character.ENCLOSING_MARK: // Me - case Character.NON_SPACING_MARK: // Mn - case Character.MODIFIER_LETTER: // Lm - if ((c > 0xf900 && c < 0xfffe) || - (c >= 0x20dd && c <= 0x20e0)) - return false; - break; - default: - if (c != '-' && c != '.' && c != ':' && c != '_' && - c != 0x0387 && (c < 0x02bb || c > 0x02c1) && - c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) - return false; - } - } - return true; + return (c == '.' || c == '-' || c == '_' || c == ':' || + isLetter(c) || isDigit(c) || + isCombiningChar(c) || isExtender(c)); + } + + public static boolean isLetter(char c) + { + if ((c >= 0x0041 && c <= 0x005A) || + (c >= 0x0061 && c <= 0x007A) || + (c >= 0x00C0 && c <= 0x00D6) || + (c >= 0x00D8 && c <= 0x00F6) || + (c >= 0x00F8 && c <= 0x00FF) || + (c >= 0x0100 && c <= 0x0131) || + (c >= 0x0134 && c <= 0x013E) || + (c >= 0x0141 && c <= 0x0148) || + (c >= 0x014A && c <= 0x017E) || + (c >= 0x0180 && c <= 0x01C3) || + (c >= 0x01CD && c <= 0x01F0) || + (c >= 0x01F4 && c <= 0x01F5) || + (c >= 0x01FA && c <= 0x0217) || + (c >= 0x0250 && c <= 0x02A8) || + (c >= 0x02BB && c <= 0x02C1) || + c == 0x0386 || + (c >= 0x0388 && c <= 0x038A) || + c == 0x038C || + (c >= 0x038E && c <= 0x03A1) || + (c >= 0x03A3 && c <= 0x03CE) || + (c >= 0x03D0 && c <= 0x03D6) || + c == 0x03DA || + c == 0x03DC || + c == 0x03DE || + c == 0x03E0 || + (c >= 0x03E2 && c <= 0x03F3) || + (c >= 0x0401 && c <= 0x040C) || + (c >= 0x040E && c <= 0x044F) || + (c >= 0x0451 && c <= 0x045C) || + (c >= 0x045E && c <= 0x0481) || + (c >= 0x0490 && c <= 0x04C4) || + (c >= 0x04C7 && c <= 0x04C8) || + (c >= 0x04CB && c <= 0x04CC) || + (c >= 0x04D0 && c <= 0x04EB) || + (c >= 0x04EE && c <= 0x04F5) || + (c >= 0x04F8 && c <= 0x04F9) || + (c >= 0x0531 && c <= 0x0556) || + c == 0x0559 || + (c >= 0x0561 && c <= 0x0586) || + (c >= 0x05D0 && c <= 0x05EA) || + (c >= 0x05F0 && c <= 0x05F2) || + (c >= 0x0621 && c <= 0x063A) || + (c >= 0x0641 && c <= 0x064A) || + (c >= 0x0671 && c <= 0x06B7) || + (c >= 0x06BA && c <= 0x06BE) || + (c >= 0x06C0 && c <= 0x06CE) || + (c >= 0x06D0 && c <= 0x06D3) || + c == 0x06D5 || + (c >= 0x06E5 && c <= 0x06E6) || + (c >= 0x0905 && c <= 0x0939) || + c == 0x093D || + (c >= 0x0958 && c <= 0x0961) || + (c >= 0x0985 && c <= 0x098C) || + (c >= 0x098F && c <= 0x0990) || + (c >= 0x0993 && c <= 0x09A8) || + (c >= 0x09AA && c <= 0x09B0) || + c == 0x09B2 || + (c >= 0x09B6 && c <= 0x09B9) || + (c >= 0x09DC && c <= 0x09DD) || + (c >= 0x09DF && c <= 0x09E1) || + (c >= 0x09F0 && c <= 0x09F1) || + (c >= 0x0A05 && c <= 0x0A0A) || + (c >= 0x0A0F && c <= 0x0A10) || + (c >= 0x0A13 && c <= 0x0A28) || + (c >= 0x0A2A && c <= 0x0A30) || + (c >= 0x0A32 && c <= 0x0A33) || + (c >= 0x0A35 && c <= 0x0A36) || + (c >= 0x0A38 && c <= 0x0A39) || + (c >= 0x0A59 && c <= 0x0A5C) || + c == 0x0A5E || + (c >= 0x0A72 && c <= 0x0A74) || + (c >= 0x0A85 && c <= 0x0A8B) || + c == 0x0A8D || + (c >= 0x0A8F && c <= 0x0A91) || + (c >= 0x0A93 && c <= 0x0AA8) || + (c >= 0x0AAA && c <= 0x0AB0) || + (c >= 0x0AB2 && c <= 0x0AB3) || + (c >= 0x0AB5 && c <= 0x0AB9) || + c == 0x0ABD || + c == 0x0AE0 || + (c >= 0x0B05 && c <= 0x0B0C) || + (c >= 0x0B0F && c <= 0x0B10) || + (c >= 0x0B13 && c <= 0x0B28) || + (c >= 0x0B2A && c <= 0x0B30) || + (c >= 0x0B32 && c <= 0x0B33) || + (c >= 0x0B36 && c <= 0x0B39) || + c == 0x0B3D || + (c >= 0x0B5C && c <= 0x0B5D) || + (c >= 0x0B5F && c <= 0x0B61) || + (c >= 0x0B85 && c <= 0x0B8A) || + (c >= 0x0B8E && c <= 0x0B90) || + (c >= 0x0B92 && c <= 0x0B95) || + (c >= 0x0B99 && c <= 0x0B9A) || + c == 0x0B9C || + (c >= 0x0B9E && c <= 0x0B9F) || + (c >= 0x0BA3 && c <= 0x0BA4) || + (c >= 0x0BA8 && c <= 0x0BAA) || + (c >= 0x0BAE && c <= 0x0BB5) || + (c >= 0x0BB7 && c <= 0x0BB9) || + (c >= 0x0C05 && c <= 0x0C0C) || + (c >= 0x0C0E && c <= 0x0C10) || + (c >= 0x0C12 && c <= 0x0C28) || + (c >= 0x0C2A && c <= 0x0C33) || + (c >= 0x0C35 && c <= 0x0C39) || + (c >= 0x0C60 && c <= 0x0C61) || + (c >= 0x0C85 && c <= 0x0C8C) || + (c >= 0x0C8E && c <= 0x0C90) || + (c >= 0x0C92 && c <= 0x0CA8) || + (c >= 0x0CAA && c <= 0x0CB3) || + (c >= 0x0CB5 && c <= 0x0CB9) || + c == 0x0CDE || + (c >= 0x0CE0 && c <= 0x0CE1) || + (c >= 0x0D05 && c <= 0x0D0C) || + (c >= 0x0D0E && c <= 0x0D10) || + (c >= 0x0D12 && c <= 0x0D28) || + (c >= 0x0D2A && c <= 0x0D39) || + (c >= 0x0D60 && c <= 0x0D61) || + (c >= 0x0E01 && c <= 0x0E2E) || + c == 0x0E30 || + (c >= 0x0E32 && c <= 0x0E33) || + (c >= 0x0E40 && c <= 0x0E45) || + (c >= 0x0E81 && c <= 0x0E82) || + c == 0x0E84 || + (c >= 0x0E87 && c <= 0x0E88) || + c == 0x0E8A || + c == 0x0E8D || + (c >= 0x0E94 && c <= 0x0E97) || + (c >= 0x0E99 && c <= 0x0E9F) || + (c >= 0x0EA1 && c <= 0x0EA3) || + c == 0x0EA5 || + c == 0x0EA7 || + (c >= 0x0EAA && c <= 0x0EAB) || + (c >= 0x0EAD && c <= 0x0EAE) || + c == 0x0EB0 || + (c >= 0x0EB2 && c <= 0x0EB3) || + c == 0x0EBD || + (c >= 0x0EC0 && c <= 0x0EC4) || + (c >= 0x0F40 && c <= 0x0F47) || + (c >= 0x0F49 && c <= 0x0F69) || + (c >= 0x10A0 && c <= 0x10C5) || + (c >= 0x10D0 && c <= 0x10F6) || + c == 0x1100 || + (c >= 0x1102 && c <= 0x1103) || + (c >= 0x1105 && c <= 0x1107) || + c == 0x1109 || + (c >= 0x110B && c <= 0x110C) || + (c >= 0x110E && c <= 0x1112) || + c == 0x113C || + c == 0x113E || + c == 0x1140 || + c == 0x114C || + c == 0x114E || + c == 0x1150 || + (c >= 0x1154 && c <= 0x1155) || + c == 0x1159 || + (c >= 0x115F && c <= 0x1161) || + c == 0x1163 || + c == 0x1165 || + c == 0x1167 || + c == 0x1169 || + (c >= 0x116D && c <= 0x116E) || + (c >= 0x1172 && c <= 0x1173) || + c == 0x1175 || + c == 0x119E || + c == 0x11A8 || + c == 0x11AB || + (c >= 0x11AE && c <= 0x11AF) || + (c >= 0x11B7 && c <= 0x11B8) || + c == 0x11BA || + (c >= 0x11BC && c <= 0x11C2) || + c == 0x11EB || + c == 0x11F0 || + c == 0x11F9 || + (c >= 0x1E00 && c <= 0x1E9B) || + (c >= 0x1EA0 && c <= 0x1EF9) || + (c >= 0x1F00 && c <= 0x1F15) || + (c >= 0x1F18 && c <= 0x1F1D) || + (c >= 0x1F20 && c <= 0x1F45) || + (c >= 0x1F48 && c <= 0x1F4D) || + (c >= 0x1F50 && c <= 0x1F57) || + c == 0x1F59 || + c == 0x1F5B || + c == 0x1F5D || + (c >= 0x1F5F && c <= 0x1F7D) || + (c >= 0x1F80 && c <= 0x1FB4) || + (c >= 0x1FB6 && c <= 0x1FBC) || + c == 0x1FBE || + (c >= 0x1FC2 && c <= 0x1FC4) || + (c >= 0x1FC6 && c <= 0x1FCC) || + (c >= 0x1FD0 && c <= 0x1FD3) || + (c >= 0x1FD6 && c <= 0x1FDB) || + (c >= 0x1FE0 && c <= 0x1FEC) || + (c >= 0x1FF2 && c <= 0x1FF4) || + (c >= 0x1FF6 && c <= 0x1FFC) || + c == 0x2126 || + (c >= 0x212A && c <= 0x212B) || + c == 0x212E || + (c >= 0x2180 && c <= 0x2182) || + (c >= 0x3041 && c <= 0x3094) || + (c >= 0x30A1 && c <= 0x30FA) || + (c >= 0x3105 && c <= 0x312C) || + (c >= 0xAC00 && c <= 0xD7A3)) + return true; // BaseChar + if ((c >= 0x4e00 && c <= 0x9fa5) || + c == 0x3007 || + (c >= 0x3021 && c <= 0x3029)) + return true; // Ideographic + return false; } + public static boolean isDigit(char c) + { + return ((c >= 0x0030 && c <= 0x0039) || + (c >= 0x0660 && c <= 0x0669) || + (c >= 0x06F0 && c <= 0x06F9) || + (c >= 0x0966 && c <= 0x096F) || + (c >= 0x09E6 && c <= 0x09EF) || + (c >= 0x0A66 && c <= 0x0A6F) || + (c >= 0x0AE6 && c <= 0x0AEF) || + (c >= 0x0B66 && c <= 0x0B6F) || + (c >= 0x0BE7 && c <= 0x0BEF) || + (c >= 0x0C66 && c <= 0x0C6F) || + (c >= 0x0CE6 && c <= 0x0CEF) || + (c >= 0x0D66 && c <= 0x0D6F) || + (c >= 0x0E50 && c <= 0x0E59) || + (c >= 0x0ED0 && c <= 0x0ED9) || + (c >= 0x0F20 && c <= 0x0F29)); + } + + public static boolean isCombiningChar(char c) + { + return ((c >= 0x0300 && c <= 0x0345) || + (c >= 0x0360 && c <= 0x0361) || + (c >= 0x0483 && c <= 0x0486) || + (c >= 0x0591 && c <= 0x05A1) || + (c >= 0x05A3 && c <= 0x05B9) || + (c >= 0x05BB && c <= 0x05BD) || + c == 0x05BF || + (c >= 0x05C1 && c <= 0x05C2) || + c == 0x05C4 || + (c >= 0x064B && c <= 0x0652) || + c == 0x0670 || + (c >= 0x06D6 && c <= 0x06DC) || + (c >= 0x06DD && c <= 0x06DF) || + (c >= 0x06E0 && c <= 0x06E4) || + (c >= 0x06E7 && c <= 0x06E8) || + (c >= 0x06EA && c <= 0x06ED) || + (c >= 0x0901 && c <= 0x0903) || + c == 0x093C || + (c >= 0x093E && c <= 0x094C) || + c == 0x094D || + (c >= 0x0951 && c <= 0x0954) || + (c >= 0x0962 && c <= 0x0963) || + (c >= 0x0981 && c <= 0x0983) || + c == 0x09BC || + c == 0x09BE || + c == 0x09BF || + (c >= 0x09C0 && c <= 0x09C4) || + (c >= 0x09C7 && c <= 0x09C8) || + (c >= 0x09CB && c <= 0x09CD) || + c == 0x09D7 || + (c >= 0x09E2 && c <= 0x09E3) || + c == 0x0A02 || + c == 0x0A3C || + c == 0x0A3E || + c == 0x0A3F || + (c >= 0x0A40 && c <= 0x0A42) || + (c >= 0x0A47 && c <= 0x0A48) || + (c >= 0x0A4B && c <= 0x0A4D) || + (c >= 0x0A70 && c <= 0x0A71) || + (c >= 0x0A81 && c <= 0x0A83) || + c == 0x0ABC || + (c >= 0x0ABE && c <= 0x0AC5) || + (c >= 0x0AC7 && c <= 0x0AC9) || + (c >= 0x0ACB && c <= 0x0ACD) || + (c >= 0x0B01 && c <= 0x0B03) || + c == 0x0B3C || + (c >= 0x0B3E && c <= 0x0B43) || + (c >= 0x0B47 && c <= 0x0B48) || + (c >= 0x0B4B && c <= 0x0B4D) || + (c >= 0x0B56 && c <= 0x0B57) || + (c >= 0x0B82 && c <= 0x0B83) || + (c >= 0x0BBE && c <= 0x0BC2) || + (c >= 0x0BC6 && c <= 0x0BC8) || + (c >= 0x0BCA && c <= 0x0BCD) || + c == 0x0BD7 || + (c >= 0x0C01 && c <= 0x0C03) || + (c >= 0x0C3E && c <= 0x0C44) || + (c >= 0x0C46 && c <= 0x0C48) || + (c >= 0x0C4A && c <= 0x0C4D) || + (c >= 0x0C55 && c <= 0x0C56) || + (c >= 0x0C82 && c <= 0x0C83) || + (c >= 0x0CBE && c <= 0x0CC4) || + (c >= 0x0CC6 && c <= 0x0CC8) || + (c >= 0x0CCA && c <= 0x0CCD) || + (c >= 0x0CD5 && c <= 0x0CD6) || + (c >= 0x0D02 && c <= 0x0D03) || + (c >= 0x0D3E && c <= 0x0D43) || + (c >= 0x0D46 && c <= 0x0D48) || + (c >= 0x0D4A && c <= 0x0D4D) || + c == 0x0D57 || + c == 0x0E31 || + (c >= 0x0E34 && c <= 0x0E3A) || + (c >= 0x0E47 && c <= 0x0E4E) || + c == 0x0EB1 || + (c >= 0x0EB4 && c <= 0x0EB9) || + (c >= 0x0EBB && c <= 0x0EBC) || + (c >= 0x0EC8 && c <= 0x0ECD) || + (c >= 0x0F18 && c <= 0x0F19) || + c == 0x0F35 || + c == 0x0F37 || + c == 0x0F39 || + c == 0x0F3E || + c == 0x0F3F || + (c >= 0x0F71 && c <= 0x0F84) || + (c >= 0x0F86 && c <= 0x0F8B) || + (c >= 0x0F90 && c <= 0x0F95) || + c == 0x0F97 || + (c >= 0x0F99 && c <= 0x0FAD) || + (c >= 0x0FB1 && c <= 0x0FB7) || + c == 0x0FB9 || + (c >= 0x20D0 && c <= 0x20DC) || + c == 0x20E1 || + (c >= 0x302A && c <= 0x302F) || + c == 0x3099 || + c == 0x309A); + } + + public static boolean isExtender(char c) + { + return (c == 0x00B7 || + c == 0x02D0 || + c == 0x02D1 || + c == 0x0387 || + c == 0x0640 || + c == 0x0E46 || + c == 0x0EC6 || + c == 0x3005 || + (c >= 0x3031 && c <= 0x3035) || + (c >= 0x309D && c <= 0x309E) || + (c >= 0x30FC && c <= 0x30FE)); + } + private String intern(String text) { return stringInterning ? text.intern() : text; @@ -2962,7 +3342,7 @@ if (ci == -1) { prefix = null; - localName = name; + localName = intern(name); } else { @@ -2992,9 +3372,12 @@ private final LinkedHashMap attlists = new LinkedHashMap(); private final LinkedHashMap entities = new LinkedHashMap(); private final LinkedHashMap notations = new LinkedHashMap(); + private final LinkedHashMap comments = new LinkedHashMap(); + private final LinkedHashMap pis = new LinkedHashMap(); private final LinkedList entries = new LinkedList(); private final HashSet externalEntities = new HashSet(); private final HashSet externalNotations = new HashSet(); + private int anon = 1; Doctype(String rootName, String publicId, String systemId) { @@ -3057,6 +3440,20 @@ externalNotations.add(name); } + void addComment(String text) + { + String key = Integer.toString(anon++); + comments.put(key, text); + entries.add("c" + key); + } + + void addPI(String target, String data) + { + String key = Integer.toString(anon++); + pis.put(key, new String[] {target, data}); + entries.add("p" + key); + } + String getElementModel(String name) { return (String) elements.get(name); @@ -3101,6 +3498,16 @@ return externalNotations.contains(name); } + String getComment(String key) + { + return (String) comments.get(key); + } + + String[] getPI(String key) + { + return (String[]) pis.get(key); + } + Iterator entryIterator() { return entries.iterator(); @@ -3262,7 +3669,7 @@ offset++; int ret = reader.read(); //System.out.println("read1:"+((char) ret)); - if (ret == 0x0d) + if (ret == 0x0d || (xml11 && ret == 0x85)) ret = 0x0a; if (ret == 0x0a) { @@ -3287,7 +3694,7 @@ for (int i = 0; i < ret; i++) { char c = b[off + i]; - if (c == 0x0d) + if (c == 0x0d || (xml11 && c == 0x85)) { c = 0x0a; b[off + i] = c; @@ -3410,6 +3817,11 @@ if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { + if (inputEncoding == "UTF-8" && + (encoding.startsWith("UTF-16") || + encoding.startsWith("UTF-32"))) + throw new UnsupportedEncodingException("document is not in its " + + "declared encoding"); inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); Index: javax/xml/parsers/SAXParserFactory.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/xml/parsers/SAXParserFactory.java,v retrieving revision 1.3 diff -u -r1.3 SAXParserFactory.java --- javax/xml/parsers/SAXParserFactory.java 2 Jul 2005 20:32:52 -0000 1.3 +++ javax/xml/parsers/SAXParserFactory.java 24 Dec 2005 13:55:00 -0000 @@ -115,7 +115,7 @@ } } while (className == null && count < 3); - return new gnu.xml.aelfred2.JAXPFactory(); + return new gnu.xml.stream.SAXParserFactory(); } private static String getFactoryClassName(ClassLoader loader, int attempt) Index: resource/META-INF/services/javax.xml.parsers.SAXParserFactory =================================================================== RCS file: /cvsroot/classpath/classpath/resource/META-INF/services/javax.xml.parsers.SAXParserFactory,v retrieving revision 1.1 diff -u -r1.1 javax.xml.parsers.SAXParserFactory --- resource/META-INF/services/javax.xml.parsers.SAXParserFactory 25 May 2005 22:26:30 -0000 1.1 +++ resource/META-INF/services/javax.xml.parsers.SAXParserFactory 24 Dec 2005 13:55:00 -0000 @@ -1 +1 @@ -gnu.xml.aelfred2.JAXPFactory +gnu.xml.stream.SAXParserFactory