Index: dom/DeferredDocumentImpl.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -b -r1.38 -r1.39 --- dom/DeferredDocumentImpl.java 17 Dec 2001 20:47:13 -0000 1.38 +++ dom/DeferredDocumentImpl.java 20 Dec 2001 21:30:24 -0000 1.39 @@ -75,7 +75,7 @@ * which associates them with the Document within whose context they * were created. * - * @version $Id: DeferredDocumentImpl.java,v 1.38 2001/12/17 20:47:13 elena Exp $ + * @version $Id: DeferredDocumentImpl.java,v 1.39 2001/12/20 21:30:24 elena Exp $ * @since PR-DOM-Level-1-19980818. */ public class DeferredDocumentImpl @@ -1025,7 +1025,9 @@ if (prevSib != -1 && getNodeType(prevSib, false) == Node.TEXT_NODE) { // append data that is stored in fNodeValue - fBufferStr.append(value); + // REVISIT: for text nodes it works differently than for CDATA + // nodes. + fStrChunks.addElement(value); do { // go in reverse order: find last child, then // its previous sibling, etc Index: impl/XMLDTDScannerImpl.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -b -r1.11 -r1.12 --- impl/XMLDTDScannerImpl.java 14 Dec 2001 20:48:32 -0000 1.11 +++ impl/XMLDTDScannerImpl.java 2 Jan 2002 20:35:14 -0000 1.12 @@ -102,7 +102,7 @@ * @author Glenn Marcy, IBM * @author Eric Ye, IBM * - * @version $Id: XMLDTDScannerImpl.java,v 1.11 2001/12/14 20:48:32 lmartin Exp $ + * @version $Id: XMLDTDScannerImpl.java,v 1.12 2002/01/02 20:35:14 elena Exp $ */ public class XMLDTDScannerImpl extends XMLScanner @@ -192,6 +192,10 @@ /** Parameter entity stack to check well-formedness. */ private int[] fPEStack = new int[5]; + + /** Parameter entity stack to report start/end entity calls. */ + private boolean[] fPEReport = new boolean[5]; + /** Number of opened parameter entities. */ private int fPEDepth; @@ -457,7 +461,7 @@ fExtEntityDepth++; } else if (name.charAt(0) == '%') { - pushPEStack(fMarkUpDepth); + pushPEStack(fMarkUpDepth, fReportEntity); if (fEntityScanner.isExternal()) { fExtEntityDepth++; } @@ -483,6 +487,7 @@ // Handle end of PE boolean reportEntity = fReportEntity; if (name.startsWith("%")) { + reportEntity = peekReportEntity(); // check well-formedness of the enity int startMarkUpDepth = popPEStack(); if (startMarkUpDepth != fMarkUpDepth) { @@ -1649,18 +1654,21 @@ fReportEntity = false; skipSeparator(false, !scanningInternalSubset()); + if (fEntityScanner.skipString("INCLUDE")) { skipSeparator(false, !scanningInternalSubset()); // call handler + if (!fEntityScanner.skipChar('[')) { + reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null); + } + if (fDTDHandler != null) { fDTDHandler.startConditional( XMLDTDHandler.CONDITIONAL_INCLUDE); } - if (!fEntityScanner.skipChar('[')) { - reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null); - } fIncludeSectDepth++; // just stop there and go back to the main loop + fReportEntity = true; } else if (fEntityScanner.skipString("IGNORE")) { skipSeparator(false, !scanningInternalSubset()); @@ -1901,17 +1909,29 @@ /* * Parameter Entity Stack */ - private final void pushPEStack(int depth) { + private final void pushPEStack(int depth, boolean report) { if (fPEStack.length == fPEDepth) { int[] newIntStack = new int[fPEDepth * 2]; System.arraycopy(fPEStack, 0, newIntStack, 0, fPEDepth); fPEStack = newIntStack; + // report end/start calls + boolean[] newBooleanStack = new boolean[fPEDepth * 2]; + System.arraycopy(fPEReport, 0, newBooleanStack, 0, fPEDepth); + fPEReport = newBooleanStack; + } + fPEReport[fPEDepth] = report; fPEStack[fPEDepth++] = depth; } + /** pop the stack */ private final int popPEStack() { return fPEStack[--fPEDepth]; + } + + /** look at the top of the stack */ + private final boolean peekReportEntity() { + return fPEReport[fPEDepth-1]; } Index: impl/XMLEntityManager.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v retrieving revision 1.14 retrieving revision 1.16 diff -u -b -r1.14 -r1.16 --- impl/XMLEntityManager.java 17 Dec 2001 16:41:12 -0000 1.14 +++ impl/XMLEntityManager.java 4 Jan 2002 23:27:49 -0000 1.16 @@ -71,6 +71,7 @@ import org.apache.xerces.impl.XMLErrorReporter; import org.apache.xerces.impl.io.ASCIIReader; +import org.apache.xerces.impl.io.UCSReader; import org.apache.xerces.impl.io.UTF8Reader; import org.apache.xerces.impl.msg.XMLMessageFormatter; @@ -112,7 +113,7 @@ * @author Andy Clark, IBM * @author Arnaud Le Hors, IBM * - * @version $Id: XMLEntityManager.java,v 1.14 2001/12/17 16:41:12 neilg Exp $ + * @version $Id: XMLEntityManager.java,v 1.16 2002/01/04 23:27:49 neilg Exp $ */ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { @@ -703,6 +704,7 @@ final String systemId = xmlInputSource.getSystemId(); String baseSystemId = xmlInputSource.getBaseSystemId(); String encoding = xmlInputSource.getEncoding(); + Boolean isBigEndian = null; // create reader InputStream stream = null; @@ -728,7 +730,9 @@ b4[count] = (byte)stream.read(); } if (count == 4) { - encoding = getEncodingName(b4, count); + Object [] encodingDesc = getEncodingName(b4, count); + encoding = (String)(encodingDesc[0]); + isBigEndian = (Boolean)(encodingDesc[1]); // removed use of pushback inputstream--neilg /***** @@ -765,18 +769,18 @@ // indirection to get at the underlying bytes. -Ac // create reader from input stream - reader = createReader(new RewindableInputStream(pbstream), encoding); + reader = createReader(new RewindableInputStream(pbstream), encoding, isBigEndian); ******/ - reader = createReader(stream, encoding); + reader = createReader(stream, encoding, isBigEndian); } else { - reader = createReader(stream, encoding); + reader = createReader(stream, encoding, isBigEndian); } } // use specified encoding else { - reader = createReader(stream, encoding); + reader = createReader(stream, encoding, isBigEndian); } // read one character at a time so we don't jump too far @@ -1136,15 +1140,18 @@ /** * Returns the IANA encoding name that is auto-detected from - * the bytes specified. + * the bytes specified, with the endian-ness of that encoding where appropriate. * * @param b4 The first four bytes of the input. * @param count The number of bytes actually read. + * @return a 2-element array: the first element, an IANA-encoding string, + * the second element a Boolean which is true iff the document is big endian, false + * if it's little-endian, and null if the distinction isn't relevant. */ - protected String getEncodingName(byte[] b4, int count) { + protected Object[] getEncodingName(byte[] b4, int count) { if (count < 2) { - return "UTF-8"; + return new Object[]{"UTF-8", null}; } // UTF-16, with BOM @@ -1152,72 +1159,72 @@ int b1 = b4[1] & 0xFF; if (b0 == 0xFE && b1 == 0xFF) { // UTF-16, big-endian - return "UTF-16"; + return new Object [] {"UTF-16BE", new Boolean(true)}; } if (b0 == 0xFF && b1 == 0xFE) { // UTF-16, little-endian - return "UTF-16"; + return new Object [] {"UTF-16LE", new Boolean(false)}; } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 3) { - return "UTF-8"; + return new Object [] {"UTF-8", null}; } // UTF-8 with a BOM int b2 = b4[2] & 0xFF; if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) { - return "UTF-8"; + return new Object [] {"UTF-8", null}; } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 4) { - return "UTF-8"; + return new Object [] {"UTF-8", null}; } // other encodings int b3 = b4[3] & 0xFF; if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) { // UCS-4, big endian (1234) - // REVISIT: What should this be? - return "UnicodeBig"; + return new Object [] {"ISO-10646-UCS-4", new Boolean(true)}; } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) { // UCS-4, little endian (4321) - // REVISIT: What should this be? - return "UnicodeLittleUnmarked"; + return new Object [] {"ISO-10646-UCS-4", new Boolean(false)}; } if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) { // UCS-4, unusual octet order (2143) // REVISIT: What should this be? - return "UnicodeBigUnmarked"; + return new Object [] {"ISO-10646-UCS-4", null}; } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) { // UCS-4, unusual octect order (3412) // REVISIT: What should this be? - return "UnicodeLittleUnmarked"; + return new Object [] {"ISO-10646-UCS-4", null}; } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) { // UTF-16, big-endian, no BOM + // (or could turn out to be UCS-2... // REVISIT: What should this be? - return "UnicodeBig"; + return new Object [] {"UTF-16BE", new Boolean(true)}; } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) { // UTF-16, little-endian, no BOM - return "UnicodeLittle"; + // (or could turn out to be UCS-2... + return new Object [] {"UTF-16LE", new Boolean(false)}; } if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) { // EBCDIC // a la xerces1, return CP037 instead of EBCDIC here - return "CP037"; + return new Object [] {"CP037", null}; } // default encoding - return "UTF-8"; + return new Object [] {"UTF-8", null}; - } // getEncodingName(byte[],int):String + } // getEncodingName(byte[],int):Object[] /** * Creates a reader capable of reading the given input stream in @@ -1229,10 +1236,13 @@ * Java encoding names are allowed, then the * encoding name may be a Java encoding name; * otherwise, it is an ianaEncoding name. + * @param isBigEndian For encodings (like uCS-4), whose names cannot + * specify a byte order, this tells whether the order is bigEndian. null menas + * unknown or not relevant. * * @return Returns a reader. */ - protected Reader createReader(InputStream inputStream, String encoding) + protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) throws IOException { // normalize encoding name @@ -1254,6 +1264,36 @@ } return new ASCIIReader(inputStream, fBufferSize); } + if(ENCODING.equals("ISO-10646-UCS-4")) { + if(isBigEndian != null) { + boolean isBE = isBigEndian.booleanValue(); + if(isBE) { + return new UCSReader(inputStream, UCSReader.UCS4BE); + } else { + return new UCSReader(inputStream, UCSReader.UCS4LE); + } + } else { + fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, + "EncodingByteOrderUnsupported", + new Object[] { encoding }, + XMLErrorReporter.SEVERITY_FATAL_ERROR); + } + } + if(ENCODING.equals("ISO-10646-UCS-2")) { + if(isBigEndian != null) { // sould never happen with this encoding... + boolean isBE = isBigEndian.booleanValue(); + if(isBE) { + return new UCSReader(inputStream, UCSReader.UCS2BE); + } else { + return new UCSReader(inputStream, UCSReader.UCS2LE); + } + } else { + fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, + "EncodingByteOrderUnsupported", + new Object[] { encoding }, + XMLErrorReporter.SEVERITY_FATAL_ERROR); + } + } // check for valid name boolean validIANA = XMLChar.isValidIANAEncoding(encoding); @@ -1277,7 +1317,16 @@ // try to use a Java reader String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING); if (javaEncoding == null) { + if(fAllowJavaEncodings) { javaEncoding = encoding; + } else { + fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, + "EncodingDeclInvalid", + new Object[] { encoding }, + XMLErrorReporter.SEVERITY_FATAL_ERROR); + // see comment above. + javaEncoding = "ISO8859_1"; + } } if (DEBUG_ENCODINGS) { System.out.print("$$$ creating Java InputStreamReader: encoding="+javaEncoding); @@ -1288,7 +1337,7 @@ } return new InputStreamReader(inputStream, javaEncoding); - } // createReader(InputStream,String): + } // createReader(InputStream,String, Boolean): Reader // // Protected static methods @@ -1772,6 +1821,30 @@ // a single char! -Ac if (fCurrentEntity.encoding == null || !fCurrentEntity.encoding.equals(encoding)) { + // UTF-16 is a bit of a special case. If the encoding is UTF-16, + // and we know the endian-ness, we shouldn't change readers. + // If it's ISO-10646-UCS-(2|4), then we'll have to deduce + // the endian-ness from the encoding we presently have. + if(fCurrentEntity.encoding != null && fCurrentEntity.encoding.startsWith("UTF-16")) { + String ENCODING = encoding.toUpperCase(); + if(ENCODING.equals("UTF-16")) return; + if(ENCODING.equals("ISO-10646-UCS-4")) { + if(fCurrentEntity.encoding.equals("UTF-16BE")) { + fCurrentEntity.reader = new UCSReader(fCurrentEntity.stream, UCSReader.UCS4BE); + } else { + fCurrentEntity.reader = new UCSReader(fCurrentEntity.stream, UCSReader.UCS4LE); + } + return; + } + if(ENCODING.equals("ISO-10646-UCS-2")) { + if(fCurrentEntity.encoding.equals("UTF-16BE")) { + fCurrentEntity.reader = new UCSReader(fCurrentEntity.stream, UCSReader.UCS2BE); + } else { + fCurrentEntity.reader = new UCSReader(fCurrentEntity.stream, UCSReader.UCS2LE); + } + return; + } + } // wrap a new reader around the input stream, changing // the encoding if (DEBUG_ENCODINGS) { @@ -1779,7 +1852,7 @@ fCurrentEntity.stream); } //fCurrentEntity.stream.reset(); - fCurrentEntity.reader = createReader(fCurrentEntity.stream, encoding); + fCurrentEntity.reader = createReader(fCurrentEntity.stream, encoding, null); } else { if (DEBUG_ENCODINGS) System.out.println("$$$ reusing old reader on stream"); @@ -3146,10 +3219,9 @@ } public int read() throws IOException { - int b; + int b = 0; if (fOffset < fLength) { - System.err.println("REturned buffered: " + (char)(fData[fOffset++] & 0xFF)); - return fData[fOffset++] & 0xFF; + return fData[fOffset++] & 0xff; } if (fOffset == fEndOffset) { return -1; @@ -3166,7 +3238,7 @@ } fData[fLength++] = (byte)b; fOffset++; - return b; + return b & 0xff; } public int read(byte[] b, int off, int len) throws IOException { @@ -3179,13 +3251,12 @@ if(fCurrentEntity.mayReadChunks) { return fInputStream.read(b, off, len); } - b[off] = (byte)read(); - if(b[off] == -1) { + int returnedVal = read(); + if(returnedVal == -1) { fEndOffset = fOffset; return -1; } - byte [] c = new byte[off]; - System.arraycopy(b,0,c,0,off); + b[off] = (byte)returnedVal; return 1; } if (len < bytesLeft) { Index: impl/dtd/XMLDTDValidator.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- impl/dtd/XMLDTDValidator.java 14 Dec 2001 20:48:51 -0000 1.5 +++ impl/dtd/XMLDTDValidator.java 8 Jan 2002 18:24:30 -0000 1.6 @@ -124,7 +124,7 @@ * @author Andy Clark, IBM * @author Jeffrey Rodriguez IBM * - * @version $Id: XMLDTDValidator.java,v 1.5 2001/12/14 20:48:51 lmartin Exp $ + * @version $Id: XMLDTDValidator.java,v 1.6 2002/01/08 18:24:30 lmartin Exp $ */ public class XMLDTDValidator implements XMLComponent, @@ -2550,7 +2550,7 @@ return attrDecl.simpleType.list ? fIDREFSSymbol : fIDREFSymbol; } case XMLSimpleType.TYPE_NMTOKEN: { - return attrDecl.simpleType.list ? fNMTOKENSSymbol : fNMTOKENSSymbol; + return attrDecl.simpleType.list ? fNMTOKENSSymbol : fNMTOKENSymbol; } case XMLSimpleType.TYPE_NOTATION: { return fNOTATIONSymbol; Index: impl/dv/XSSimpleType.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/XSSimpleType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- impl/dv/XSSimpleType.java 6 Dec 2001 23:11:55 -0000 1.3 +++ impl/dv/XSSimpleType.java 4 Jan 2002 19:52:38 -0000 1.4 @@ -69,7 +69,7 @@ * * @author Sandy Gao, IBM * - * @version $Id: XSSimpleType.java,v 1.3 2001/12/06 23:11:55 sandygao Exp $ + * @version $Id: XSSimpleType.java,v 1.4 2002/01/04 19:52:38 sandygao Exp $ */ public interface XSSimpleType extends XSTypeDecl { @@ -236,20 +236,48 @@ * REVISIT: this method makes ID special, which is not a good design. * but since ID is not a primitive, there doesn't seem to be a * clean way of doing it except to define special method like this. + * + * @return whether this simple type is or is derived from ID. */ public boolean isIDType(); /** * Check whether this type is or is derived from NOTATION. * REVISIT: this method makes NOTATION special, which is not a good design. + * + * @return whether this simple type is or is derived from NOTATION. */ public boolean isNOTATIONType(); - // REVISIT: the following methods are for PSVI. they are not implemented yet. + // REVISIT: it's not decided yet how to return the facets, + // as String's or as values (Object's). //public XSFacet[] getFacets(); - // the following four are for fundamental facets - //public short getOrderedFacet(); - //public boolean isBounded(); - //public boolean isNumeric(); - //public short getCardinalityFacet(); + + /** + * Return the value of the "ordered" fundamental facet. + * + * @return a constant corresponding to the "ordered" facet. + */ + public short getOrderedFacet(); + + /** + * Return the value of the "bounded" fundamental facet. + * + * @return whether the this type is bounded. + */ + public boolean isBounded(); + + /** + * Return the value of the "numeric" fundamental facet. + * + * @return whether the this type is numeric. + */ + public boolean isNumeric(); + + /** + * Return the value of the "cardinality" fundamental facet. + * + * @return a constant corresponding to the "cardinality" facet. + */ + public short getCardinalityFacet(); } Index: impl/dv/xs_new/AnyURIDV.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs_new/AnyURIDV.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- impl/dv/xs_new/AnyURIDV.java 19 Nov 2001 20:13:01 -0000 1.1 +++ impl/dv/xs_new/AnyURIDV.java 3 Jan 2002 20:14:13 -0000 1.2 @@ -67,10 +67,18 @@ * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: AnyURIDV.java,v 1.1 2001/11/19 20:13:01 sandygao Exp $ + * @version $Id: AnyURIDV.java,v 1.2 2002/01/03 20:14:13 sandygao Exp $ */ public class AnyURIDV extends TypeValidator { + private static URI BASE_URI = null; + static { + try { + BASE_URI = new URI("http://www.template.com"); + } catch (URI.MalformedURIException ex) { + } + } + public short getAllowedFacets(){ return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE ); } @@ -81,13 +89,12 @@ // check 3.2.17.c0 must: URI (rfc 2396/2723) try { if( content.length() != 0 ) { - URI tempURI = new URI("http://www.template.com"); // Support for relative URLs // According to Java 1.1: URLs may also be specified with a // String and the URL object that it is related to. - new URI(tempURI, content ); + new URI(BASE_URI, content ); } - } catch ( URI.MalformedURIException ex ) { + } catch (URI.MalformedURIException ex) { throw new InvalidDatatypeValueException("Value '"+content+"' is a Malformed URI"); } Index: impl/dv/xs_new/MonthDV.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs_new/MonthDV.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- impl/dv/xs_new/MonthDV.java 30 Nov 2001 19:29:22 -0000 1.3 +++ impl/dv/xs_new/MonthDV.java 4 Jan 2002 19:52:38 -0000 1.4 @@ -66,7 +66,7 @@ * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: MonthDV.java,v 1.3 2001/11/30 19:29:22 sandygao Exp $ + * @version $Id: MonthDV.java,v 1.4 2002/01/04 19:52:38 sandygao Exp $ */ public class MonthDV extends AbstractDateTimeDV { @@ -96,6 +96,7 @@ */ protected int[] parse(String str, int[] date) throws SchemaDateTimeException{ + //REVISIT: change --MM-- to --MM resetBuffer(str); //create structure to hold an object @@ -136,6 +137,11 @@ /** * Overwrite compare algorithm to optimize month comparison + * + * REVISIT: this one is lack of the third parameter: boolean strict, so it + * doesn't override the method in the base. But maybe this method + * is not correctly implemented, and I did encounter errors when + * trying to add the extra parameter. I'm leaving it as is. -SG * * @param date1 * @param date2 Index: impl/dv/xs_new/SchemaDVFactoryImpl.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs_new/SchemaDVFactoryImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- impl/dv/xs_new/SchemaDVFactoryImpl.java 28 Nov 2001 17:54:52 -0000 1.2 +++ impl/dv/xs_new/SchemaDVFactoryImpl.java 4 Jan 2002 19:52:38 -0000 1.3 @@ -71,7 +71,7 @@ * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDVFactoryImpl.java,v 1.2 2001/11/28 17:54:52 sandygao Exp $ + * @version $Id: SchemaDVFactoryImpl.java,v 1.3 2002/01/04 19:52:38 sandygao Exp $ */ public class SchemaDVFactoryImpl extends SchemaDVFactory { @@ -228,23 +228,23 @@ //REVISIT: passing "anyType" here. XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType; fBuiltInTypes.put(ANYSIMPLETYPE, anySimpleType); - XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING); + XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false ); fBuiltInTypes.put(STRING, stringDV); - fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_BOOLEAN)); - XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL); + fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_FINITE, false)); + XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, true); fBuiltInTypes.put(DECIMAL, decimalDV); - fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI)); - fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY)); - fBuiltInTypes.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION)); - fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME)); - fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME)); - fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE)); - fBuiltInTypes.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH)); - fBuiltInTypes.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR)); - fBuiltInTypes.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY)); - fBuiltInTypes.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY)); - fBuiltInTypes.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH)); + fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); facets.fractionDigits = 0; XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, URI_SCHEMAFORSCHEMA, (short)0); @@ -317,10 +317,10 @@ fBuiltInTypes.put(POSITIVEINTEGER, positiveIntegerDV); - fBuiltInTypes.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT)); - fBuiltInTypes.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE)); - fBuiltInTypes.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY)); - fBuiltInTypes.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION)); + fBuiltInTypes.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_TOTAL, true, XSSimpleType.CARDINALITY_FINITE, true)); + fBuiltInTypes.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_TOTAL, true, XSSimpleType.CARDINALITY_FINITE, true)); + fBuiltInTypes.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); + fBuiltInTypes.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); facets.whiteSpace = XSSimpleType.WS_REPLACE; @@ -350,10 +350,10 @@ ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_TOKEN_NCNAME); fBuiltInTypes.put(NCNAME, ncnameDV); - fBuiltInTypes.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME)); + fBuiltInTypes.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false)); - fBuiltInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID , XSSimpleTypeDecl.DV_ID )); - XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF); + fBuiltInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false )); + XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false); fBuiltInTypes.put(IDREF, idrefDV); facets.minLength = 1; @@ -362,7 +362,7 @@ idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0); fBuiltInTypes.put(IDREFS, idrefsDV); - XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY); + XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false); fBuiltInTypes.put(ENTITY, entityDV); facets.minLength = 1; Index: impl/dv/xs_new/XSSimpleTypeDecl.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/dv/xs_new/XSSimpleTypeDecl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- impl/dv/xs_new/XSSimpleTypeDecl.java 30 Nov 2001 19:29:22 -0000 1.3 +++ impl/dv/xs_new/XSSimpleTypeDecl.java 4 Jan 2002 19:52:38 -0000 1.4 @@ -77,7 +77,7 @@ * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. * - * @version $Id: XSSimpleTypeDecl.java,v 1.3 2001/11/30 19:29:22 sandygao Exp $ + * @version $Id: XSSimpleTypeDecl.java,v 1.4 2002/01/04 19:52:38 sandygao Exp $ */ class XSSimpleTypeDecl implements XSAtomicSimpleType, XSListSimpleType, XSUnionSimpleType { @@ -148,7 +148,6 @@ "preserve", "collapse", "replace", }; - //private short fPrimitiveDV = -1; private XSSimpleTypeDecl fItemType; private XSSimpleTypeDecl[] fMemberTypes; @@ -162,13 +161,13 @@ private short fFacetsDefined = 0; private short fFixedFacet = 0; + //for constraining facets private short fWhiteSpace = 0; private int fLength = -1; private int fMinLength = -1; private int fMaxLength = -1; private int fTotalDigits = -1; private int fFractionDigits = -1; - private short fTokenType = SPECIAL_TOKEN_NONE; private Vector fPattern; private Vector fEnumeration; private Object fMaxInclusive; @@ -176,17 +175,24 @@ private Object fMinExclusive; private Object fMinInclusive; + private short fTokenType = SPECIAL_TOKEN_NONE; + + // for fundamental facets + private short fOrdered; + private short fCardinality; + private boolean fBounded; + private boolean fNumeric; + private ValidatedInfo fTempInfo = new ValidatedInfo(); //Create a new built-in primitive types (and id/idref/entity) - protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV) { + protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV, + short ordered, boolean bounded, + short cardinality, boolean numeric) { fBase = base; fTypeName = name; fTargetNamespace = SchemaDVFactoryImpl.URI_SCHEMAFORSCHEMA; fVariety = VARIETY_ATOMIC; - //fPrimitiveDV = validateDV; - //if (validateDV == DV_ID || validateDV == DV_IDREF || validateDV == DV_ENTITY) - // fPrimitiveDV = DV_STRING; fValidationDV = validateDV; fFacetsDefined = FACET_WHITESPACE; if (validateDV == DV_STRING) { @@ -208,7 +214,6 @@ fValidationDV = fBase.fValidationDV; switch (fVariety) { case VARIETY_ATOMIC: - //fPrimitiveDV = fBase.fPrimitiveDV; break; case VARIETY_LIST: fItemType = fBase.fItemType; @@ -235,6 +240,9 @@ fTokenType = fBase.fTokenType; fFixedFacet = fBase.fFixedFacet; fFacetsDefined = fBase.fFacetsDefined; + + //we also set fundamental facets information in case applyFacets is not called. + caclFundamentalFacets(); } //Create a new simple type for list. @@ -250,6 +258,9 @@ fFacetsDefined = FACET_WHITESPACE; fFixedFacet = FACET_WHITESPACE; fWhiteSpace = WS_COLLAPSE; + + //setting fundamental facets + caclFundamentalFacets(); } //Create a new simple type for union. @@ -268,6 +279,9 @@ // if fFacetsDefined != 0 fFacetsDefined = FACET_WHITESPACE; fWhiteSpace = WS_COLLAPSE; + + //setting fundamental facets + caclFundamentalFacets(); } public short getXSType () { @@ -1009,9 +1023,10 @@ // step 5: mark fixed values fFixedFacet |= fBase.fFixedFacet; - //inherit baseBuiltInTypeName. + //step 6: setting fundamental facets + caclFundamentalFacets(); - } //init4Restriction() + } //applyFacets() /** * validate a value, and return the compiled form @@ -1273,7 +1288,7 @@ regex = (RegularExpression)fPattern.elementAt(idx); if (!regex.matches(nvalue)){ throw new InvalidDatatypeValueException("Value '"+content+ - "' does not match regular expression facet '" + fPattern + "'" ); + "' does not match regular expression facet '" + regex + "'" ); } } } @@ -1442,6 +1457,204 @@ } } - static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE); + public short getOrderedFacet() { + return fOrdered; + } + + public boolean isBounded(){ + return fBounded; + } + + public short getCardinalityFacet(){ + return fCardinality; + } + + public boolean isNumeric(){ + return fNumeric; + } + + private void caclFundamentalFacets() { + setOrdered(); + setNumeric(); + setBounded(); + setCardinality(); + } + + private void setOrdered(){ + + // When {variety} is atomic, {value} is inherited from {value} of {base type definition}. For all ·primitive· types {value} is as specified in the table in Fundamental Facets (C.1). + if(fVariety == VARIETY_ATOMIC){ + this.fOrdered = fBase.fOrdered; + } + + // When {variety} is list, {value} is false. + else if(fVariety == VARIETY_LIST){ + this.fOrdered = ORDERED_FALSE; + } + + // When {variety} is union, the {value} is partial unless one of the following: + // 1. If every member of {member type definitions} is derived from a common ancestor other than the simple ur-type, then {value} is the same as that ancestor's ordered facet. + // 2. If every member of {member type definitions} has a {value} of false for the ordered facet, then {value} is false. + else if(fVariety == VARIETY_UNION){ + int length = fMemberTypes.length; + // REVISIT: is the length possible to be 0? + if (length == 0) { + this.fOrdered = ORDERED_PARTIAL; + return; + } + // we need to process the first member type before entering the loop + short ancestorId = getPrimitiveDV(fMemberTypes[0].fValidationDV); + boolean commonAnc = ancestorId != DV_ANYSIMPLETYPE; + boolean allFalse = fMemberTypes[0].fOrdered == ORDERED_FALSE; + // for the other member types, check whether the value is false + // and whether they have the same ancestor as the first one + for (int i = 1; i < fMemberTypes.length && (commonAnc || allFalse); i++) { + if (commonAnc) + commonAnc = ancestorId == getPrimitiveDV(fMemberTypes[i].fValidationDV); + if (allFalse) + allFalse = fMemberTypes[i].fOrdered == ORDERED_FALSE; + } + if (commonAnc) { + // REVISIT: all member types should have the same ordered value + // just use the first one. Can we assume this? + this.fOrdered = fMemberTypes[0].fOrdered; + } else if (allFalse) { + this.fOrdered = ORDERED_FALSE; + } else { + this.fOrdered = ORDERED_PARTIAL; + } + } + + }//setOrdered + + private void setNumeric(){ + if(fVariety == VARIETY_ATOMIC){ + this.fNumeric = fBase.fNumeric; + } + else if(fVariety == VARIETY_LIST){ + this.fNumeric = false; + } + else if(fVariety == VARIETY_UNION){ + XSSimpleType [] memberTypes = this.getMemberTypes(); + for(int i = 0 ; i < memberTypes.length ; i++){ + if( ! memberTypes[i].isNumeric() ){ + this.fNumeric = false; + return; + } + } + this.fNumeric = true; + } + + }//setNumeric + + private void setBounded(){ + if(fVariety == VARIETY_ATOMIC){ + if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0) || ((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) + && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) || ((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) ){ + this.fBounded = true; + } + else{ + this.fBounded = false; + } + } + else if(fVariety == VARIETY_LIST){ + if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ( ((this.fFacetsDefined & FACET_MINLENGTH) != 0 ) + && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){ + this.fBounded = true; + } + else{ + this.fBounded = false; + } + + } + else if(fVariety == VARIETY_UNION){ + + XSSimpleTypeDecl [] memberTypes = this.fMemberTypes; + short ancestorId = 0 ; + + if(memberTypes.length > 0){ + ancestorId = getPrimitiveDV(memberTypes[0].fValidationDV); + } + + for(int i = 0 ; i < memberTypes.length ; i++){ + if( ! memberTypes[i].isBounded() || (ancestorId != getPrimitiveDV(memberTypes[i].fValidationDV)) ){ + this.fBounded = false; + return; + } + } + this.fBounded = true; + } + + }//setBounded + + private boolean specialCardinalityCheck(){ + if( (fBase.fValidationDV == XSSimpleTypeDecl.DV_DATE) || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GYEARMONTH) + || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GYEAR) || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GMONTHDAY) + || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GDAY) || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GMONTH) ){ + return true; + } + return false; + + } //specialCardinalityCheck() + + private void setCardinality(){ + if(fVariety == VARIETY_ATOMIC){ + if(fBase.fCardinality == CARDINALITY_FINITE){ + this.fCardinality = CARDINALITY_FINITE; + } + else {// (fBase.fCardinality == CARDINALITY_COUNTABLY_INFINITE) + if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 ) + || ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){ + this.fCardinality = CARDINALITY_FINITE; + } + else if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0 ) || ((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0 )) + && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) || ((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 )) ){ + if( ((this.fFacetsDefined & FACET_FRACTIONDIGITS) != 0 ) || specialCardinalityCheck()){ + this.fCardinality = CARDINALITY_FINITE; + } + else{ + this.fCardinality = CARDINALITY_COUNTABLY_INFINITE; + } + } + else{ + this.fCardinality = CARDINALITY_COUNTABLY_INFINITE; + } + } + } + else if(fVariety == VARIETY_LIST){ + if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ( ((this.fFacetsDefined & FACET_MINLENGTH) != 0 ) + && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){ + this.fCardinality = CARDINALITY_FINITE; + } + else{ + this.fCardinality = CARDINALITY_COUNTABLY_INFINITE; + } + + } + else if(fVariety == VARIETY_UNION){ + XSSimpleType [] memberTypes = this.getMemberTypes(); + for(int i = 0 ; i < memberTypes.length ; i++){ + if( ! (memberTypes[i].getCardinalityFacet() == CARDINALITY_FINITE) ){ + this.fCardinality = CARDINALITY_COUNTABLY_INFINITE; + return; + } + } + this.fCardinality = CARDINALITY_FINITE; + } + + }//setCardinality + + private short getPrimitiveDV(short validationDV){ + + if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){ + return DV_STRING; + } + else{ + return validationDV; + } + + }//getPrimitiveDV() + + static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, CARDINALITY_FINITE, false); } // class XSComplexTypeDecl Index: impl/msg/XMLMessages.properties =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLMessages.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- impl/msg/XMLMessages.properties 18 Oct 2001 04:42:40 -0000 1.4 +++ impl/msg/XMLMessages.properties 4 Jan 2002 23:27:49 -0000 1.5 @@ -111,6 +111,7 @@ PINotInOneEntity = The processing instruction must be entirely contained within the same parsed entity. # 4.3.3 Character Encoding in Entities EncodingDeclInvalid = Invalid encoding name \"{0}\". + EncodingByteOrderUnsupported = Given byte order for encoding \"{0}\" is not supported. # DTD Messages # 2.2 Characters Index: impl/msg/XMLSchemaMessages.properties =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties,v retrieving revision 1.32 retrieving revision 1.34 diff -u -b -r1.32 -r1.34 --- impl/msg/XMLSchemaMessages.properties 2 Dec 2001 01:43:28 -0000 1.32 +++ impl/msg/XMLSchemaMessages.properties 7 Jan 2002 19:03:16 -0000 1.34 @@ -193,6 +193,7 @@ src-redefine.6.1.1 = src-redefine.6.1.1: if a group child of a element contains a group ref'ing itself, it must have exactly 1; this one has ''{0}''. src-redefine.6.1.2 = src-redefine.6.1.2: the group ''{0}'' which contains a reference to a group being redefined must have minOccurs = maxOccurs = 1. src-redefine.6.2.1 = src-redefine.6.2.1: no group in the redefined schema with a name matching ''{0}''. + src-redefine.6.2.2 = src-redefine.6.2.2: group ''{0}'' does not properly restrict the group it redefines; constraint violated: ''{1}''. src-redefine.7.1 = src-redefine.7.1: if an attributeGroup child of a element contains an attributeGroup ref'ing itself, it must have exactly 1; this one has ''{0}''. src-redefine.7.2.1 = src-redefine.7.2.1: no attributeGroup in the redefined schema with a name matching ''{0}''. src-redefine.7.2.2 = src-redefine.7.2.2: attributeGroup ''{0}'' does not properly restrict the attributeGroup it redefines; constraint violated: ''{1}''. @@ -320,7 +321,12 @@ rcase-RecurseUnordered.2 = rcase-RecurseUnordered.2: There is not a complete functional mapping between the particles. sch-props-correct.1 = sch-props-correct.1: schema components of type ''{0}'' cannot occur after declarations or are not permitted as children of a element. sch-props-correct.2 = sch-props-correct.2: a schema cannot contain two global components with the same name; this one contains two occurrences of ''{0}''. - st-props-correct = st-props-correct: error. + st-props-correct.1 = st-props-correct.1: error. + st-props-correct.2 = st-props-correct.2: circular definitions detected for type ''{0}''. + st-props-correct.3 = st-props-correct.3: {final} of the {base type definition} contains restriction. + st-props-correct.4.1 = st-props-correct.4.1: The type definition is not a valid restriction with repect to the base type ''{0}''. + st-props-correct.4.2.1 = st-props-correct.4.2.1: {final} of the {base type definition} contains list. + st-props-correct.4.2.2 = st-props-correct.4.2.2: {final} of the {base type definition} contains union. totalDigits-valid-restriction = totalDigits-valid-restriction: error. whiteSpace-valid-restriction = whiteSpace-valid-restriction: error. w-props-correct = w-props-correct: error. Index: impl/xs/SchemaGrammar.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v retrieving revision 1.6 retrieving revision 1.8 diff -u -b -r1.6 -r1.8 --- impl/xs/SchemaGrammar.java 6 Dec 2001 21:49:36 -0000 1.6 +++ impl/xs/SchemaGrammar.java 7 Jan 2002 20:02:59 -0000 1.8 @@ -79,7 +79,7 @@ * @author Sandy Gao, IBM * @author Elena Litani, IBM * - * @version $Id: SchemaGrammar.java,v 1.6 2001/12/06 21:49:36 neilg Exp $ + * @version $Id: SchemaGrammar.java,v 1.8 2002/01/07 20:02:59 neilg Exp $ */ public class SchemaGrammar extends Grammar { @@ -280,6 +280,12 @@ private int fCTCount = 0; private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE]; + // an array to store groups being redefined by restriction + // even-numbered elements are the derived groups, odd-numbered ones their bases + private static final int REDEFINED_GROUP_INIT_SIZE = 2; + private int fRGCount = 0; + private XSGroupDecl[] fRedefinedGroupDecls = new XSGroupDecl[REDEFINED_GROUP_INIT_SIZE]; + // a flag to indicate whether we have checked the 3 constraints on this // grammar. boolean fFullChecked = false; @@ -294,6 +300,17 @@ } /** + * add a group redefined by restriction: for later constraint checking + */ + public final void addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base) { + if (fRGCount == fRedefinedGroupDecls.length) + // double array size each time. + fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount << 1); + fRedefinedGroupDecls[fRGCount++] = derived; + fRedefinedGroupDecls[fRGCount++] = base; + } + + /** * get all complex type decls: for later constraint checking */ final XSComplexTypeDecl[] getUncheckedComplexTypeDecls() { @@ -303,6 +320,16 @@ } /** + * get all redefined groups: for later constraint checking + */ + final XSGroupDecl[] getRedefinedGroupDecls() { + if (fRGCount < fRedefinedGroupDecls.length) + fRedefinedGroupDecls = resize(fRedefinedGroupDecls, fRGCount); + return fRedefinedGroupDecls; + } + + + /** * after the first-round checking, some types don't need to be checked * against UPA again. here we trim the array to the proper size. */ @@ -352,6 +379,12 @@ static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) { XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize]; + System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); + return newArray; + } + + static final XSGroupDecl[] resize(XSGroupDecl[] oldArray, int newSize) { + XSGroupDecl[] newArray = new XSGroupDecl[newSize]; System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize)); return newArray; } Index: impl/xs/XSConstraints.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -b -r1.12 -r1.13 --- impl/xs/XSConstraints.java 5 Dec 2001 16:36:42 -0000 1.12 +++ impl/xs/XSConstraints.java 7 Jan 2002 19:03:17 -0000 1.13 @@ -73,7 +73,7 @@ * * @author Sandy Gao, IBM * - * @version $Id: XSConstraints.java,v 1.12 2001/12/05 16:36:42 lmartin Exp $ + * @version $Id: XSConstraints.java,v 1.13 2002/01/07 19:03:17 neilg Exp $ */ public class XSConstraints { @@ -316,6 +316,41 @@ SchemaGrammar[] grammars = grammarResolver.getGrammars(); for (int i = grammars.length-1; i >= 0; i--) { SGHandler.addSubstitutionGroup(grammars[i].getSubstitutionGroups()); + } + + // before worrying about complexTypes, let's get + // groups redefined by restriction out of the way. + for (int g = grammars.length-1; g >= 0; g--) { + XSGroupDecl [] redefinedGroups = grammars[g].getRedefinedGroupDecls(); + for(int i=0; i element information item * * @author Sandy Gao, IBM - * @version $Id: XSGroupDecl.java,v 1.1 2001/10/25 20:36:02 elena Exp $ + * @version $Id: XSGroupDecl.java,v 1.2 2002/01/07 20:02:59 neilg Exp $ */ public class XSGroupDecl { @@ -73,4 +73,4 @@ // particle of the group public XSParticleDecl fParticle = null; -} // class XSWildcardDecl +} // class XSGroupDecl Index: impl/xs/traversers/XSDElementTraverser.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- impl/xs/traversers/XSDElementTraverser.java 14 Dec 2001 20:04:16 -0000 1.9 +++ impl/xs/traversers/XSDElementTraverser.java 20 Dec 2001 16:45:51 -0000 1.10 @@ -98,7 +98,7 @@ * * @author Sandy Gao, IBM * - * @version $Id: XSDElementTraverser.java,v 1.9 2001/12/14 20:04:16 sandygao Exp $ + * @version $Id: XSDElementTraverser.java,v 1.10 2001/12/20 16:45:51 sandygao Exp $ */ class XSDElementTraverser extends XSDAbstractTraverser { @@ -359,6 +359,9 @@ if (childName.equals(SchemaSymbols.ELT_KEY) || childName.equals(SchemaSymbols.ELT_UNIQUE)) { + // need to set / to hidden before traversing it, + // because it has global scope + DOMUtil.setHidden(child); fSchemaHandler.fUniqueOrKeyTraverser.traverse(child, element, schemaDoc, grammar); if(DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME).length() != 0 ) { fSchemaHandler.checkForDuplicateNames( Index: impl/xs/traversers/XSDGroupTraverser.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- impl/xs/traversers/XSDGroupTraverser.java 25 Oct 2001 20:36:04 -0000 1.1 +++ impl/xs/traversers/XSDGroupTraverser.java 7 Jan 2002 19:03:17 -0000 1.2 @@ -78,7 +78,7 @@ * @author Rahul Srivastava, Sun Microsystems Inc. * @author Elena Litani, IBM * @author Lisa Martin, IBM - * @version $Id: XSDGroupTraverser.java,v 1.1 2001/10/25 20:36:04 elena Exp $ + * @version $Id: XSDGroupTraverser.java,v 1.2 2002/01/07 19:03:17 neilg Exp $ */ class XSDGroupTraverser extends XSDAbstractParticleTraverser { @@ -205,6 +205,17 @@ group.fTargetNamespace = schemaDoc.fTargetNamespace; group.fParticle = particle; grammar.addGlobalGroupDecl(group); + } + } + if(group != null) { + // store groups redefined by restriction in the grammar so + // that we can get at them at full-schema-checking time. + Object redefinedGrp = fSchemaHandler.getGrpOrAttrGrpRedefinedByRestriction(XSDHandler.GROUP_TYPE, + new QName(fSchemaHandler.EMPTY_STRING, strNameAttr, strNameAttr, schemaDoc.fTargetNamespace), + schemaDoc); + if(redefinedGrp != null) { + // store in grammar + grammar.addRedefinedGroupDecl(group, (XSGroupDecl)redefinedGrp); } } Index: impl/xs/traversers/XSDHandler.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v retrieving revision 1.7 retrieving revision 1.10 diff -u -b -r1.7 -r1.10 --- impl/xs/traversers/XSDHandler.java 10 Dec 2001 23:30:16 -0000 1.7 +++ impl/xs/traversers/XSDHandler.java 7 Jan 2002 20:02:37 -0000 1.10 @@ -97,7 +97,7 @@ * schema, other grammars may be constructed as a side-effect. * * @author Neil Graham, IBM - * @version $Id: XSDHandler.java,v 1.7 2001/12/10 23:30:16 sandygao Exp $ + * @version $Id: XSDHandler.java,v 1.10 2002/01/07 20:02:37 neilg Exp $ */ public class XSDHandler { @@ -344,7 +344,7 @@ String schemaHint) { // first phase: construct trees. - Document schemaRoot = getSchema(schemaNamespace, schemaHint, null, true); + Document schemaRoot = getSchema(schemaNamespace, schemaHint, null, true, true); if (schemaRoot == null) { // something went wrong right off the hop reportGenericSchemaError("Could not locate a schema document corresponding to grammar " + schemaNamespace); @@ -443,7 +443,7 @@ fAttributeChecker.returnAttrArray(includeAttrs, currSchemaInfo); // consciously throw away whether was a duplicate; don't care. // pass the systemId of the current document as the base systemId - newSchemaRoot = getSchema(schemaNamespace, schemaHint, (String)fDoc2SystemId.get(schemaRoot), true); + newSchemaRoot = getSchema(schemaNamespace, schemaHint, (String)fDoc2SystemId.get(schemaRoot), false, true); } else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) || (localName.equals(SchemaSymbols.ELT_REDEFINE))) { @@ -457,7 +457,11 @@ if (schemaHint == null) reportGenericSchemaError("schemaLocation attribute must appear in and "); // pass the systemId of the current document as the base systemId - newSchemaRoot = getSchema(null, schemaHint, (String)fDoc2SystemId.get(schemaRoot), false); + boolean mustResolve = false; + if(localName.equals(SchemaSymbols.ELT_REDEFINE)) { + mustResolve = nonAnnotationContent(child); + } + newSchemaRoot = getSchema(null, schemaHint, (String)fDoc2SystemId.get(schemaRoot), mustResolve, false); schemaNamespace = currSchemaInfo.fTargetNamespace; } else { @@ -966,6 +970,9 @@ keyrefSchemaDoc.fNamespaceSupport.makeGlobal(); keyrefSchemaDoc.fNamespaceSupport.setEffectiveContext( fKeyrefNamespaceContext[i] ); SchemaGrammar keyrefGrammar = fGrammarResolver.getGrammar(keyrefSchemaDoc.fTargetNamespace); + // need to set to hidden before traversing it, + // because it has global scope + DOMUtil.setHidden(fKeyrefs[i]); fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar); } } // end resolveKeyRefs @@ -1012,7 +1019,7 @@ // otherwise. schemaDoc is null if and only if no schema document // was resolved to. private Document getSchema(String schemaNamespace, String schemaHint, - String baseSystemId, boolean useProperties) { + String baseSystemId, boolean mustResolve, boolean useProperties) { // contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc. XMLInputSource schemaSource=null; Document schemaDoc = null; @@ -1061,6 +1068,12 @@ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "General", new Object[]{"file not found: " + schemaHint}, + // when using namespace, then hint is optional, + // and it's not an error if the file is not found + // but if not using namespace (include), + // it's a warning if the file is not found. + mustResolve ? + XMLErrorReporter.SEVERITY_ERROR: XMLErrorReporter.SEVERITY_WARNING); } catch (IOException ex) { @@ -1071,7 +1084,7 @@ schemaDoc = null; fLastSchemaWasDuplicate = false; return null; - } // getSchema(String, String): Document + } // getSchema(String, String, String, boolean, boolean): Document // initialize all the traversers. // this should only need to be called once during the construction @@ -1550,6 +1563,14 @@ return null; **********/ } // findXSDocumentForDecl(XSDocumentInfo, Element): XSDocumentInfo + + // returns whether more than s occur in children of elem + private boolean nonAnnotationContent(Element elem) { + for(Element child = DOMUtil.getFirstChildElement(elem); child != null; child = DOMUtil.getNextSiblingElement(child)) { + if(!(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION))) return true; + } + return false; + } // nonAnnotationContent(Element): boolean private void setSchemasVisible(XSDocumentInfo startSchema) { if (DOMUtil.isHidden(startSchema.fSchemaDoc)) { Index: impl/xs/traversers/XSDSimpleTypeTraverser.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- impl/xs/traversers/XSDSimpleTypeTraverser.java 14 Dec 2001 20:04:16 -0000 1.5 +++ impl/xs/traversers/XSDSimpleTypeTraverser.java 3 Jan 2002 20:59:43 -0000 1.6 @@ -65,6 +65,7 @@ import org.apache.xerces.impl.XMLErrorReporter; import org.apache.xerces.impl.xs.SchemaGrammar; import org.apache.xerces.impl.xs.SchemaSymbols; +import org.apache.xerces.impl.xs.XSTypeDecl; import org.apache.xerces.util.DOMUtil; import org.apache.xerces.impl.xs.util.XInt; @@ -115,7 +116,7 @@ * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems, Inc. - * @version $Id: XSDSimpleTypeTraverser.java,v 1.5 2001/12/14 20:04:16 sandygao Exp $ + * @version $Id: XSDSimpleTypeTraverser.java,v 1.6 2002/01/03 20:59:43 sandygao Exp $ */ class XSDSimpleTypeTraverser extends XSDAbstractTraverser { @@ -297,13 +298,13 @@ if (baseValidator == null) { Object[] args = {content.getAttribute( SchemaSymbols.ATT_BASE )}; reportSchemaError("dt-unknown-basetype", args); - return (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); + return SchemaGrammar.fAnySimpleType; } } else { Object[] args = { simpleTypeDecl.getAttribute( SchemaSymbols.ATT_NAME )}; reportSchemaError("dt-simpleType",new Object[]{SchemaSymbols.ELT_SIMPLETYPE, nameProperty, "(annotation?, (restriction | list | union))"}); - return (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); + return SchemaGrammar.fAnySimpleType; } } else { @@ -328,7 +329,7 @@ if (baseValidator == null) { Object[] args = { content.getAttribute( SchemaSymbols.ATT_BASE ), nameProperty}; reportSchemaError("dt-unknown-basetype", args); - baseValidator = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); + baseValidator = SchemaGrammar.fAnySimpleType; } // ------------------------------ // (variety is list)cos-list-of-atomic @@ -417,7 +418,7 @@ if (baseValidator == null) { Object[] args = { content.getAttribute( SchemaSymbols.ATT_BASE ), nameProperty}; reportSchemaError("dt-unknown-basetype", args); - baseValidator = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); + baseValidator = SchemaGrammar.fAnySimpleType; } content = DOMUtil.getNextSiblingElement( content ); } @@ -520,20 +521,23 @@ (baseTypeStr.localpart.equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE) || baseTypeStr.localpart.equals(SchemaSymbols.ATTVAL_ANYTYPE)) && baseRefContext == SchemaSymbols.RESTRICTION) { - String base = baseTypeStr.localpart; reportSchemaError("dt-unknown-basetype", new Object[] { DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_NAME), DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_BASE)}); - return (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE); + return SchemaGrammar.fAnySimpleType; } - XSSimpleType baseType = null; - baseType = (XSSimpleType)fSchemaHandler.getGlobalDecl(schemaDoc, fSchemaHandler.TYPEDECL_TYPE, baseTypeStr); + XSTypeDecl baseType = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, fSchemaHandler.TYPEDECL_TYPE, baseTypeStr); if (baseType != null) { + if (baseType.getXSType() != XSTypeDecl.SIMPLE_TYPE) { + reportSchemaError("st-props-correct.4.1", new Object[] { baseTypeStr.rawname} ); + return SchemaGrammar.fAnySimpleType; + } if ((baseType.getFinalSet() & baseRefContext) != 0) { - reportSchemaError("dt-restiction-final",new Object[] { baseTypeStr.rawname} ); + reportSchemaError("dt-restiction-final", new Object[] { baseTypeStr.rawname} ); } } - return baseType; + + return (XSSimpleType)baseType; } // find if union datatype validator has list datatype member. Index: parsers/AbstractDOMParser.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java,v retrieving revision 1.22 retrieving revision 1.24 diff -u -b -r1.22 -r1.24 --- parsers/AbstractDOMParser.java 17 Dec 2001 19:03:21 -0000 1.22 +++ parsers/AbstractDOMParser.java 22 Dec 2001 23:25:49 -0000 1.24 @@ -102,7 +102,7 @@ * @author Andy Clark, IBM * @author Elena Litani, IBM * - * @version $Id: AbstractDOMParser.java,v 1.22 2001/12/17 19:03:21 lehors Exp $ + * @version $Id: AbstractDOMParser.java,v 1.24 2001/12/22 23:25:49 andyc Exp $ */ public abstract class AbstractDOMParser extends AbstractXMLDocumentParser { @@ -189,6 +189,10 @@ protected Node fCurrentNode; protected CDATASection fCurrentCDATASection; + // internal subset + + /** Internal subset buffer. */ + protected StringBuffer fInternalSubset; // deferred expansion data @@ -202,6 +206,9 @@ // state + /** True if inside DTD external subset. */ + protected boolean fInDTDExternalSubset; + /** True if inside document. */ protected boolean fInDocument; @@ -352,6 +359,7 @@ // reset state information fInDocument = false; fInDTD = false; + fInDTDExternalSubset = false; fInCDATASection = false; fCurrentCDATASection = null; fCurrentCDATASectionIndex = -1; @@ -420,10 +428,11 @@ * * @param version The XML version, or null if not specified. * @param encoding The IANA encoding name of the entity. + * @param augs Additional information that may include infoset augmentations * * @throws XNIException Thrown by handler to signal an error. */ - public void textDecl(String version, String encoding) throws XNIException { + public void textDecl(String version, String encoding, Augmentations augs) throws XNIException { if (!fDeferNodeExpansion) { // REVISIT: when DOM Level 3 is REC rely on Document.support // instead of specific class @@ -593,10 +602,12 @@ * @param encoding The IANA encoding name of the document, or null if * not specified. * @param standalone The standalone value, or null if not specified. + * @param augs Additional information that may include infoset augmentations * * @throws XNIException Thrown by handler to signal an error. */ - public void xmlDecl(String version, String encoding, String standalone) + public void xmlDecl(String version, String encoding, String standalone, + Augmentations augs) throws XNIException { if (!fDeferNodeExpansion) { // REVISIT: when DOM Level 3 is REC rely on Document.support @@ -999,6 +1010,82 @@ // /** + * The start of the DTD. + * + * @throws XNIException Thrown by handler to signal an error. + */ + public void startDTD(XMLLocator locator) throws XNIException { + super.startDTD(locator); + if (fDeferNodeExpansion || fDocumentImpl != null) { + fInternalSubset = new StringBuffer(1024); + } + } // startDTD(XMLLocator) + + /** + * The end of the DTD. + * + * @throws XNIException Thrown by handler to signal an error. + */ + public void endDTD() throws XNIException { + super.endDTD(); + String internalSubset = fInternalSubset != null && fInternalSubset.length() > 0 + ? fInternalSubset.toString() : null; + if (fDeferNodeExpansion) { + if (internalSubset != null) { + fDeferredDocumentImpl.setInternalSubset(fDocumentTypeIndex, internalSubset); + } + } + else if (fDocumentImpl != null) { + if (internalSubset != null) { + ((DocumentTypeImpl)fDocumentType).setInternalSubset(internalSubset); + } + } + } // endDTD() + + /** + * This method notifies of the start of an entity. The DTD has the + * pseudo-name of "[dtd]" and parameter entity names start with '%'. + *

+ * + * @param name The name of the entity. + * @param publicId The public identifier of the entity if the entity + * is external, null otherwise. + * @param systemId The system identifier of the entity if the entity + * is external, null otherwise. + * @param baseSystemId The base system identifier of the entity if + * the entity is external, null otherwise. + * @param encoding The auto-detected IANA encoding name of the entity + * stream. This value will be null in those situations + * where the entity encoding is not auto-detected (e.g. + * internal parameter entities). + * + * @throws XNIException Thrown by handler to signal an error. + */ + public void startEntity(String name, + String publicId, String systemId, + String baseSystemId, + String encoding) throws XNIException { + if (name.equals("[dtd]")) { + fInDTDExternalSubset = true; + } + } // startEntity(String,String,String,String,String) + + /** + * This method notifies the end of an entity. The DTD has the pseudo-name + * of "[dtd]" and parameter entity names start with '%'. + *

+ * + * @param name The name of the entity. + * + * @throws XNIException Thrown by handler to signal an error. + */ + public void endEntity(String name) throws XNIException { + if (name.equals("[dtd]")) { + fInDTDExternalSubset = false; + } + } // endEntity(String) + + /** * An internal entity declaration. * * @param name The name of the entity. Parameter entity names start with @@ -1016,6 +1103,25 @@ XMLString nonNormalizedText) throws XNIException { + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append("\n"); + } + // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac @@ -1075,6 +1181,29 @@ String publicId, String systemId, String baseSystemId) throws XNIException { + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append("\n"); + } + // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac @@ -1134,6 +1263,28 @@ String publicId, String systemId, String notation) throws XNIException { + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append("\n"); + } + // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac @@ -1189,6 +1340,24 @@ public void notationDecl(String name, String publicId, String systemId) throws XNIException { + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append("\n"); + } + // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac @@ -1229,6 +1398,28 @@ } // notationDecl(String,String,String) /** + * An element declaration. + * + * @param name The name of the element. + * @param contentModel The element content model. + * + * @throws XNIException Thrown by handler to signal an error. + */ + public void elementDecl(String name, String contentModel) + throws XNIException { + + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append("\n"); + } + + } // elementDecl(String,String) + + /** * An attribute declaration. * * @param elementName The name of the element that this attribute @@ -1253,6 +1444,46 @@ String type, String[] enumeration, String defaultType, XMLString defaultValue) throws XNIException { + + // internal subset string + if (fInternalSubset != null && !fInDTDExternalSubset) { + fInternalSubset.append(" 0) { + fInternalSubset.append('|'); + } + fInternalSubset.append(enumeration[i]); + } + fInternalSubset.append(')'); + } + else { + fInternalSubset.append(type); + } + if (defaultType != null) { + fInternalSubset.append(' '); + fInternalSubset.append(defaultType); + } + if (defaultValue != null) { + fInternalSubset.append(" '"); + for (int i = 0; i < defaultValue.length; i++) { + char c = defaultValue.ch[defaultValue.offset + i]; + if (c == '\'') { + fInternalSubset.append("'"); + } + else { + fInternalSubset.append(c); + } + } + fInternalSubset.append('\''); + } + fInternalSubset.append(">\n"); + } // deferred expansion if (fDeferredDocumentImpl != null) { Index: parsers/AbstractSAXParser.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/parsers/AbstractSAXParser.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- parsers/AbstractSAXParser.java 14 Dec 2001 20:49:16 -0000 1.10 +++ parsers/AbstractSAXParser.java 20 Dec 2001 13:44:51 -0000 1.11 @@ -110,7 +110,7 @@ * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: AbstractSAXParser.java,v 1.10 2001/12/14 20:49:16 lmartin Exp $ + * @version $Id: AbstractSAXParser.java,v 1.11 2001/12/20 13:44:51 rahuls Exp $ */ public abstract class AbstractSAXParser extends AbstractXMLDocumentParser @@ -392,15 +392,22 @@ // SAX2 if (fContentHandler != null) { - if (!fNamespacePrefixes) { - // remove namespace declaration attributes int len = attributes.getLength(); for (int i = len - 1; i >= 0; i--) { attributes.getName(i, fQName); - if (fQName.rawname == fXmlnsSymbol || - fQName.prefix == fXmlnsSymbol) { + if (fQName.prefix == fXmlnsSymbol || + fQName.rawname == fXmlnsSymbol) { + if (!fNamespacePrefixes) { + // remove namespace declaration attributes attributes.removeAttributeAt(i); } + else if (fNamespaces && fNamespacePrefixes) { + // localpart should be empty string as per SAX documentation: + // http://www.saxproject.org/?selected=namespaces + fQName.prefix = fEmptySymbol; + fQName.localpart = fEmptySymbol; + attributes.setName(i, fQName); + } } } Index: parsers/StandardParserConfiguration.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- parsers/StandardParserConfiguration.java 14 Dec 2001 20:50:21 -0000 1.10 +++ parsers/StandardParserConfiguration.java 3 Jan 2002 19:50:08 -0000 1.11 @@ -121,7 +121,7 @@ * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: StandardParserConfiguration.java,v 1.10 2001/12/14 20:50:21 lmartin Exp $ + * @version $Id: StandardParserConfiguration.java,v 1.11 2002/01/03 19:50:08 sandygao Exp $ */ public class StandardParserConfiguration extends BasicParserConfiguration @@ -773,6 +773,12 @@ if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length()); if (property.equals(Constants.DTD_SCANNER_PROPERTY)) { + return; + } + if (property.equals(Constants.SCHEMA_LOCATION)) { + return; + } + if (property.equals(Constants.SCHEMA_NONS_LOCATION)) { return; } } Index: util/EncodingMap.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/util/EncodingMap.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- util/EncodingMap.java 11 Dec 2001 21:57:38 -0000 1.3 +++ util/EncodingMap.java 4 Jan 2002 23:27:49 -0000 1.4 @@ -507,7 +507,7 @@ * @author Stubs generated by DesignDoc on Wed Jun 07 11:58:44 PDT 2000 * @author Andy Clark, IBM * - * @version $Id: EncodingMap.java,v 1.3 2001/12/11 21:57:38 neilg Exp $ + * @version $Id: EncodingMap.java,v 1.4 2002/01/04 23:27:49 neilg Exp $ */ public class EncodingMap { @@ -647,6 +647,8 @@ fIANA2JavaMap.put("CP367", "ASCII"); fIANA2JavaMap.put("UTF-8", "UTF8"); fIANA2JavaMap.put("UTF-16", "Unicode"); + fIANA2JavaMap.put("UTF-16BE", "UnicodeBig"); + fIANA2JavaMap.put("UTF-16LE", "UnicodeLittle"); // REVISIT: // j:CNS11643 -> EUC-TW? @@ -686,6 +688,8 @@ fJava2IANAMap.put("SJIS", "SHIFT_JIS"); fJava2IANAMap.put("UTF8", "UTF-8"); fJava2IANAMap.put("Unicode", "UTF-16"); + fJava2IANAMap.put("UnicodeBig", "UTF-16BE"); + fJava2IANAMap.put("UnicodeLittle", "UTF-16LE"); fJava2IANAMap.put("JIS0201", "X0201"); fJava2IANAMap.put("JIS0208", "X0208"); fJava2IANAMap.put("JIS0212", "ISO-IR-159"); Index: util/XMLAttributesImpl.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/util/XMLAttributesImpl.java,v retrieving revision 1.11 diff -u -b -r1.11 XMLAttributesImpl.java --- util/XMLAttributesImpl.java 12 Dec 2001 22:33:47 -0000 1.11 +++ util/XMLAttributesImpl.java 9 Jan 2002 13:33:53 -0000 @@ -293,7 +293,7 @@ public void setValue(int attrIndex, String attrValue) { Attribute attribute = fAttributes[attrIndex]; attribute.value = attrValue; - attribute.nonNormalizedValue = attrValue; +// attribute.nonNormalizedValue = attrValue; } // setValue(int,String) /**