# HG changeset patch
# User andrew
# Date 1317227784 -3600
# Node ID fa1d0a3d616f1c0e1b14d47a77a41e1587daf8c5
# Parent 44f4743bbd56336d1e88a0fd231ed701836278e9
7007257: jaxp 1.4.5 jdk7 1st integration
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xalan/internal/Version.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/Version.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/Version.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,10 +26,10 @@
* Administrative class to keep track of the version number of
* the Xalan release.
*
This class implements the upcoming standard of having
- * org.apache.project-name.Version.getVersion() be a standard way
- * to get version information. This class will replace the older
+ * org.apache.project-name.Version.getVersion() be a standard way
+ * to get version information. This class will replace the older
* com.sun.org.apache.xalan.internal.processor.Version class.
- * See also: com/sun/org/apache/xalan/internal/res/XSLTInfo.properties for
+ *
See also: com/sun/org/apache/xalan/internal/res/XSLTInfo.properties for
* information about the version of the XSLT spec we support.
* @xsl.usage general
*/
@@ -38,7 +38,7 @@
/**
* Get the basic version string for the current Xalan release.
- * Version String formatted like
+ * Version String formatted like
* "Xalan Java v.r[.dd| Dnn]"
.
*
* Futurework: have this read version info from jar manifest.
@@ -49,8 +49,8 @@
{
return getProduct()+" "+getImplementationLanguage()+" "
+getMajorVersionNum()+"."+getReleaseVersionNum()+"."
- +( (getDevelopmentVersionNum() > 0) ?
- ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));
+ +( (getDevelopmentVersionNum() > 0) ?
+ ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));
}
/**
@@ -62,7 +62,7 @@
{
System.out.println(getVersion());
}
-
+
/**
* Name of product: Xalan.
*/
@@ -78,8 +78,8 @@
{
return "Java";
}
-
-
+
+
/**
* Major version number.
* Version number. This changes only when there is a
@@ -94,8 +94,8 @@
public static int getMajorVersionNum()
{
return 2;
-
- }
+
+ }
/**
* Release Number.
@@ -107,9 +107,9 @@
*/
public static int getReleaseVersionNum()
{
- return 6;
+ return 7;
}
-
+
/**
* Maintenance Drop Number.
* Optional identifier used to designate maintenance
@@ -142,14 +142,14 @@
* the final releases.
*/
public static int getDevelopmentVersionNum()
- {
- try {
+ {
+ try {
if ((new String("")).length() == 0)
return 0;
- else
+ else
return Integer.parseInt("");
} catch (NumberFormatException nfe) {
return 0;
- }
- }
+ }
+ }
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java Wed Sep 28 17:36:24 2011 +0100
@@ -38,21 +38,21 @@
/**
* Utility class to report simple information about the environment.
- * Simplistic reporting about certain classes found in your JVM may
+ * Simplistic reporting about certain classes found in your JVM may
* help answer some FAQs for simple problems.
*
- * Usage-command line:
+ *
Usage-command line:
*
* java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck [-out outFile]
*
- *
- * Usage-from program:
+ *
+ *
Usage-from program:
*
- * boolean environmentOK =
+ * boolean environmentOK =
* (new EnvironmentCheck()).checkEnvironment(yourPrintWriter);
*
*
- * Usage-from stylesheet:
+ *
Usage-from stylesheet:
*
* <?xml version="1.0"?>
* <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
@@ -64,38 +64,39 @@
* </xsl:template>
* </xsl:stylesheet>
*
- *
- * Xalan users reporting problems are encouraged to use this class
- * to see if there are potential problems with their actual
- * Java environment before reporting a bug. Note that you
- * should both check from the JVM/JRE's command line as well as
- * temporarily calling checkEnvironment() directly from your code,
+ *
+ *
Xalan users reporting problems are encouraged to use this class
+ * to see if there are potential problems with their actual
+ * Java environment before reporting a bug. Note that you
+ * should both check from the JVM/JRE's command line as well as
+ * temporarily calling checkEnvironment() directly from your code,
* since the classpath may differ (especially for servlets, etc).
*
* Also see http://xml.apache.org/xalan-j/faq.html
*
- * Note: This class is pretty simplistic:
- * results are not necessarily definitive nor will it find all
- * problems related to environment setup. Also, you should avoid
- * calling this in deployed production code, both because it is
+ *
Note: This class is pretty simplistic:
+ * results are not necessarily definitive nor will it find all
+ * problems related to environment setup. Also, you should avoid
+ * calling this in deployed production code, both because it is
* quite slow and because it forces classes to get loaded.
*
- * Note: This class explicitly has very limited compile-time
- * dependencies to enable easy compilation and usage even when
+ *
Note: This class explicitly has very limited compile-time
+ * dependencies to enable easy compilation and usage even when
* Xalan, DOM/SAX/JAXP, etc. are not present.
- *
- * Note: for an improved version of this utility, please see
- * the xml-commons' project Which utility which does the same kind
+ *
+ *
Note: for an improved version of this utility, please see
+ * the xml-commons' project Which utility which does the same kind
* of thing but in a much simpler manner.
*
* @author Shane_Curcuru@us.ibm.com
+ * @version $Id: EnvironmentCheck.java,v 1.10 2010-11-01 04:34:13 joehw Exp $
*/
public class EnvironmentCheck
{
/**
* Command line runnability: checks for [-out outFilename] arg.
- * Command line entrypoint; Sets output and calls
+ *
Command line entrypoint; Sets output and calls
* {@link #checkEnvironment(PrintWriter)}.
* @param args command line args
*/
@@ -136,26 +137,26 @@
}
/**
- * Programmatic entrypoint: Report on basic Java environment
+ * Programmatic entrypoint: Report on basic Java environment
* and CLASSPATH settings that affect Xalan.
*
- * Note that this class is not advanced enough to tell you
- * everything about the environment that affects Xalan, and
- * sometimes reports errors that will not actually affect
- * Xalan's behavior. Currently, it very simplistically
- * checks the JVM's environment for some basic properties and
- * logs them out; it will report a problem if it finds a setting
+ *
Note that this class is not advanced enough to tell you
+ * everything about the environment that affects Xalan, and
+ * sometimes reports errors that will not actually affect
+ * Xalan's behavior. Currently, it very simplistically
+ * checks the JVM's environment for some basic properties and
+ * logs them out; it will report a problem if it finds a setting
* or .jar file that is likely to cause problems.
*
- * Advanced users can peruse the code herein to help them
- * investigate potential environment problems found; other users
- * may simply send the output from this tool along with any bugs
+ *
Advanced users can peruse the code herein to help them
+ * investigate potential environment problems found; other users
+ * may simply send the output from this tool along with any bugs
* they submit to help us in the debugging process.
*
- * @param pw PrintWriter to send output to; can be sent to a
- * file that will look similar to a Properties file; defaults
+ * @param pw PrintWriter to send output to; can be sent to a
+ * file that will look similar to a Properties file; defaults
* to System.out if null
- * @return true if your environment appears to have no major
+ * @return true if your environment appears to have no major
* problems; false if potential environment problems found
* @see #getEnvironmentHash()
*/
@@ -174,7 +175,7 @@
if (environmentHasErrors)
{
- // Note: many logMsg calls have # at the start to
+ // Note: many logMsg calls have # at the start to
// fake a property-file like output
logMsg("# WARNING: Potential problems found in your environment!");
logMsg("# Check any 'ERROR' items above against the Xalan FAQs");
@@ -197,20 +198,20 @@
* Fill a hash with basic environment settings that affect Xalan.
*
* Worker method called from various places.
- * Various system and CLASSPATH, etc. properties are put into
- * the hash as keys with a brief description of the current state
- * of that item as the value. Any serious problems will be put in
+ *
Various system and CLASSPATH, etc. properties are put into
+ * the hash as keys with a brief description of the current state
+ * of that item as the value. Any serious problems will be put in
* with a key that is prefixed with {@link #ERROR 'ERROR.'} so it
- * stands out in any resulting report; also a key with just that
+ * stands out in any resulting report; also a key with just that
* constant will be set as well for any error.
- * Note that some legitimate cases are flaged as potential
- * errors - namely when a developer recompiles xalan.jar on their
- * own - and even a non-error state doesn't guaruntee that
- * everything in the environment is correct. But this will help
+ *
Note that some legitimate cases are flaged as potential
+ * errors - namely when a developer recompiles xalan.jar on their
+ * own - and even a non-error state doesn't guaruntee that
+ * everything in the environment is correct. But this will help
* point out the most common classpath and system property
- * problems that we've seen.
+ * problems that we've seen.
*
- * @return Hashtable full of useful environment info about Xalan
+ * @return Hashtable full of useful environment info about Xalan
* and related system properties, etc.
*/
public Hashtable getEnvironmentHash()
@@ -219,13 +220,15 @@
Hashtable hash = new Hashtable();
// Call various worker methods to fill in the hash
- // These are explicitly separate for maintenance and so
+ // These are explicitly separate for maintenance and so
// advanced users could call them standalone
checkJAXPVersion(hash);
checkProcessorVersion(hash);
checkParserVersion(hash);
checkAntVersion(hash);
+ if (!checkDOML3(hash)) {
checkDOMVersion(hash);
+ }
checkSAXVersion(hash);
checkSystemProperties(hash);
@@ -233,15 +236,15 @@
}
/**
- * Dump a basic Xalan environment report to outWriter.
+ * Dump a basic Xalan environment report to outWriter.
*
- * This dumps a simple header and then each of the entries in
- * the Hashtable to our PrintWriter; it does special processing
+ *
This dumps a simple header and then each of the entries in
+ * the Hashtable to our PrintWriter; it does special processing
* for entries that are .jars found in the classpath.
*
* @param h Hashtable of items to report on; presumably
* filled in by our various check*() methods
- * @return true if your environment appears to have no major
+ * @return true if your environment appears to have no major
* problems; false if potential environment problems found
* @see #appendEnvironmentReport(Node, Document, Hashtable)
* for an equivalent that appends to a Node instead
@@ -258,10 +261,10 @@
boolean errors = false;
logMsg(
- "#---- BEGIN writeEnvironmentReport($Revision: 1.7 $): Useful stuff found: ----");
+ "#---- BEGIN writeEnvironmentReport($Revision: 1.10 $): Useful stuff found: ----");
// Fake the Properties-like output
- for (Enumeration keys = h.keys();
+ for (Enumeration keys = h.keys();
keys.hasMoreElements();
/* no increment portion */
)
@@ -279,8 +282,8 @@
// ..normal processing for all other entries
else
{
- // Note: we could just check for the ERROR key by itself,
- // since we now set that, but since we have to go
+ // Note: we could just check for the ERROR key by itself,
+ // since we now set that, but since we have to go
// through the whole hash anyway, do it this way,
// which is safer for maintenance
if (keyStr.startsWith(ERROR))
@@ -330,24 +333,24 @@
"serializer.jar", // Serializer (shared between Xalan & Xerces)
"xerces.jar", // Xerces-J 1.x
"xercesImpl.jar", // Xerces-J 2.x
- "testxsl.jar",
- "crimson.jar",
- "lotusxsl.jar",
- "jaxp.jar", "parser.jar", "dom.jar", "sax.jar", "xml.jar",
+ "testxsl.jar",
+ "crimson.jar",
+ "lotusxsl.jar",
+ "jaxp.jar", "parser.jar", "dom.jar", "sax.jar", "xml.jar",
"xml-apis.jar",
"xsltc.jar"
};
/**
- * Print out report of .jars found in a classpath.
+ * Print out report of .jars found in a classpath.
*
- * Takes the information encoded from a checkPathForJars()
+ * Takes the information encoded from a checkPathForJars()
* call and dumps it out to our PrintWriter.
*
* @param v Vector of Hashtables of .jar file info
* @param desc description to print out in header
*
- * @return false if OK, true if any .jars were reported
+ * @return false if OK, true if any .jars were reported
* as having errors
* @see #checkPathForJars(String, String[])
*/
@@ -365,7 +368,7 @@
{
Hashtable subhash = (Hashtable) v.elementAt(i);
- for (Enumeration keys = subhash.keys();
+ for (Enumeration keys = subhash.keys();
keys.hasMoreElements();
/* no increment portion */
)
@@ -395,10 +398,10 @@
}
/**
- * Stylesheet extension entrypoint: Dump a basic Xalan
- * environment report from getEnvironmentHash() to a Node.
- *
- * Copy of writeEnvironmentReport that creates a Node suitable
+ * Stylesheet extension entrypoint: Dump a basic Xalan
+ * environment report from getEnvironmentHash() to a Node.
+ *
+ *
Copy of writeEnvironmentReport that creates a Node suitable
* for other processing instead of a properties-like text output.
*
* @param container Node to append our report to
@@ -413,11 +416,11 @@
{
return;
}
-
+
try
{
Element envCheckNode = factory.createElement("EnvironmentCheck");
- envCheckNode.setAttribute("version", "$Revision: 1.7 $");
+ envCheckNode.setAttribute("version", "$Revision: 1.10 $");
container.appendChild(envCheckNode);
if (null == h)
@@ -433,8 +436,8 @@
Element hashNode = factory.createElement("environment");
envCheckNode.appendChild(hashNode);
-
- for (Enumeration keys = h.keys();
+
+ for (Enumeration keys = h.keys();
keys.hasMoreElements();
/* no increment portion */
)
@@ -451,10 +454,10 @@
errors |= appendFoundJars(hashNode, factory, v, keyStr);
}
// ..normal processing for all other entries
- else
+ else
{
- // Note: we could just check for the ERROR key by itself,
- // since we now set that, but since we have to go
+ // Note: we could just check for the ERROR key by itself,
+ // since we now set that, but since we have to go
// through the whole hash anyway, do it this way,
// which is safer for maintenance
if (keyStr.startsWith(ERROR))
@@ -486,12 +489,12 @@
System.err.println("appendEnvironmentReport threw: " + e2.toString());
e2.printStackTrace();
}
- }
+ }
/**
- * Print out report of .jars found in a classpath.
+ * Print out report of .jars found in a classpath.
*
- * Takes the information encoded from a checkPathForJars()
+ * Takes the information encoded from a checkPathForJars()
* call and dumps it out to our PrintWriter.
*
* @param container Node to append our report to
@@ -499,11 +502,11 @@
* @param v Vector of Hashtables of .jar file info
* @param desc description to print out in header
*
- * @return false if OK, true if any .jars were reported
+ * @return false if OK, true if any .jars were reported
* as having errors
* @see #checkPathForJars(String, String[])
*/
- protected boolean appendFoundJars(Node container, Document factory,
+ protected boolean appendFoundJars(Node container, Document factory,
Vector v, String desc)
{
@@ -516,7 +519,7 @@
{
Hashtable subhash = (Hashtable) v.elementAt(i);
- for (Enumeration keys = subhash.keys();
+ for (Enumeration keys = subhash.keys();
keys.hasMoreElements();
/* no increment portion */
)
@@ -548,12 +551,12 @@
}
/**
- * Fillin hash with info about SystemProperties.
+ * Fillin hash with info about SystemProperties.
*
- * Logs java.class.path and other likely paths; then attempts
+ * Logs java.class.path and other likely paths; then attempts
* to search those paths for .jar files with Xalan-related classes.
*
- * //@todo NOTE: We don't actually search java.ext.dirs for
+ * //@todo NOTE: We don't actually search java.ext.dirs for
* // *.jar files therein! This should be updated
*
* @param h Hashtable to put information in
@@ -610,7 +613,7 @@
h.put(FOUNDCLASSES + "sun.boot.class.path", classpathJars);
}
- //@todo NOTE: We don't actually search java.ext.dirs for
+ //@todo NOTE: We don't actually search java.ext.dirs for
// *.jar files therein! This should be updated
othercp = System.getProperty("java.ext.dirs");
@@ -638,11 +641,11 @@
}
/**
- * Cheap-o listing of specified .jars found in the classpath.
+ * Cheap-o listing of specified .jars found in the classpath.
*
- * cp should be separated by the usual File.pathSeparator. We
- * then do a simplistic search of the path for any requested
- * .jar filenames, and return a listing of their names and
+ * cp should be separated by the usual File.pathSeparator. We
+ * then do a simplistic search of the path for any requested
+ * .jar filenames, and return a listing of their names and
* where (apparently) they came from.
*
* @param cp classpath to search
@@ -679,20 +682,20 @@
if (f.exists())
{
- // If any requested jarName exists, report on
+ // If any requested jarName exists, report on
// the details of that .jar file
try
{
Hashtable h = new Hashtable(2);
// Note "-" char is looked for in appendFoundJars
h.put(jars[i] + "-path", f.getAbsolutePath());
-
+
// We won't bother reporting on the xalan.jar apparent version
// since this requires knowing the jar size of the xalan.jar
- // before we build it.
- // For other jars, eg. xml-apis.jar and xercesImpl.jar, we
+ // before we build it.
+ // For other jars, eg. xml-apis.jar and xercesImpl.jar, we
// report the apparent version of the file we've found
- if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
+ if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
h.put(jars[i] + "-apparent.version",
getApparentVersion(jars[i], f.length()));
}
@@ -708,7 +711,7 @@
{
Hashtable h = new Hashtable(2);
// Note "-" char is looked for in appendFoundJars
- h.put(jars[i] + "-path", WARNING + " Classpath entry: "
+ h.put(jars[i] + "-path", WARNING + " Classpath entry: "
+ filename + " does not exist");
h.put(jars[i] + "-apparent.version", CLASS_NOTPRESENT);
v.addElement(h);
@@ -721,12 +724,12 @@
}
/**
- * Cheap-o method to determine the product version of a .jar.
+ * Cheap-o method to determine the product version of a .jar.
*
- * Currently does a lookup into a local table of some recent
- * shipped Xalan builds to determine where the .jar probably
- * came from. Note that if you recompile Xalan or Xerces
- * yourself this will likely report a potential error, since
+ * Currently does a lookup into a local table of some recent
+ * shipped Xalan builds to determine where the .jar probably
+ * came from. Note that if you recompile Xalan or Xerces
+ * yourself this will likely report a potential error, since
* we can't certify builds other than the ones we ship.
* Only reports against selected posted Xalan-J builds.
*
@@ -735,12 +738,12 @@
* @param jarName base filename of the .jarfile
* @param jarSize size of the .jarfile
*
- * @return String describing where the .jar file probably
+ * @return String describing where the .jar file probably
* came from
*/
protected String getApparentVersion(String jarName, long jarSize)
{
- // If we found a matching size and it's for our
+ // If we found a matching size and it's for our
// jar, then return it's description
// Lookup in static jarVersions Hashtable
String foundSize = (String) jarVersions.get(new Long(jarSize));
@@ -757,7 +760,7 @@
{
// For xalan.jar and xerces.jar/xercesImpl.jar, which we ship together:
- // The jar is not from a shipped copy of xalan-j, so
+ // The jar is not from a shipped copy of xalan-j, so
// it's up to the user to ensure that it's compatible
return jarName + " " + WARNING + CLASS_PRESENT;
}
@@ -773,8 +776,8 @@
/**
* Report version information about JAXP interfaces.
*
- * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
- * and not found; only tests the interfaces, and does not
+ * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
+ * and not found; only tests the interfaces, and does not
* check for reference implementation versions.
*
* @param h Hashtable to put information in
@@ -785,42 +788,24 @@
if (null == h)
h = new Hashtable();
- final Class noArgs[] = new Class[0];
Class clazz = null;
try
{
- final String JAXP1_CLASS = "javax.xml.parsers.DocumentBuilder";
- final String JAXP11_METHOD = "getDOMImplementation";
+ final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";
clazz = ObjectFactory.findProviderClass(
JAXP1_CLASS, ObjectFactory.findClassLoader(), true);
- Method method = clazz.getMethod(JAXP11_METHOD, noArgs);
-
- // If we succeeded, we at least have JAXP 1.1 available
- h.put(VERSION + "JAXP", "1.1 or higher");
+ // If we succeeded, we have JAXP 1.4 available
+ h.put(VERSION + "JAXP", "1.4");
}
catch (Exception e)
{
- if (null != clazz)
- {
-
- // We must have found the class itself, just not the
- // method, so we (probably) have JAXP 1.0.1
- h.put(ERROR + VERSION + "JAXP", "1.0.1");
+ h.put(ERROR + VERSION + "JAXP", "1.3");
h.put(ERROR, ERROR_FOUND);
}
- else
- {
- // We couldn't even find the class, and don't have
- // any JAXP support at all, or only have the
- // transform half of it
- h.put(ERROR + VERSION + "JAXP", CLASS_NOTPRESENT);
- h.put(ERROR, ERROR_FOUND);
}
- }
- }
/**
* Report product version information from Xalan-J.
@@ -868,7 +853,7 @@
try
{
- // NOTE: This is the old Xalan 2.0, 2.1, 2.2 version class,
+ // NOTE: This is the old Xalan 2.0, 2.1, 2.2 version class,
// is being replaced by class below
final String XALAN2_VERSION_CLASS =
"com.sun.org.apache.xalan.internal.processor.XSLProcessorVersion";
@@ -1009,10 +994,42 @@
}
/**
- * Report version info from DOM interfaces.
+ * Report version info from DOM interfaces.
*
- * Currently distinguishes between pre-DOM level 2, the DOM
- * level 2 working draft, the DOM level 2 final draft,
+ * @param h Hashtable to put information in
+ */
+ protected boolean checkDOML3(Hashtable h)
+ {
+
+ if (null == h)
+ h = new Hashtable();
+
+ final String DOM_CLASS = "org.w3c.dom.Document";
+ final String DOM_LEVEL3_METHOD = "getDoctype"; // no parameter
+
+ try
+ {
+ Class clazz = ObjectFactory.findProviderClass(
+ DOM_CLASS, ObjectFactory.findClassLoader(), true);
+
+ Method method = clazz.getMethod(DOM_LEVEL3_METHOD, null);
+
+ // If we succeeded, we have loaded interfaces from a
+ // level 3 DOM somewhere
+ h.put(VERSION + "DOM", "3.0");
+ return true;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Report version info from DOM interfaces.
+ *
+ * Currently distinguishes between pre-DOM level 2, the DOM
+ * level 2 working draft, the DOM level 2 final draft,
* and not found.
*
* @param h Hashtable to put information in
@@ -1025,6 +1042,7 @@
final String DOM_LEVEL2_CLASS = "org.w3c.dom.Document";
final String DOM_LEVEL2_METHOD = "createElementNS"; // String, String
+ final String DOM_LEVEL3_METHOD = "getDoctype"; // no parameter
final String DOM_LEVEL2WD_CLASS = "org.w3c.dom.Node";
final String DOM_LEVEL2WD_METHOD = "supported"; // String, String
final String DOM_LEVEL2FD_CLASS = "org.w3c.dom.Node";
@@ -1039,13 +1057,13 @@
Method method = clazz.getMethod(DOM_LEVEL2_METHOD, twoStringArgs);
- // If we succeeded, we have loaded interfaces from a
+ // If we succeeded, we have loaded interfaces from a
// level 2 DOM somewhere
h.put(VERSION + "DOM", "2.0");
try
{
- // Check for the working draft version, which is
+ // Check for the working draft version, which is
// commonly found, but won't work anymore
clazz = ObjectFactory.findProviderClass(
DOM_LEVEL2WD_CLASS, ObjectFactory.findClassLoader(), true);
@@ -1082,15 +1100,15 @@
}
//@todo load an actual DOM implmementation and query it as well
- //@todo load an actual DOM implmementation and check if
- // isNamespaceAware() == true, which is needed to parse
+ //@todo load an actual DOM implmementation and check if
+ // isNamespaceAware() == true, which is needed to parse
// xsl stylesheet files into a DOM
}
/**
- * Report version info from SAX interfaces.
+ * Report version info from SAX interfaces.
*
- * Currently distinguishes between SAX 2, SAX 2.0beta2,
+ * Currently distinguishes between SAX 2, SAX 2.0beta2,
* SAX1, and not found.
*
* @param h Hashtable to put information in
@@ -1113,14 +1131,14 @@
try
{
- // This method was only added in the final SAX 2.0 release;
+ // This method was only added in the final SAX 2.0 release;
// see changes.html "Changes from SAX 2.0beta2 to SAX 2.0prerelease"
Class clazz = ObjectFactory.findProviderClass(
SAX_VERSION2BETA_CLASSNF, ObjectFactory.findClassLoader(), true);
Method method = clazz.getMethod(SAX_VERSION2BETA_METHODNF, attributesArg);
- // If we succeeded, we have loaded interfaces from a
+ // If we succeeded, we have loaded interfaces from a
// real, final SAX version 2.0 somewhere
h.put(VERSION + "SAX", "2.0");
}
@@ -1130,7 +1148,7 @@
h.put(ERROR + VERSION + "SAX",
"ERROR attempting to load SAX version 2 class: " + e.toString());
h.put(ERROR, ERROR_FOUND);
-
+
try
{
Class clazz = ObjectFactory.findProviderClass(
@@ -1138,9 +1156,9 @@
Method method = clazz.getMethod(SAX_VERSION2_METHOD, oneStringArg);
- // If we succeeded, we have loaded interfaces from a
- // SAX version 2.0beta2 or earlier; these might work but
- // you should really have the final SAX 2.0
+ // If we succeeded, we have loaded interfaces from a
+ // SAX version 2.0beta2 or earlier; these might work but
+ // you should really have the final SAX 2.0
h.put(VERSION + "SAX-backlevel", "2.0beta2-or-earlier");
}
catch (Exception e2)
@@ -1149,7 +1167,7 @@
h.put(ERROR + VERSION + "SAX",
"ERROR attempting to load SAX version 2 class: " + e.toString());
h.put(ERROR, ERROR_FOUND);
-
+
try
{
Class clazz = ObjectFactory.findProviderClass(
@@ -1157,8 +1175,8 @@
Method method = clazz.getMethod(SAX_VERSION1_METHOD, oneStringArg);
- // If we succeeded, we have loaded interfaces from a
- // SAX version 1.0 somewhere; which won't work very
+ // If we succeeded, we have loaded interfaces from a
+ // SAX version 1.0 somewhere; which won't work very
// well for JAXP 1.1 or beyond!
h.put(VERSION + "SAX-backlevel", "1.0");
}
@@ -1168,14 +1186,14 @@
// Note that either 1.0 or no SAX are both errors
h.put(ERROR + VERSION + "SAX-backlevel",
"ERROR attempting to load SAX version 1 class: " + e3.toString());
-
+
}
}
}
}
- /**
- * Manual table of known .jar sizes.
+ /**
+ * Manual table of known .jar sizes.
* Only includes shipped versions of certain projects.
* key=jarsize, value=jarname ' from ' distro name
* Note assumption: two jars cannot have the same size!
@@ -1184,13 +1202,13 @@
*/
private static Hashtable jarVersions = new Hashtable();
- /**
- * Static initializer for jarVersions table.
+ /**
+ * Static initializer for jarVersions table.
* Doing this just once saves time and space.
*
* @see #getApparentVersion(String, long)
*/
- static
+ static
{
// Note: hackish Hashtable, this could use improvement
jarVersions.put(new Long(857192), "xalan.jar from xalan-j_1_1");
@@ -1206,19 +1224,19 @@
jarVersions.put(new Long(905872), "xalan.jar from xalan-j_2_3_D1");
jarVersions.put(new Long(906122), "xalan.jar from xalan-j_2_3_0");
jarVersions.put(new Long(906248), "xalan.jar from xalan-j_2_3_1");
- jarVersions.put(new Long(983377), "xalan.jar from xalan-j_2_4_D1");
+ jarVersions.put(new Long(983377), "xalan.jar from xalan-j_2_4_D1");
jarVersions.put(new Long(997276), "xalan.jar from xalan-j_2_4_0");
- jarVersions.put(new Long(1031036), "xalan.jar from xalan-j_2_4_1");
- // Stop recording xalan.jar sizes as of Xalan Java 2.5.0
+ jarVersions.put(new Long(1031036), "xalan.jar from xalan-j_2_4_1");
+ // Stop recording xalan.jar sizes as of Xalan Java 2.5.0
jarVersions.put(new Long(596540), "xsltc.jar from xalan-j_2_2_0");
jarVersions.put(new Long(590247), "xsltc.jar from xalan-j_2_3_D1");
jarVersions.put(new Long(589914), "xsltc.jar from xalan-j_2_3_0");
jarVersions.put(new Long(589915), "xsltc.jar from xalan-j_2_3_1");
- jarVersions.put(new Long(1306667), "xsltc.jar from xalan-j_2_4_D1");
+ jarVersions.put(new Long(1306667), "xsltc.jar from xalan-j_2_4_D1");
jarVersions.put(new Long(1328227), "xsltc.jar from xalan-j_2_4_0");
jarVersions.put(new Long(1344009), "xsltc.jar from xalan-j_2_4_1");
- jarVersions.put(new Long(1348361), "xsltc.jar from xalan-j_2_5_D1");
+ jarVersions.put(new Long(1348361), "xsltc.jar from xalan-j_2_5_D1");
// Stop recording xsltc.jar sizes as of Xalan Java 2.5.0
jarVersions.put(new Long(1268634), "xsltc.jar-bundled from xalan-j_2_3_0");
@@ -1231,7 +1249,7 @@
jarVersions.put(new Long(124724), "xml-apis.jar from tck-jaxp-1_2_0 branch of xml-commons, tag: xml-commons-external_1_2_01");
jarVersions.put(new Long(194205), "xml-apis.jar from head branch of xml-commons, tag: xml-commons-external_1_3_02");
- // If the below were more common I would update it to report
+ // If the below were more common I would update it to report
// errors better; but this is so old hardly anyone has it
jarVersions.put(new Long(424490), "xalan.jar from Xerces Tools releases - ERROR:DO NOT USE!");
@@ -1249,23 +1267,23 @@
jarVersions.put(new Long(1812019), "xerces.jar from xalan-j_2_2_0");
jarVersions.put(new Long(1720292), "xercesImpl.jar from xalan-j_2_3_D1");
jarVersions.put(new Long(1730053), "xercesImpl.jar from xalan-j_2_3_0 or xalan-j_2_3_1 from xerces-2_0_0");
- jarVersions.put(new Long(1728861), "xercesImpl.jar from xalan-j_2_4_D1 from xerces-2_0_1");
+ jarVersions.put(new Long(1728861), "xercesImpl.jar from xalan-j_2_4_D1 from xerces-2_0_1");
jarVersions.put(new Long(972027), "xercesImpl.jar from xalan-j_2_4_0 from xerces-2_1");
- jarVersions.put(new Long(831587), "xercesImpl.jar from xalan-j_2_4_1 from xerces-2_2");
- jarVersions.put(new Long(891817), "xercesImpl.jar from xalan-j_2_5_D1 from xerces-2_3");
+ jarVersions.put(new Long(831587), "xercesImpl.jar from xalan-j_2_4_1 from xerces-2_2");
+ jarVersions.put(new Long(891817), "xercesImpl.jar from xalan-j_2_5_D1 from xerces-2_3");
jarVersions.put(new Long(895924), "xercesImpl.jar from xerces-2_4");
- jarVersions.put(new Long(1010806), "xercesImpl.jar from Xerces-J-bin.2.6.2");
- jarVersions.put(new Long(1203860), "xercesImpl.jar from Xerces-J-bin.2.7.1");
+ jarVersions.put(new Long(1010806), "xercesImpl.jar from Xerces-J-bin.2.6.2");
+ jarVersions.put(new Long(1203860), "xercesImpl.jar from Xerces-J-bin.2.7.1");
jarVersions.put(new Long(37485), "xalanj1compat.jar from xalan-j_2_0_0");
jarVersions.put(new Long(38100), "xalanj1compat.jar from xalan-j_2_0_1");
jarVersions.put(new Long(18779), "xalanservlet.jar from xalan-j_2_0_0");
jarVersions.put(new Long(21453), "xalanservlet.jar from xalan-j_2_0_1");
- jarVersions.put(new Long(24826), "xalanservlet.jar from xalan-j_2_3_1 or xalan-j_2_4_1");
+ jarVersions.put(new Long(24826), "xalanservlet.jar from xalan-j_2_3_1 or xalan-j_2_4_1");
jarVersions.put(new Long(24831), "xalanservlet.jar from xalan-j_2_4_1");
// Stop recording xalanservlet.jar sizes as of Xalan Java 2.5.0; now a .war file
-
+
// For those who've downloaded JAXP from sun
jarVersions.put(new Long(5618), "jaxp.jar from jaxp1.0.1");
jarVersions.put(new Long(136133), "parser.jar from jaxp1.0.1");
@@ -1287,7 +1305,7 @@
protected PrintWriter outWriter = new PrintWriter(System.out, true);
/**
- * Bottleneck output: calls outWriter.println(s).
+ * Bottleneck output: calls outWriter.println(s).
* @param s String to print
*/
protected void logMsg(String s)
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,17 +26,18 @@
import org.w3c.dom.DOMException;
/**
- * AttrNSImpl inherits from AttrImpl and adds namespace support.
+ * AttrNSImpl inherits from AttrImpl and adds namespace support.
*
* The qualified name is the node name, and we store localName which is also
* used in all queries. On the other hand we recompute the prefix when
* necessary.
- *
+ *
* @xerces.internal
- *
+ *
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
* @author Ralf Pfeiffer, IBM
+ * @version $Id: AttrNSImpl.java,v 1.7 2010-11-01 04:39:37 joehw Exp $
*/
public class AttrNSImpl
extends AttrImpl {
@@ -47,7 +48,7 @@
/** Serialization version. */
static final long serialVersionUID = -781906615369795414L;
-
+
static final String xmlnsURI = "http://www.w3.org/2000/xmlns/";
static final String xmlURI = "http://www.w3.org/XML/1998/namespace";
@@ -57,7 +58,7 @@
/** DOM2: Namespace URI. */
protected String namespaceURI;
-
+
/** DOM2: localName. */
protected String localName;
@@ -65,12 +66,12 @@
* Default constructor
*/
public AttrNSImpl(){}
-
+
/**
* DOM2: Constructor for Namespace implementation.
*/
- protected AttrNSImpl(CoreDocumentImpl ownerDocument,
- String namespaceURI,
+ protected AttrNSImpl(CoreDocumentImpl ownerDocument,
+ String namespaceURI,
String qualifiedName) {
super(ownerDocument, qualifiedName);
@@ -85,7 +86,7 @@
if (namespaceURI !=null) {
this.namespaceURI = (namespaceURI.length() == 0)? null
: namespaceURI;
-
+
}
int colon1 = qname.indexOf(':');
int colon2 = qname.lastIndexOf(':');
@@ -95,7 +96,7 @@
localName = qname;
if (ownerDocument.errorChecking) {
ownerDocument.checkQName(null, localName);
-
+
if (qname.equals("xmlns") && (namespaceURI == null
|| !namespaceURI.equals(NamespaceContext.XMLNS_URI))
|| (namespaceURI!=null && namespaceURI.equals(NamespaceContext.XMLNS_URI)
@@ -115,21 +116,21 @@
ownerDocument.checkQName(prefix, localName);
ownerDocument.checkDOMNSErr(prefix, namespaceURI);
}
- }
+ }
// when local name is known
- public AttrNSImpl(CoreDocumentImpl ownerDocument,
- String namespaceURI,
+ public AttrNSImpl(CoreDocumentImpl ownerDocument,
+ String namespaceURI,
String qualifiedName,
String localName) {
super(ownerDocument, qualifiedName);
-
+
this.localName = localName;
this.namespaceURI = namespaceURI;
}
-
+
// for DeferredAttrImpl
- protected AttrNSImpl(CoreDocumentImpl ownerDocument,
+ protected AttrNSImpl(CoreDocumentImpl ownerDocument,
String value) {
super(ownerDocument, value);
}
@@ -142,20 +143,20 @@
if (needsSyncData()) {
synchronizeData();
}
- this.name = qualifiedName;
+ this.name = qualifiedName;
setName(namespaceURI, qualifiedName);
}
/**
* NON-DOM: resets this node and sets specified values for the node
- *
+ *
* @param ownerDocument
* @param namespaceURI
* @param qualifiedName
* @param localName
*/
- public void setValues (CoreDocumentImpl ownerDocument,
- String namespaceURI,
+ public void setValues (CoreDocumentImpl ownerDocument,
+ String namespaceURI,
String qualifiedName,
String localName){
@@ -174,7 +175,7 @@
// DOM2: Namespace methods
//
- /**
+ /**
* Introduced in DOM Level 2.
*
* The namespace URI of this node, or null if it is unspecified.
@@ -184,7 +185,7 @@
* merely the namespace URI given at creation time.
*
* For nodes created with a DOM Level 1 method, such as createElement
- * from the Document interface, this is null.
+ * from the Document interface, this is null.
* @since WD-DOM-Level-2-19990923
*/
public String getNamespaceURI()
@@ -197,8 +198,8 @@
// seems to be some DOM spec interpretation grey-area.
return namespaceURI;
}
-
- /**
+
+ /**
* Introduced in DOM Level 2.
*
* The namespace prefix of this node, or null if it is unspecified.
@@ -214,16 +215,16 @@
synchronizeData();
}
int index = name.indexOf(':');
- return index < 0 ? null : name.substring(0, index);
+ return index < 0 ? null : name.substring(0, index);
}
-
+
/**
* Introduced in DOM Level 2.
- *
+ *
* Note that setting this attribute changes the nodeName attribute, which
* holds the qualified name, as well as the tagName and name attributes of
* the Element and Attr interfaces, when applicable.
- *
+ *
* @param prefix The namespace prefix of this node, or null(empty string) if it is unspecified.
*
* @exception INVALID_CHARACTER_ERR
@@ -252,7 +253,7 @@
if (namespaceURI == null || prefix.indexOf(':') >=0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
-
+
}
if (prefix.equals("xmlns")) {
if (!namespaceURI.equals(xmlnsURI)){
@@ -268,7 +269,7 @@
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
- }
+ }
}
// update node name with new qualifiedName
@@ -279,8 +280,8 @@
name = localName;
}
}
-
- /**
+
+ /**
* Introduced in DOM Level 2.
*
* Returns the local part of the qualified name of this node.
@@ -293,8 +294,8 @@
}
return localName;
}
-
-
+
+
/**
* @see org.w3c.dom.TypeInfo#getTypeName()
*/
@@ -312,26 +313,26 @@
* Introduced in DOM Level 3.
* Checks if a type is derived from another by restriction. See:
* http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
+ *
+ * @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
* The name of the ancestor type declaration
* @param type
* The reference type definition
- *
+ *
* @return boolean True if the type is derived by restriciton for the
* reference type
*/
- public boolean isDerivedFrom(String typeNamespaceArg,
- String typeNameArg,
+ public boolean isDerivedFrom(String typeNamespaceArg,
+ String typeNameArg,
int derivationMethod) {
if (type != null) {
- if (type instanceof XSSimpleTypeDefinition) {
+ if (type instanceof XSSimpleTypeDecl) {
return ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
typeNamespaceArg, typeNameArg, derivationMethod);
- }
- }
+ }
+ }
return false;
}
@@ -347,5 +348,5 @@
}
return null;
}
-
+
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,26 +20,27 @@
package com.sun.org.apache.xerces.internal.dom;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
-
/**
* AttributeMap inherits from NamedNodeMapImpl and extends it to deal with the
* specifics of storing attributes. These are:
*
* - managing ownership of attribute nodes
- *
- managing default attributes
+ *
- managing default attributes
*
- firing mutation events
*
*
* This class doesn't directly support mutation events, however, it notifies
* the document when mutations are performed so that the document class do so.
- *
+ *
* @xerces.internal
*
+ * @version $Id: AttributeMap.java,v 1.7 2010-11-01 04:39:37 joehw Exp $
*/
public class AttributeMap extends NamedNodeMapImpl {
@@ -105,11 +106,11 @@
argn.ownerNode = ownerNode;
argn.isOwned(true);
- int i = findNamePoint(arg.getNodeName(),0);
+ int i = findNamePoint(argn.getNodeName(),0);
AttrImpl previous = null;
if (i >= 0) {
- previous = (AttrImpl) nodes.elementAt(i);
- nodes.setElementAt(arg,i);
+ previous = (AttrImpl) nodes.get(i);
+ nodes.set(i, arg);
previous.ownerNode = ownerNode.ownerDocument();
previous.isOwned(false);
// make sure it won't be mistaken with defaults in case it's reused
@@ -117,9 +118,9 @@
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
- nodes = new Vector(5, 10);
+ nodes = new ArrayList(5);
}
- nodes.insertElementAt(arg, i);
+ nodes.add(i, arg);
}
// notify document
@@ -177,8 +178,8 @@
int i = findNamePoint(argn.getNamespaceURI(), argn.getLocalName());
AttrImpl previous = null;
if (i >= 0) {
- previous = (AttrImpl) nodes.elementAt(i);
- nodes.setElementAt(arg,i);
+ previous = (AttrImpl) nodes.get(i);
+ nodes.set(i, arg);
previous.ownerNode = ownerNode.ownerDocument();
previous.isOwned(false);
// make sure it won't be mistaken with defaults in case it's reused
@@ -188,17 +189,17 @@
// nodeName so we know where to insert.
i = findNamePoint(arg.getNodeName(),0);
if (i >=0) {
- previous = (AttrImpl) nodes.elementAt(i);
- nodes.insertElementAt(arg,i);
+ previous = (AttrImpl) nodes.get(i);
+ nodes.add(i, arg);
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
- nodes = new Vector(5, 10);
+ nodes = new ArrayList(5);
}
- nodes.insertElementAt(arg, i);
+ nodes.add(i, arg);
}
}
- // changed(true);
+ // changed(true);
// notify document
ownerNode.ownerDocument().setAttrNode(argn, previous);
@@ -256,8 +257,9 @@
int index = -1;
if (nodes != null) {
- for (int i = 0; i < nodes.size(); i++) {
- if (nodes.elementAt(i) == item) {
+ final int size = nodes.size();
+ for (int i = 0; i < size; ++i) {
+ if (nodes.get(i) == item) {
index = i;
break;
}
@@ -290,7 +292,7 @@
}
}
- return remove((AttrImpl)nodes.elementAt(i), i, true);
+ return remove((AttrImpl)nodes.get(i), i, true);
} // internalRemoveNamedItem(String,boolean):Node
@@ -324,16 +326,16 @@
clone.isOwned(true);
clone.isSpecified(false);
- nodes.setElementAt(clone, index);
+ nodes.set(index, clone);
if (attr.isIdAttribute()) {
ownerDocument.putIdentifier(clone.getNodeValue(),
(ElementImpl)ownerNode);
}
} else {
- nodes.removeElementAt(index);
+ nodes.remove(index);
}
} else {
- nodes.removeElementAt(index);
+ nodes.remove(index);
}
// changed(true);
@@ -360,7 +362,7 @@
* The namespace URI of the node to remove.
* When it is null or an empty string, this
* method behaves like removeNamedItem.
- * @param The local name of the node to remove. If the
+ * @param name The local name of the node to remove. If the
* removed attribute is known to have a default
* value, an attribute immediately appears
* containing the default value.
@@ -406,7 +408,7 @@
}
}
- AttrImpl n = (AttrImpl)nodes.elementAt(i);
+ AttrImpl n = (AttrImpl)nodes.get(i);
if (n.isIdAttribute()) {
ownerDocument.removeIdentifier(n.getValue());
@@ -432,19 +434,19 @@
}
clone.isOwned(true);
clone.isSpecified(false);
- nodes.setElementAt(clone, i);
+ nodes.set(i, clone);
if (clone.isIdAttribute()) {
ownerDocument.putIdentifier(clone.getNodeValue(),
(ElementImpl)ownerNode);
}
} else {
- nodes.removeElementAt(i);
+ nodes.remove(i);
}
} else {
- nodes.removeElementAt(i);
+ nodes.remove(i);
}
} else {
- nodes.removeElementAt(i);
+ nodes.remove(i);
}
// changed(true);
@@ -486,19 +488,21 @@
* Override parent's method to set the ownerNode correctly
*/
protected void cloneContent(NamedNodeMapImpl srcmap) {
- Vector srcnodes = srcmap.nodes;
+ List srcnodes = srcmap.nodes;
if (srcnodes != null) {
int size = srcnodes.size();
if (size != 0) {
if (nodes == null) {
- nodes = new Vector(size);
+ nodes = new ArrayList(size);
}
- nodes.setSize(size);
+ else {
+ nodes.clear();
+ }
for (int i = 0; i < size; ++i) {
- NodeImpl n = (NodeImpl) srcnodes.elementAt(i);
+ NodeImpl n = (NodeImpl) srcnodes.get(i);
NodeImpl clone = (NodeImpl) n.cloneNode(true);
clone.isSpecified(n.isSpecified());
- nodes.setElementAt(clone, i);
+ nodes.add(clone);
clone.ownerNode = ownerNode;
clone.isOwned(true);
}
@@ -513,7 +517,7 @@
void moveSpecifiedAttributes(AttributeMap srcmap) {
int nsize = (srcmap.nodes != null) ? srcmap.nodes.size() : 0;
for (int i = nsize - 1; i >= 0; i--) {
- AttrImpl attr = (AttrImpl) srcmap.nodes.elementAt(i);
+ AttrImpl attr = (AttrImpl) srcmap.nodes.get(i);
if (attr.isSpecified()) {
srcmap.remove(attr, i, false);
if (attr.getLocalName() != null) {
@@ -535,8 +539,8 @@
// remove any existing default
int nsize = (nodes != null) ? nodes.size() : 0;
- for (int i = nsize - 1; i >= 0; i--) {
- AttrImpl attr = (AttrImpl) nodes.elementAt(i);
+ for (int i = nsize - 1; i >= 0; --i) {
+ AttrImpl attr = (AttrImpl) nodes.get(i);
if (!attr.isSpecified()) {
remove(attr, i, false);
}
@@ -550,20 +554,53 @@
}
else {
int dsize = defaults.nodes.size();
- for (int n = 0; n < dsize; n++) {
- AttrImpl d = (AttrImpl) defaults.nodes.elementAt(n);
+ for (int n = 0; n < dsize; ++n) {
+ AttrImpl d = (AttrImpl) defaults.nodes.get(n);
int i = findNamePoint(d.getNodeName(), 0);
if (i < 0) {
- i = -1 - i;
+ i = -1 - i;
NodeImpl clone = (NodeImpl) d.cloneNode(true);
clone.ownerNode = ownerNode;
clone.isOwned(true);
clone.isSpecified(false);
- nodes.insertElementAt(clone, i);
+ nodes.add(i, clone);
}
}
}
} // reconcileDefaults()
+ protected final int addItem (Node arg) {
+
+ final AttrImpl argn = (AttrImpl) arg;
+
+ // set owner
+ argn.ownerNode = ownerNode;
+ argn.isOwned(true);
+
+ int i = findNamePoint(argn.getNamespaceURI(), argn.getLocalName());
+ if (i >= 0) {
+ nodes.set(i, arg);
+ }
+ else {
+ // If we can't find by namespaceURI, localName, then we find by
+ // nodeName so we know where to insert.
+ i = findNamePoint(argn.getNodeName(),0);
+ if (i >= 0) {
+ nodes.add(i, arg);
+ }
+ else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new ArrayList(5);
+ }
+ nodes.add(i, arg);
+ }
+ }
+
+ // notify document
+ ownerNode.ownerDocument().setAttrNode(argn, null);
+ return i;
+ }
+
} // class AttributeMap
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -60,11 +60,12 @@
/**
* Xerces implementation of DOMConfiguration that maintains a table of recognized parameters.
- *
+ *
* @xerces.internal
*
* @author Elena Litani, IBM
* @author Neeraj Bajaj, Sun Microsystems.
+ * @version $Id: DOMConfigurationImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $
*/
public class DOMConfigurationImpl extends ParserConfigurationSettings
implements XMLParserConfiguration, DOMConfiguration {
@@ -85,7 +86,7 @@
protected static final String SCHEMA =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
-
+
protected static final String SCHEMA_FULL_CHECKING =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
@@ -99,8 +100,15 @@
protected static final String SEND_PSVI =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;
- protected final static String DTD_VALIDATOR_FACTORY_PROPERTY =
- Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
+ protected final static String DTD_VALIDATOR_FACTORY_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
+
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
// property identifiers
@@ -142,6 +150,11 @@
protected static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+
+ /** Property identifier: Schema DV Factory */
+ protected static final String SCHEMA_DV_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
+
//
// Data
//
@@ -235,6 +248,8 @@
DYNAMIC_VALIDATION,
NORMALIZE_DATA,
SEND_PSVI,
+ NAMESPACE_GROWTH,
+ TOLERATE_DUPLICATES
};
addRecognizedFeatures(recognizedFeatures);
@@ -246,6 +261,7 @@
setFeature(NORMALIZE_DATA, false);
setFeature(XERCES_NAMESPACES, true);
setFeature(SEND_PSVI, true);
+ setFeature(NAMESPACE_GROWTH, false);
// add default recognized properties
final String[] recognizedProperties = {
@@ -259,7 +275,8 @@
GRAMMAR_POOL,
JAXP_SCHEMA_SOURCE,
JAXP_SCHEMA_LANGUAGE,
- DTD_VALIDATOR_FACTORY_PROPERTY
+ DTD_VALIDATOR_FACTORY_PROPERTY,
+ SCHEMA_DV_FACTORY
};
addRecognizedProperties(recognizedProperties);
@@ -285,7 +302,7 @@
addComponent(fErrorReporter);
setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, DTDDVFactory.getInstance());
-
+
XMLEntityManager manager = new XMLEntityManager();
setProperty(ENTITY_MANAGER, manager);
addComponent(manager);
@@ -527,12 +544,12 @@
* setParameter
*/
public void setParameter(String name, Object value) throws DOMException {
- boolean found = true;
+ boolean found = true;
// REVISIT: Recognizes DOM L3 default features only.
// Does not yet recognize Xerces features.
- if(value instanceof Boolean){
- boolean state = ((Boolean)value).booleanValue();
+ if(value instanceof Boolean){
+ boolean state = ((Boolean)value).booleanValue();
if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
features = (short) (state ? features | COMMENTS : features & ~COMMENTS);
@@ -588,7 +605,7 @@
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
}
- else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
+ else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
if (!state) { // false is not supported
String msg =
DOMMessageFormatter.formatMessage(
@@ -615,7 +632,7 @@
features = (short) (state ? features | PSVI : features & ~PSVI);
}
else {
- found = false;
+ found = false;
/*
String msg =
DOMMessageFormatter.formatMessage(
@@ -625,11 +642,11 @@
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
*/
}
-
+
}
-
- if (!found || !(value instanceof Boolean)) { // set properties
- found = true;
+
+ if (!found || !(value instanceof Boolean)) { // set properties
+ found = true;
if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
if (value instanceof DOMErrorHandler || value == null) {
@@ -692,18 +709,18 @@
if (value == null) {
setProperty(
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
- null);
+ null);
}
else if (value.equals(Constants.NS_XMLSCHEMA)) {
// REVISIT: when add support to DTD validation
setProperty(
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
Constants.NS_XMLSCHEMA);
- }
+ }
else if (value.equals(Constants.NS_DTD)) {
// Added support for revalidation against DTDs
- setProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
- Constants.NS_DTD);
+ setProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
+ Constants.NS_DTD);
}
}
catch (XMLConfigurationException e) {}
@@ -767,90 +784,90 @@
* DOM Level 3 WD - Experimental.
* getParameter
*/
- public Object getParameter(String name) throws DOMException {
+ public Object getParameter(String name) throws DOMException {
- // REVISIT: Recognizes DOM L3 default features only.
- // Does not yet recognize Xerces features.
+ // REVISIT: Recognizes DOM L3 default features only.
+ // Does not yet recognize Xerces features.
- if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
- return ((features & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACES)) {
- return (features & NAMESPACES) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)) {
- // REVISIT: datatype-normalization only takes effect if validation is on
- return (features & DTNORMALIZATION) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
- return (features & CDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_ENTITIES)) {
- return (features & ENTITIES) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)) {
- return (features & SPLITCDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_VALIDATE)) {
- return (features & VALIDATE) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
- return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
- return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
- return (features & INFOSET_MASK) == INFOSET_TRUE_PARAMS ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
- || name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
- || name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
- || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
+ if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
+ return ((features & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACES)) {
+ return (features & NAMESPACES) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)) {
+ // REVISIT: datatype-normalization only takes effect if validation is on
+ return (features & DTNORMALIZATION) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
+ return (features & CDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_ENTITIES)) {
+ return (features & ENTITIES) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)) {
+ return (features & SPLITCDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_VALIDATE)) {
+ return (features & VALIDATE) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
+ return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+ return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
+ return (features & INFOSET_MASK) == INFOSET_TRUE_PARAMS ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
+ || name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
+ || name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
+ || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
) {
- return Boolean.FALSE;
- }
+ return Boolean.FALSE;
+ }
else if (name.equalsIgnoreCase(SEND_PSVI)) {
return Boolean.TRUE;
}
else if (name.equalsIgnoreCase(Constants.DOM_PSVI)) {
return (features & PSVI) != 0 ? Boolean.TRUE : Boolean.FALSE;
- }
+ }
else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
- return Boolean.TRUE;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
+ return Boolean.TRUE;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
return fErrorHandlerWrapper.getErrorHandler();
- }
- else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
- XMLEntityResolver entityResolver = getEntityResolver();
- if (entityResolver != null && entityResolver instanceof DOMEntityResolverWrapper) {
- return ((DOMEntityResolverWrapper) entityResolver).getEntityResolver();
- }
- return null;
- }
- else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
- return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
- }
- else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
- return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE);
- }
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
+ XMLEntityResolver entityResolver = getEntityResolver();
+ if (entityResolver != null && entityResolver instanceof DOMEntityResolverWrapper) {
+ return ((DOMEntityResolverWrapper) entityResolver).getEntityResolver();
+ }
+ return null;
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
+ return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
+ }
+ else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
+ return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE);
+ }
else if (name.equalsIgnoreCase(SYMBOL_TABLE)){
return getProperty(SYMBOL_TABLE);
}
else if (name.equalsIgnoreCase(GRAMMAR_POOL)){
return getProperty(GRAMMAR_POOL);
}
- else {
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_FOUND",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
- }
+ else {
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "FEATURE_NOT_FOUND",
+ new Object[] { name });
+ throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ }
- }
+ }
/**
* DOM Level 3 WD - Experimental.
@@ -865,7 +882,7 @@
* the requested value is not supported. This does not change the
* current value of the parameter itself.
*/
- public boolean canSetParameter(String name, Object value) {
+ public boolean canSetParameter(String name, Object value) {
if (value == null){
//if null, the returned value is true.
@@ -910,7 +927,7 @@
return false ;
}
}
- else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
+ else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
return (value instanceof DOMErrorHandler) ? true : false ;
}
else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
@@ -936,7 +953,7 @@
return false ;
}
- } //canSetParameter
+ } //canSetParameter
/**
* DOM Level 3 CR - Experimental.
@@ -947,45 +964,45 @@
* parameter names defined outside this specification.
*/
public DOMStringList getParameterNames() {
- if (fRecognizedParameters == null){
- Vector parameters = new Vector();
+ if (fRecognizedParameters == null){
+ Vector parameters = new Vector();
- //Add DOM recognized parameters
- //REVISIT: Would have been nice to have a list of
- //recognized paramters.
- parameters.add(Constants.DOM_COMMENTS);
- parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
- parameters.add(Constants.DOM_CDATA_SECTIONS);
- parameters.add(Constants.DOM_ENTITIES);
- parameters.add(Constants.DOM_SPLIT_CDATA);
- parameters.add(Constants.DOM_NAMESPACES);
- parameters.add(Constants.DOM_VALIDATE);
+ //Add DOM recognized parameters
+ //REVISIT: Would have been nice to have a list of
+ //recognized paramters.
+ parameters.add(Constants.DOM_COMMENTS);
+ parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
+ parameters.add(Constants.DOM_CDATA_SECTIONS);
+ parameters.add(Constants.DOM_ENTITIES);
+ parameters.add(Constants.DOM_SPLIT_CDATA);
+ parameters.add(Constants.DOM_NAMESPACES);
+ parameters.add(Constants.DOM_VALIDATE);
- parameters.add(Constants.DOM_INFOSET);
- parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
- parameters.add(Constants.DOM_CANONICAL_FORM);
- parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
- parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
- parameters.add(Constants.DOM_WELLFORMED);
+ parameters.add(Constants.DOM_INFOSET);
+ parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
+ parameters.add(Constants.DOM_CANONICAL_FORM);
+ parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
+ parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
+ parameters.add(Constants.DOM_WELLFORMED);
- parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
- parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
+ parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
+ parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
- parameters.add(Constants.DOM_ERROR_HANDLER);
- parameters.add(Constants.DOM_SCHEMA_TYPE);
- parameters.add(Constants.DOM_SCHEMA_LOCATION);
- parameters.add(Constants.DOM_RESOURCE_RESOLVER);
+ parameters.add(Constants.DOM_ERROR_HANDLER);
+ parameters.add(Constants.DOM_SCHEMA_TYPE);
+ parameters.add(Constants.DOM_SCHEMA_LOCATION);
+ parameters.add(Constants.DOM_RESOURCE_RESOLVER);
- //Add recognized xerces features and properties
- parameters.add(GRAMMAR_POOL);
- parameters.add(SYMBOL_TABLE);
- parameters.add(SEND_PSVI);
+ //Add recognized xerces features and properties
+ parameters.add(GRAMMAR_POOL);
+ parameters.add(SYMBOL_TABLE);
+ parameters.add(SEND_PSVI);
- fRecognizedParameters = new DOMStringListImpl(parameters);
+ fRecognizedParameters = new DOMStringListImpl(parameters);
- }
+ }
- return fRecognizedParameters;
+ return fRecognizedParameters;
}//getParameterNames
//
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java Wed Sep 28 17:36:24 2011 +0100
@@ -22,6 +22,7 @@
import java.io.IOException;
+import java.util.ArrayList;
import java.io.StringReader;
import java.util.Vector;
@@ -83,16 +84,17 @@
* document.
* See Namespace normalization for details on how namespace declaration attributes and prefixes
* are normalized.
- *
+ *
* NOTE: There is an initial support for DOM revalidation with XML Schema as a grammar.
* The tree might not be validated correctly if entityReferences, CDATA sections are
* present in the tree. The PSVI information is not exposed, normalized data (including element
* default content is not available).
*
* @xerces.experimental
- *
+ *
* @author Elena Litani, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @version $Id: DOMNormalizer.java,v 1.9 2010-11-01 04:39:38 joehw Exp $
*/
public class DOMNormalizer implements XMLDocumentHandler {
@@ -124,13 +126,13 @@
protected SymbolTable fSymbolTable;
/** error handler. may be null. */
protected DOMErrorHandler fErrorHandler;
-
+
/**
* Cached {@link DOMError} impl.
* The same object is re-used to report multiple errors.
*/
private final DOMErrorImpl fError = new DOMErrorImpl();
-
+
// Validation against namespace aware grammar
protected boolean fNamespaceValidation = false;
@@ -144,8 +146,7 @@
protected final NamespaceContext fLocalNSBinder = new NamespaceSupport();
/** list of attributes */
- protected final Vector fAttributeList = new Vector(5,10);
-
+ protected final ArrayList fAttributeList = new ArrayList(5);
/** DOM Locator - for namespace fixup algorithm */
protected final DOMLocatorImpl fLocator = new DOMLocatorImpl();
@@ -153,23 +154,23 @@
/** for setting the PSVI */
protected Node fCurrentNode = null;
private QName fAttrQName = new QName();
-
+
// attribute value normalization
final XMLString fNormalizedValue = new XMLString(new char[16], 0, 0);
-
+
/**
* If the user stops the process, this exception will be thrown.
*/
public static final RuntimeException abort = new RuntimeException();
-
+
//DTD validator
private XMLDTDValidator fDTDValidator;
-
+
//Check if element content is all "ignorable whitespace"
private boolean allWhitespace = false;
-
+
// Constructor
- //
+ //
public DOMNormalizer(){}
@@ -179,81 +180,81 @@
* Normalizes document.
* Note: reset() must be called before this method.
*/
- protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config) {
+ protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config) {
- fDocument = document;
- fConfiguration = config;
+ fDocument = document;
+ fConfiguration = config;
- // intialize and reset DOMNormalizer component
- //
- fSymbolTable = (SymbolTable) fConfiguration.getProperty(DOMConfigurationImpl.SYMBOL_TABLE);
- // reset namespace context
- fNamespaceContext.reset();
- fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
+ // intialize and reset DOMNormalizer component
+ //
+ fSymbolTable = (SymbolTable) fConfiguration.getProperty(DOMConfigurationImpl.SYMBOL_TABLE);
+ // reset namespace context
+ fNamespaceContext.reset();
+ fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
- if ((fConfiguration.features & DOMConfigurationImpl.VALIDATE) != 0) {
+ if ((fConfiguration.features & DOMConfigurationImpl.VALIDATE) != 0) {
String schemaLang = (String)fConfiguration.getProperty(DOMConfigurationImpl.JAXP_SCHEMA_LANGUAGE);
-
+
if(schemaLang != null && schemaLang.equals(Constants.NS_XMLSCHEMA)) {
- fValidationHandler =
- CoreDOMImplementationImpl.singleton.getValidator(XMLGrammarDescription.XML_SCHEMA);
+ fValidationHandler =
+ CoreDOMImplementationImpl.singleton.getValidator(XMLGrammarDescription.XML_SCHEMA);
fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA, true);
fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA_FULL_CHECKING, true);
// report fatal error on DOM Level 1 nodes
- fNamespaceValidation = true;
-
+ fNamespaceValidation = true;
+
// check if we need to fill in PSVI
- fPSVI = ((fConfiguration.features & DOMConfigurationImpl.PSVI) !=0)?true:false;
+ fPSVI = ((fConfiguration.features & DOMConfigurationImpl.PSVI) !=0)?true:false;
}
-
- fConfiguration.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true);
-
- // reset ID table
+
+ fConfiguration.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true);
+
+ // reset ID table
fDocument.clearIdentifiers();
-
+
if(fValidationHandler != null)
// reset schema validator
((XMLComponent) fValidationHandler).reset(fConfiguration);
-
- }
+
+ }
- fErrorHandler = (DOMErrorHandler) fConfiguration.getParameter(Constants.DOM_ERROR_HANDLER);
- if (fValidationHandler != null) {
- fValidationHandler.setDocumentHandler(this);
- fValidationHandler.startDocument(
+ fErrorHandler = (DOMErrorHandler) fConfiguration.getParameter(Constants.DOM_ERROR_HANDLER);
+ if (fValidationHandler != null) {
+ fValidationHandler.setDocumentHandler(this);
+ fValidationHandler.startDocument(
new SimpleLocator(fDocument.fDocumentURI, fDocument.fDocumentURI,
- -1, -1 ), fDocument.encoding, fNamespaceContext, null);
+ -1, -1 ), fDocument.encoding, fNamespaceContext, null);
- }
- try {
- Node kid, next;
- for (kid = fDocument.getFirstChild(); kid != null; kid = next) {
- next = kid.getNextSibling();
- kid = normalizeNode(kid);
- if (kid != null) { // don't advance
- next = kid;
- }
- }
+ }
+ try {
+ Node kid, next;
+ for (kid = fDocument.getFirstChild(); kid != null; kid = next) {
+ next = kid.getNextSibling();
+ kid = normalizeNode(kid);
+ if (kid != null) { // don't advance
+ next = kid;
+ }
+ }
- // release resources
- if (fValidationHandler != null) {
- fValidationHandler.endDocument(null);
- CoreDOMImplementationImpl.singleton.releaseValidator(
- XMLGrammarDescription.XML_SCHEMA, fValidationHandler);
- fValidationHandler = null;
- }
- }
- catch (RuntimeException e) {
+ // release resources
+ if (fValidationHandler != null) {
+ fValidationHandler.endDocument(null);
+ CoreDOMImplementationImpl.singleton.releaseValidator(
+ XMLGrammarDescription.XML_SCHEMA, fValidationHandler);
+ fValidationHandler = null;
+ }
+ }
+ catch (RuntimeException e) {
if( e==abort )
return; // processing aborted by the user
throw e; // otherwise re-throw.
- }
+ }
- }
+ }
/**
- *
+ *
* This method acts as if the document was going through a save
* and load cycle, putting the document in a "normal" form. The actual result
* depends on the features being set and governing what operations actually
@@ -262,7 +263,7 @@
* according to the algorithm described below in pseudo code, by adding missing
* namespace declaration attributes and adding or changing namespace prefixes, updates
* the replacement tree of EntityReference nodes,normalizes attribute values, etc.
- *
+ *
* @param node Modified node or null. If node is returned, we need
* to normalize again starting on the node returned.
* @return the normalized Node
@@ -272,7 +273,7 @@
int type = node.getNodeType();
boolean wellformed;
fLocator.fRelatedNode=node;
-
+
switch (type) {
case Node.DOCUMENT_TYPE_NODE: {
if (DEBUG_ND) {
@@ -291,15 +292,15 @@
break;
}
- case Node.ELEMENT_NODE: {
+ case Node.ELEMENT_NODE: {
if (DEBUG_ND) {
System.out.println("==>normalizeNode:{element} "+node.getNodeName());
}
-
+
//do the name check only when version of the document was changed &
//application has set the value of well-formed features to true
if (fDocument.errorChecking) {
- if ( ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
+ if ( ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
fDocument.isXMLVersionChanged()){
if (fNamespaceValidation){
wellformed = CoreDocumentImpl.isValidQName(node.getPrefix() , node.getLocalName(), fDocument.isXML11Version()) ;
@@ -309,11 +310,11 @@
}
if (!wellformed){
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "wf-invalid-character-in-node-name",
+ DOMMessageFormatter.DOM_DOMAIN,
+ "wf-invalid-character-in-node-name",
new Object[]{"Element", node.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
- "wf-invalid-character-in-node-name");
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
+ "wf-invalid-character-in-node-name");
}
}
}
@@ -325,7 +326,7 @@
if (elem.needsSyncChildren()) {
elem.synchronizeChildren();
}
- AttributeMap attributes = (elem.hasAttributes()) ? (AttributeMap) elem.getAttributes() : null;
+ AttributeMap attributes = (elem.hasAttributes()) ? (AttributeMap) elem.getAttributes() : null;
// fix namespaces and remove default attributes
if ((fConfiguration.features & DOMConfigurationImpl.NAMESPACES) !=0) {
@@ -333,7 +334,7 @@
// normalize attribute values
// remove default attributes
namespaceFixUp(elem, attributes);
-
+
if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0 && attributes != null ) {
for (int i = 0; i < attributes.getLength(); ++i) {
Attr att = (Attr)attributes.getItem(i);
@@ -343,8 +344,8 @@
--i;
}
}
- }
-
+ }
+
} else {
if ( attributes!=null ) {
for ( int i=0; inormalizeNode:{comments}");
}
@@ -467,13 +468,13 @@
if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0)){
String commentdata = ((Comment)node).getData();
// check comments for invalid xml chracter as per the version
- // of the document
- isCommentWF(fErrorHandler, fError, fLocator, commentdata, fDocument.isXML11Version());
+ // of the document
+ isCommentWF(fErrorHandler, fError, fLocator, commentdata, fDocument.isXML11Version());
}
}//end-else if comment node is not to be removed.
- break;
+ break;
}
- case Node.ENTITY_REFERENCE_NODE: {
+ case Node.ENTITY_REFERENCE_NODE: {
if (DEBUG_ND) {
System.out.println("==>normalizeNode:{entityRef} "+node.getNodeName());
}
@@ -488,15 +489,15 @@
// The list of children #text -> &ent;
// and entity has a first child as a text
// we should not advance
- if (prevSibling != null && next != null && prevSibling.getNodeType() == Node.TEXT_NODE &&
+ if (prevSibling != null && next != null && prevSibling.getNodeType() == Node.TEXT_NODE &&
next.getNodeType() == Node.TEXT_NODE) {
- return prevSibling; // Don't advance
+ return prevSibling; // Don't advance
}
return next;
} else {
- if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
+ if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
fDocument.isXMLVersionChanged()){
- CoreDocumentImpl.isXMLName(node.getNodeName() , fDocument.isXML11Version());
+ CoreDocumentImpl.isXMLName(node.getNodeName() , fDocument.isXML11Version());
}
// REVISIT: traverse entity reference and send appropriate calls to the validator
// (no normalization should be performed for the children).
@@ -508,21 +509,21 @@
if (DEBUG_ND) {
System.out.println("==>normalizeNode:{cdata}");
}
-
+
if ((fConfiguration.features & DOMConfigurationImpl.CDATA) == 0) {
// convert CDATA to TEXT nodes
Node prevSibling = node.getPreviousSibling();
if (prevSibling != null && prevSibling.getNodeType() == Node.TEXT_NODE){
((Text)prevSibling).appendData(node.getNodeValue());
node.getParentNode().removeChild(node);
- return prevSibling; //don't advance
+ return prevSibling; //don't advance
}
else {
Text text = fDocument.createTextNode(node.getNodeValue());
Node parent = node.getParentNode();
node = parent.replaceChild(text, node);
return text; //don't advance
-
+
}
}
@@ -536,7 +537,7 @@
fValidationHandler.characterData(node.getNodeValue(), null);
fValidationHandler.endCDATA(null);
}
-
+
if (fDTDValidator != null) {
// set error node in the dom error wrapper
// so if error occurs we can report an error node
@@ -547,7 +548,7 @@
fDTDValidator.endCDATA(null);
}
String value = node.getNodeValue();
-
+
if ((fConfiguration.features & DOMConfigurationImpl.SPLITCDATA) != 0) {
int index;
Node parent = node.getParentNode();
@@ -557,18 +558,18 @@
while ( (index=value.indexOf("]]>")) >= 0 ) {
node.setNodeValue(value.substring(0, index+2));
value = value.substring(index +2);
-
+
Node firstSplitNode = node;
Node newChild = fDocument.createCDATASection(value);
parent.insertBefore(newChild, node.getNextSibling());
- node = newChild;
+ node = newChild;
// issue warning
fLocator.fRelatedNode = firstSplitNode;
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "cdata-sections-splitted",
+ DOMMessageFormatter.DOM_DOMAIN,
+ "cdata-sections-splitted",
null);
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_WARNING,
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_WARNING,
"cdata-sections-splitted");
}
@@ -580,7 +581,7 @@
break;
}
- case Node.TEXT_NODE: {
+ case Node.TEXT_NODE: {
if (DEBUG_ND) {
System.out.println("==>normalizeNode(text):{"+node.getNodeValue()+"}");
}
@@ -596,18 +597,18 @@
node.getParentNode().removeChild( next );
// We don't need to check well-formness here since we are not yet
// done with this node.
-
- return node; // Don't advance;
+
+ return node; // Don't advance;
} else if (node.getNodeValue().length()==0) {
// If kid is empty, remove it
node.getParentNode().removeChild( node );
- } else {
+ } else {
// validator.characters() call and well-formness
// Don't send characters or check well-formness in the following cases:
// 1. entities is false, next child is entity reference: expand tree first
// 2. comments is false, and next child is comment
// 3. cdata is false, and next child is cdata
-
+
short nextType = (next != null)?next.getNodeType():-1;
if (nextType == -1 || !(((fConfiguration.features & DOMConfigurationImpl.ENTITIES) == 0 &&
nextType == Node.ENTITY_NODE) ||
@@ -617,7 +618,7 @@
nextType == Node.CDATA_SECTION_NODE)) {
if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) ){
isXMLCharWF(fErrorHandler, fError, fLocator, node.getNodeValue(), fDocument.isXML11Version());
- }
+ }
if (fValidationHandler != null) {
fConfiguration.fErrorHandlerWrapper.fCurrentNode = node;
fCurrentNode = node;
@@ -626,7 +627,7 @@
System.out.println("=====>characterData(),"+nextType);
}
- }
+ }
if (fDTDValidator != null) {
fConfiguration.fErrorHandlerWrapper.fCurrentNode = node;
fCurrentNode = node;
@@ -639,7 +640,7 @@
allWhitespace = false;
((TextImpl)node).setIgnorableWhitespace(true);
}
- }
+ }
}
else {
if (DEBUG_ND) {
@@ -649,9 +650,9 @@
}
}
break;
- }
+ }
case Node.PROCESSING_INSTRUCTION_NODE: {
-
+
//do the well-formed valid PI target name , data check when application has set the value of well-formed feature to true
if (fDocument.errorChecking && (fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0 ) {
ProcessingInstruction pinode = (ProcessingInstruction)node ;
@@ -661,26 +662,26 @@
if(fDocument.isXML11Version()){
wellformed = XML11Char.isXML11ValidName(target);
}
- else{
+ else{
wellformed = XMLChar.isValidName(target);
}
- if (!wellformed) {
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "wf-invalid-character-in-node-name",
- new Object[]{"Element", node.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
+ if (!wellformed) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "wf-invalid-character-in-node-name",
+ new Object[]{"Element", node.getNodeName()});
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
"wf-invalid-character-in-node-name");
- }
-
+ }
+
//2. check PI data
//processing isntruction data may have certain characters
- //which may not be valid XML character
+ //which may not be valid XML character
isXMLCharWF(fErrorHandler, fError, fLocator, pinode.getData(), fDocument.isXML11Version());
}
}//end case Node.PROCESSING_INSTRUCTION_NODE
-
+
}//end of switch
return null;
}//normalizeNode
@@ -688,16 +689,16 @@
private XMLGrammarPool createGrammarPool(DocumentTypeImpl docType) {
XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl();
-
+
XMLGrammarPreparser preParser = new XMLGrammarPreparser(fSymbolTable);
preParser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true);
preParser.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, pool);
-
+
String internalSubset = docType.getInternalSubset();
XMLInputSource is = new XMLInputSource(docType.getPublicId(), docType.getSystemId(), null);
-
+
if(internalSubset != null)
is.setCharacterStream(new StringReader(internalSubset));
try {
@@ -706,11 +707,11 @@
is.setCharacterStream(null);
g = (DTDGrammar)preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is);
((XMLDTDDescription)g.getGrammarDescription()).setRootName(docType.getName());
-
+
} catch (XNIException e) {
} catch (IOException e) {
}
-
+
return pool;
}
@@ -728,7 +729,7 @@
// normalize attribute values
// remove default attributes
// check attribute names if the version of the document changed.
-
+
protected final void namespaceFixUp (ElementImpl element, AttributeMap attributes){
if (DEBUG) {
System.out.println("[ns-fixup] element:" +element.getNodeName()+
@@ -738,7 +739,7 @@
// ------------------------------------
// pick up local namespace declarations
//
- //
//
@@ -751,19 +752,19 @@
// Record all valid local declarations
for (int k = 0; k < attributes.getLength(); ++k) {
Attr attr = (Attr)attributes.getItem(k);
-
+
//do the name check only when version of the document was changed &
//application has set the value of well-formed features to true
- if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
+ if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) &&
fDocument.isXMLVersionChanged()) {
//checkQName does checking based on the version of the document
fDocument.checkQName(attr.getPrefix() , attr.getLocalName()) ;
}
-
+
uri = attr.getNamespaceURI();
if (uri != null && uri.equals(NamespaceContext.XMLNS_URI)) {
// namespace attribute
-
+
// "namespace-declarations" == false; Discard all namespace declaration attributes
if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) {
continue;
@@ -776,8 +777,8 @@
// Check for invalid namespace declaration:
if (fDocument.errorChecking && value.equals(NamespaceContext.XMLNS_URI)) {
- //A null value for locale is passed to formatMessage,
- //which means that the default locale will be used
+ //A null value for locale is passed to formatMessage,
+ //which means that the default locale will be used
fLocator.fRelatedNode = attr;
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.XML_DOMAIN,"CantBindXMLNS",null );
reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR, "CantBindXMLNS");
@@ -785,7 +786,7 @@
// XML 1.0 Attribute value normalization
// value = normalizeAttributeValue(value, attr);
prefix = attr.getPrefix();
- prefix = (prefix == null ||
+ prefix = (prefix == null ||
prefix.length() == 0) ? XMLSymbols.EMPTY_STRING :fSymbolTable.addSymbol(prefix);
String localpart = fSymbolTable.addSymbol( attr.getLocalName());
if (prefix == XMLSymbols.PREFIX_XMLNS) { //xmlns:prefix
@@ -815,14 +816,14 @@
// ---------------------------------------------------------
- // Fix up namespaces for element: per DOM L3
+ // Fix up namespaces for element: per DOM L3
// Need to consider the following cases:
//
// case 1:
// We create another element body bound to the "http://xsl" namespace
// as well as namespace attribute rebounding xsl to another namespace.
//
- // Need to make sure that the new namespace decl value is changed to
+ // Need to make sure that the new namespace decl value is changed to
// "http://xsl"
//
// ---------------------------------------------------------
@@ -831,20 +832,20 @@
uri = element.getNamespaceURI();
prefix = element.getPrefix();
-
+
// "namespace-declarations" == false? Discard all namespace declaration attributes
if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) {
// no namespace declaration == no namespace URI, semantics are to keep prefix
uri = null;
} else if (uri != null) { // Element has a namespace
uri = fSymbolTable.addSymbol(uri);
- prefix = (prefix == null ||
+ prefix = (prefix == null ||
prefix.length() == 0) ? XMLSymbols.EMPTY_STRING :fSymbolTable.addSymbol(prefix);
if (fNamespaceContext.getURI(prefix) == uri) {
// The xmlns:prefix=namespace or xmlns="default" was declared at parent.
// The binder always stores mapping of empty prefix to "".
} else {
- // the prefix is either undeclared
+ // the prefix is either undeclared
// or
// conflict: the prefix is bound to another URI
addNamespaceDecl(prefix, uri, element);
@@ -853,27 +854,27 @@
}
} else { // Element has no namespace
if (element.getLocalName() == null) {
-
+
// Error: DOM Level 1 node!
if (fNamespaceValidation) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "NullLocalElementName",
+ DOMMessageFormatter.DOM_DOMAIN, "NullLocalElementName",
new Object[]{element.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_FATAL_ERROR,
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_FATAL_ERROR,
"NullLocalElementName");
} else {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "NullLocalElementName",
+ DOMMessageFormatter.DOM_DOMAIN, "NullLocalElementName",
new Object[]{element.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
"NullLocalElementName");
}
-
+
} else { // uri=null and no colon (DOM L2 node)
uri = fNamespaceContext.getURI(XMLSymbols.EMPTY_STRING);
if (uri !=null && uri.length() > 0) {
// undeclare default namespace declaration (before that element
- // bound to non-zero length uir), but adding xmlns="" decl
+ // bound to non-zero length uir), but adding xmlns="" decl
addNamespaceDecl (XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING, element);
fLocalNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
@@ -882,7 +883,7 @@
}
// -----------------------------------------
- // Fix up namespaces for attributes: per DOM L3
+ // Fix up namespaces for attributes: per DOM L3
// check if prefix/namespace is correct the attributes
// -----------------------------------------
if (attributes != null) {
@@ -890,16 +891,16 @@
// clone content of the attributes
attributes.cloneMap(fAttributeList);
for (int i = 0; i < fAttributeList.size(); i++) {
- Attr attr = (Attr) fAttributeList.elementAt(i);
+ Attr attr = (Attr) fAttributeList.get(i);
fLocator.fRelatedNode = attr;
if (DEBUG) {
System.out.println("==>[ns-fixup] process attribute: "+attr.getNodeName());
}
// normalize attribute value
- attr.normalize();
+ attr.normalize();
value = attr.getValue();
- name = attr.getNodeName();
+ name = attr.getNodeName();
uri = attr.getNamespaceURI();
// make sure that value is never null.
@@ -909,12 +910,12 @@
if (uri != null) { // attribute has namespace !=null
prefix = attr.getPrefix();
- prefix = (prefix == null ||
+ prefix = (prefix == null ||
prefix.length() == 0) ? XMLSymbols.EMPTY_STRING :fSymbolTable.addSymbol(prefix);
/*String localpart =*/ fSymbolTable.addSymbol( attr.getLocalName());
// ---------------------------------------
- // skip namespace declarations
+ // skip namespace declarations
// ---------------------------------------
// REVISIT: can we assume that "uri" is from some symbol
// table, and compare by reference? -SG
@@ -926,15 +927,15 @@
//---------------------------------------
if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0)) {
isAttrValueWF(fErrorHandler, fError, fLocator, attributes, (AttrImpl)attr, attr.getValue(), fDocument.isXML11Version());
- if (fDocument.isXMLVersionChanged()){
+ if (fDocument.isXMLVersionChanged()){
boolean wellformed=CoreDocumentImpl.isXMLName(attr.getNodeName() , fDocument.isXML11Version());
if (!wellformed){
- String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "wf-invalid-character-in-node-name",
- new Object[]{"Attribute", attr.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
- "wf-invalid-character-in-node-name");
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "wf-invalid-character-in-node-name",
+ new Object[]{"Attribute", attr.getNodeName()});
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
+ "wf-invalid-character-in-node-name");
}
}
}
@@ -942,14 +943,14 @@
// ---------------------------------------
// remove default attributes
// ---------------------------------------
- /*
+ /*
if (removeDefault(attr, attributes)) {
continue;
}
*/
// XML 1.0 Attribute value normalization
//value = normalizeAttributeValue(value, attr);
-
+
// reset id-attributes
((AttrImpl)attr).setIdAttribute(false);
@@ -960,7 +961,7 @@
String declaredURI = fNamespaceContext.getURI(prefix);
if (prefix == XMLSymbols.EMPTY_STRING || declaredURI != uri) {
- // attribute has no prefix (default namespace decl does not apply to attributes)
+ // attribute has no prefix (default namespace decl does not apply to attributes)
// OR
// attribute prefix is not declared
// OR
@@ -1005,7 +1006,7 @@
// XML 1.0 Attribute value normalization
//value = normalizeAttributeValue(value, attr);
-
+
// reset id-attributes
((AttrImpl)attr).setIdAttribute(false);
@@ -1013,20 +1014,20 @@
// It is an error if document has DOM L1 nodes.
if (fNamespaceValidation) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
+ DOMMessageFormatter.DOM_DOMAIN,
"NullLocalAttrName", new Object[]{attr.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_FATAL_ERROR,
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_FATAL_ERROR,
"NullLocalAttrName");
} else {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
+ DOMMessageFormatter.DOM_DOMAIN,
"NullLocalAttrName", new Object[]{attr.getNodeName()});
- reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
+ reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
"NullLocalAttrName");
}
} else {
// uri=null and no colon
- // no fix up is needed: default namespace decl does not
+ // no fix up is needed: default namespace decl does not
// ---------------------------------------
// remove default attributes
@@ -1037,12 +1038,12 @@
}
} // end loop for attributes
}
-
+
/**
* Adds a namespace attribute or replaces the value of existing namespace
* attribute with the given prefix and value for URI.
* In case prefix is empty will add/update default namespace declaration.
- *
+ *
* @param prefix
* @param uri
* @exception IOException
@@ -1056,47 +1057,47 @@
if (DEBUG) {
System.out.println("=>add xmlns=\""+uri+"\" declaration");
}
- element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
+ element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
} else {
if (DEBUG) {
System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
}
- element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
+ element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
}
}
-
-
+
+
//
// Methods for well-formness checking
//
-
-
+
+
/**
* Check if CDATA section is well-formed
* @param datavalue
* @param isXML11Version = true if XML 1.1
*/
- public static final void isCDataWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
+ public static final void isCDataWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
String datavalue, boolean isXML11Version)
{
if (datavalue == null || (datavalue.length() == 0) ) {
return;
}
-
- char [] dataarray = datavalue.toCharArray();
+
+ char [] dataarray = datavalue.toCharArray();
int datalength = dataarray.length;
-
+
// version of the document is XML 1.1
- if (isXML11Version) {
+ if (isXML11Version) {
// we need to check all chracters as per production rules of XML11
int i = 0;
- while(i < datalength){
- char c = dataarray[i++];
+ while(i < datalength){
+ char c = dataarray[i++];
if ( XML11Char.isXML11Invalid(c) ) {
// check if this is a supplemental character
if (XMLChar.isHighSurrogate(c) && i < datalength) {
char c2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(c2) &&
+ if (XMLChar.isLowSurrogate(c2) &&
XMLChar.isSupplemental(XMLChar.supplemental(c, c2))) {
continue;
}
@@ -1125,31 +1126,31 @@
reportDOMError(errorHandler, error, locator,msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
}
}
-
+
}
}
} // version of the document is XML 1.0
- else {
+ else {
// we need to check all chracters as per production rules of XML 1.0
int i = 0;
- while (i < datalength) {
- char c = dataarray[i++];
+ while (i < datalength) {
+ char c = dataarray[i++];
if( XMLChar.isInvalid(c) ) {
// check if this is a supplemental character
if (XMLChar.isHighSurrogate(c) && i < datalength) {
char c2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(c2) &&
+ if (XMLChar.isLowSurrogate(c2) &&
XMLChar.isSupplemental(XMLChar.supplemental(c, c2))) {
continue;
}
}
// Note: The key InvalidCharInCDSect from XMLMessages.properties
// is being used to obtain the message and DOM error type
- // "wf-invalid-character" is used. Also per DOM it is error but
+ // "wf-invalid-character" is used. Also per DOM it is error but
// as per XML spec. it is fatal error
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.XML_DOMAIN,
- "InvalidCharInCDSect",
+ DOMMessageFormatter.XML_DOMAIN,
+ "InvalidCharInCDSect",
new Object[]{Integer.toString(c, 16)});
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
}
@@ -1164,129 +1165,129 @@
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
}
}
-
+
}
- }
+ }
} // end-else fDocument.isXMLVersion()
-
+
} // isCDataWF
-
+
/**
* NON-DOM: check for valid XML characters as per the XML version
* @param datavalue
* @param isXML11Version = true if XML 1.1
*/
- public static final void isXMLCharWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
+ public static final void isXMLCharWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
String datavalue, boolean isXML11Version)
{
if ( datavalue == null || (datavalue.length() == 0) ) {
- return;
+ return;
}
-
- char [] dataarray = datavalue.toCharArray();
+
+ char [] dataarray = datavalue.toCharArray();
int datalength = dataarray.length;
-
+
// version of the document is XML 1.1
- if(isXML11Version){
+ if(isXML11Version){
//we need to check all characters as per production rules of XML11
int i = 0 ;
- while (i < datalength) {
+ while (i < datalength) {
if(XML11Char.isXML11Invalid(dataarray[i++])){
// check if this is a supplemental character
char ch = dataarray[i-1];
if (XMLChar.isHighSurrogate(ch) && i < datalength) {
char ch2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(ch2) &&
+ if (XMLChar.isLowSurrogate(ch2) &&
XMLChar.isSupplemental(XMLChar.supplemental(ch, ch2))) {
continue;
}
}
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "InvalidXMLCharInDOM",
+ DOMMessageFormatter.DOM_DOMAIN, "InvalidXMLCharInDOM",
new Object[]{Integer.toString(dataarray[i-1], 16)});
- reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR,
+ reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR,
"wf-invalid-character");
}
}
} // version of the document is XML 1.0
- else{
+ else{
// we need to check all characters as per production rules of XML 1.0
int i = 0 ;
- while (i < datalength) {
+ while (i < datalength) {
if( XMLChar.isInvalid(dataarray[i++]) ) {
// check if this is a supplemental character
char ch = dataarray[i-1];
if (XMLChar.isHighSurrogate(ch) && i < datalength) {
char ch2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(ch2) &&
+ if (XMLChar.isLowSurrogate(ch2) &&
XMLChar.isSupplemental(XMLChar.supplemental(ch, ch2))) {
continue;
}
}
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "InvalidXMLCharInDOM",
+ DOMMessageFormatter.DOM_DOMAIN, "InvalidXMLCharInDOM",
new Object[]{Integer.toString(dataarray[i-1], 16)});
- reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR,
+ reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR,
"wf-invalid-character");
}
- }
+ }
} // end-else fDocument.isXMLVersion()
-
+
} // isXMLCharWF
-
+
/**
* NON-DOM: check if value of the comment is well-formed
* @param datavalue
* @param isXML11Version = true if XML 1.1
*/
- public static final void isCommentWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
+ public static final void isCommentWF(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
String datavalue, boolean isXML11Version)
{
if ( datavalue == null || (datavalue.length() == 0) ) {
return;
}
-
- char [] dataarray = datavalue.toCharArray();
+
+ char [] dataarray = datavalue.toCharArray();
int datalength = dataarray.length ;
-
+
// version of the document is XML 1.1
- if (isXML11Version) {
+ if (isXML11Version) {
// we need to check all chracters as per production rules of XML11
int i = 0 ;
- while (i < datalength){
+ while (i < datalength){
char c = dataarray[i++];
if ( XML11Char.isXML11Invalid(c) ) {
// check if this is a supplemental character
if (XMLChar.isHighSurrogate(c) && i < datalength) {
char c2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(c2) &&
+ if (XMLChar.isLowSurrogate(c2) &&
XMLChar.isSupplemental(XMLChar.supplemental(c, c2))) {
continue;
}
}
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.XML_DOMAIN,
- "InvalidCharInComment",
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.XML_DOMAIN,
+ "InvalidCharInComment",
new Object [] {Integer.toString(dataarray[i-1], 16)});
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
}
else if (c == '-' && i < datalength && dataarray[i] == '-') {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.XML_DOMAIN,
"DashDashInComment", null);
- // invalid: '--' in comment
+ // invalid: '--' in comment
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
}
}
} // version of the document is XML 1.0
- else {
+ else {
// we need to check all chracters as per production rules of XML 1.0
int i = 0;
- while (i < datalength){
- char c = dataarray[i++];
+ while (i < datalength){
+ char c = dataarray[i++];
if( XMLChar.isInvalid(c) ){
// check if this is a supplemental character
if (XMLChar.isHighSurrogate(c) && i < datalength) {
char c2 = dataarray[i++];
- if (XMLChar.isLowSurrogate(c2) &&
+ if (XMLChar.isLowSurrogate(c2) &&
XMLChar.isSupplemental(XMLChar.supplemental(c, c2))) {
continue;
}
@@ -1294,30 +1295,30 @@
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.XML_DOMAIN,
"InvalidCharInComment", new Object [] {Integer.toString(dataarray[i-1], 16)});
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR, "wf-invalid-character");
- }
+ }
else if (c == '-' && istrongly
@@ -1702,14 +1703,14 @@
* for copying the namespace bindings from the
* the current context (and its parent contexts)
* if that information is important.
- *
+ *
* @param augs Additional information that may include infoset augmentations
* @exception XNIException
* Thrown by handler to signal an error.
*/
- public void startDocument(XMLLocator locator, String encoding,
+ public void startDocument(XMLLocator locator, String encoding,
NamespaceContext namespaceContext,
- Augmentations augs)
+ Augmentations augs)
throws XNIException{
}
@@ -1717,13 +1718,13 @@
* Notifies of the presence of an XMLDecl line in the document. If
* present, this method will be called immediately following the
* startDocument call.
- *
+ *
* @param version The XML version.
* @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
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1733,7 +1734,7 @@
/**
* Notifies of the presence of the DOCTYPE line in the document.
- *
+ *
* @param rootElement
* The name of the root element.
* @param publicId The public identifier if an external DTD or null
@@ -1741,7 +1742,7 @@
* @param systemId The system identifier if an external DTD, null
* otherwise.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1751,10 +1752,10 @@
/**
* A comment.
- *
+ *
* @param text The text in the comment.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by application to signal an error.
*/
@@ -1771,11 +1772,11 @@
* element attributes but are not parsed or presented
* to the application as anything other than text. The application is
* responsible for parsing the data.
- *
+ *
* @param target The target.
* @param data The data or null if none specified.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1785,32 +1786,32 @@
/**
* The start of an element.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
- throws XNIException {
- Element currentElement = (Element) fCurrentNode;
- int attrCount = attributes.getLength();
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
+ throws XNIException {
+ Element currentElement = (Element) fCurrentNode;
+ int attrCount = attributes.getLength();
if (DEBUG_EVENTS) {
System.out.println("==>startElement: " +element+
" attrs.length="+attrCount);
}
- for (int i = 0; i < attrCount; i++) {
- attributes.getName(i, fAttrQName);
- Attr attr = null;
+ for (int i = 0; i < attrCount; i++) {
+ attributes.getName(i, fAttrQName);
+ Attr attr = null;
- attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
+ attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
AttributePSVI attrPSVI =
- (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
+ (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
- if (attrPSVI != null) {
+ if (attrPSVI != null) {
//REVISIT: instead we should be using augmentations:
// to set/retrieve Id attributes
XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
@@ -1820,59 +1821,59 @@
} else{
decl = attrPSVI.getTypeDefinition();
if (decl !=null){
- id = ((XSSimpleType)decl).isIDType();
+ id = ((XSSimpleType)decl).isIDType();
}
}
if (id){
((ElementImpl)currentElement).setIdAttributeNode(attr, true);
}
-
- if (fPSVI) {
- ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
- }
- if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
- // datatype-normalization
- // NOTE: The specified value MUST be set after we set
- // the node value because that turns the "specified"
- // flag to "true" which may overwrite a "false"
- // value from the attribute list.
- boolean specified = attr.getSpecified();
- attr.setValue(attrPSVI.getSchemaNormalizedValue());
- if (!specified) {
- ((AttrImpl) attr).setSpecified(specified);
- }
- }
- }
- }
- }
+
+ if (fPSVI) {
+ ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
+ }
+ if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
+ // datatype-normalization
+ // NOTE: The specified value MUST be set after we set
+ // the node value because that turns the "specified"
+ // flag to "true" which may overwrite a "false"
+ // value from the attribute list.
+ boolean specified = attr.getSpecified();
+ attr.setValue(attrPSVI.getSchemaNormalizedValue());
+ if (!specified) {
+ ((AttrImpl) attr).setSpecified(specified);
+ }
+ }
+ }
+ }
+ }
/**
* An empty element.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
- public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
- throws XNIException {
+ public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
+ throws XNIException {
if (DEBUG_EVENTS) {
System.out.println("==>emptyElement: " +element);
}
- startElement(element, attributes, augs);
+ startElement(element, attributes, augs);
endElement(element, augs);
- }
+ }
/**
* This method notifies the start of a general entity.
*
* Note: This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @param name The name of the general entity.
* @param identifier The resource identifier.
* @param encoding The auto-detected IANA encoding name of the entity
@@ -1881,10 +1882,10 @@
* internal entities or a document entity that is
* parsed from a java.io.Reader).
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException Thrown by handler to signal an error.
*/
- public void startGeneralEntity(String name,
+ public void startGeneralEntity(String name,
XMLResourceIdentifier identifier,
String encoding,
Augmentations augs) throws XNIException{
@@ -1900,11 +1901,11 @@
*
* Note: This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @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
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1916,10 +1917,10 @@
*
* Note: This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @param name The name of the entity.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1928,10 +1929,10 @@
/**
* Character content.
- *
+ *
* @param text The content.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1945,10 +1946,10 @@
* example, the validator can determine if a length of whitespace
* characters in the document are ignorable based on the element
* content model.
- *
+ *
* @param text The ignorable whitespace.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -1958,52 +1959,52 @@
/**
* The end of an element.
- *
+ *
* @param element The name of the element.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
- public void endElement(QName element, Augmentations augs) throws XNIException {
- if (DEBUG_EVENTS) {
- System.out.println("==>endElement: " + element);
- }
+ public void endElement(QName element, Augmentations augs) throws XNIException {
+ if (DEBUG_EVENTS) {
+ System.out.println("==>endElement: " + element);
+ }
if(augs != null) {
- ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI);
- if (elementPSVI != null) {
- ElementImpl elementNode = (ElementImpl) fCurrentNode;
- if (fPSVI) {
- ((PSVIElementNSImpl) fCurrentNode).setPSVI(elementPSVI);
- }
- // include element default content (if one is available)
- String normalizedValue = elementPSVI.getSchemaNormalizedValue();
- if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
+ ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI);
+ if (elementPSVI != null) {
+ ElementImpl elementNode = (ElementImpl) fCurrentNode;
+ if (fPSVI) {
+ ((PSVIElementNSImpl) fCurrentNode).setPSVI(elementPSVI);
+ }
+ // include element default content (if one is available)
+ String normalizedValue = elementPSVI.getSchemaNormalizedValue();
+ if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
if (normalizedValue !=null)
- elementNode.setTextContent(normalizedValue);
- }
- else {
- // NOTE: this is a hack: it is possible that DOM had an empty element
- // and validator sent default value using characters(), which we don't
- // implement. Thus, here we attempt to add the default value.
- String text = elementNode.getTextContent();
- if (text.length() == 0) {
- // default content could be provided
+ elementNode.setTextContent(normalizedValue);
+ }
+ else {
+ // NOTE: this is a hack: it is possible that DOM had an empty element
+ // and validator sent default value using characters(), which we don't
+ // implement. Thus, here we attempt to add the default value.
+ String text = elementNode.getTextContent();
+ if (text.length() == 0) {
+ // default content could be provided
if (normalizedValue !=null)
elementNode.setTextContent(normalizedValue);
- }
- }
- }
+ }
+ }
+ }
}
- }
+ }
/**
* The start of a CDATA section.
- *
+ *
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -2012,9 +2013,9 @@
/**
* The end of a CDATA section.
- *
+ *
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -2023,9 +2024,9 @@
/**
* The end of the document.
- *
+ *
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -2043,5 +2044,5 @@
return null;
}
-
+
} // DOMNormalizer class
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,12 +20,12 @@
package com.sun.org.apache.xerces.internal.dom;
+import java.util.ArrayList;
+
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import java.util.Vector;
-
/**
* The Document interface represents the entire HTML or XML document.
* Conceptually, it is the root of the document tree, and provides the
@@ -37,10 +37,10 @@
* objects. The Node objects created have a ownerDocument attribute
* which associates them with the Document within whose context they
* were created.
- *
+ *
* @xerces.internal
*
- * @version $Id: DeferredDocumentImpl.java,v 1.9 2010/08/11 07:18:39 joehw Exp $
+ * @version $Id: DeferredDocumentImpl.java,v 1.11 2010-11-01 04:39:38 joehw Exp $
* @since PR-DOM-Level-1-19980818.
*/
public class DeferredDocumentImpl
@@ -68,7 +68,7 @@
// protected
/** Chunk shift. */
- protected static final int CHUNK_SHIFT = 8; // 2^8 = 256
+ protected static final int CHUNK_SHIFT = 11; // 2^11 = 2k
/** Chunk size. */
protected static final int CHUNK_SIZE = (1 << CHUNK_SHIFT);
@@ -77,7 +77,7 @@
protected static final int CHUNK_MASK = CHUNK_SIZE - 1;
/** Initial chunk size. */
- protected static final int INITIAL_CHUNK_COUNT = (1 << (13 - CHUNK_SHIFT)); // 32
+ protected static final int INITIAL_CHUNK_COUNT = (1 << (16 - CHUNK_SHIFT)); // 2^16 = 64k
//
// Data
@@ -128,12 +128,12 @@
// Implementation Note: The deferred element and attribute must know how to
// interpret the int representing the qname.
protected boolean fNamespacesEnabled = false;
-
+
//
// private data
//
- private transient final StringBuilder fBufferStr = new StringBuilder();
- private transient final Vector fStrChunks = new Vector();
+ private transient final StringBuffer fBufferStr = new StringBuffer();
+ private transient final ArrayList fStrChunks = new ArrayList();
//
// Constructors
@@ -181,7 +181,7 @@
// information anyway.
return DeferredDOMImplementationImpl.getDOMImplementation();
}
-
+
/** Returns the cached parser.getNamespaces() value.*/
boolean getNamespacesEnabled() {
return fNamespacesEnabled;
@@ -223,10 +223,10 @@
int index = doctypeIndex & CHUNK_MASK;
// create extra data node to store internal subset
- int extraDataIndex = createNode(Node.DOCUMENT_TYPE_NODE);
+ int extraDataIndex = createNode(Node.DOCUMENT_TYPE_NODE);
int echunk = extraDataIndex >> CHUNK_SHIFT;
int eindex = extraDataIndex & CHUNK_MASK;
- setChunkIndex(fNodeExtra, extraDataIndex, chunk, index);
+ setChunkIndex(fNodeExtra, extraDataIndex, chunk, index);
setChunkValue(fNodeValue, subset, echunk, eindex);
}
@@ -241,7 +241,7 @@
// create extra data node
- int extraDataIndex = createNode(Node.NOTATION_NODE);
+ int extraDataIndex = createNode(Node.NOTATION_NODE);
int echunk = extraDataIndex >> CHUNK_SHIFT;
int eindex = extraDataIndex & CHUNK_MASK;
@@ -261,7 +261,7 @@
/** Creates an entity in the table. */
public int createDeferredEntity(String entityName, String publicId,
- String systemId, String notationName,
+ String systemId, String notationName,
String baseURI) {
// create node
int nodeIndex = createNode(Node.ENTITY_NODE);
@@ -269,7 +269,7 @@
int index = nodeIndex & CHUNK_MASK;
// create extra data node
- int extraDataIndex = createNode(Node.ENTITY_NODE);
+ int extraDataIndex = createNode(Node.ENTITY_NODE);
int echunk = extraDataIndex >> CHUNK_SHIFT;
int eindex = extraDataIndex & CHUNK_MASK;
@@ -322,9 +322,15 @@
}
}
+ // DOM Level 3: sets element TypeInfo
+ public void setTypeInfo(int elementNodeIndex, Object type) {
+ int elementChunk = elementNodeIndex >> CHUNK_SHIFT;
+ int elementIndex = elementNodeIndex & CHUNK_MASK;
+ setChunkValue(fNodeValue, type, elementChunk, elementIndex);
+ }
/**
- * DOM Internal
+ * DOM Internal
*
* An attribute specifying the actual encoding of this document. This is
* null
otherwise.
@@ -339,9 +345,9 @@
int echunk = extraDataIndex >> CHUNK_SHIFT;
int eindex = extraDataIndex & CHUNK_MASK;
-
+
setChunkValue(fNodeValue, value, echunk, eindex);
-
+
}
/** Creates an entity reference node in the table. */
@@ -360,8 +366,11 @@
} // createDeferredEntityReference(String):int
- /** Creates an element node with a URI in the table and type information. */
- public int createDeferredElement(String elementURI, String elementName,
+ /**
+ * Creates an element node with a URI in the table and type information.
+ * @deprecated
+ */
+ public int createDeferredElement(String elementURI, String elementName,
Object type) {
// create node
@@ -371,18 +380,23 @@
setChunkValue(fNodeName, elementName, elementChunk, elementIndex);
setChunkValue(fNodeURI, elementURI, elementChunk, elementIndex);
setChunkValue(fNodeValue, type, elementChunk, elementIndex);
-
+
// return node index
return elementNodeIndex;
- } // createDeferredElement(String,String):int
+ } // createDeferredElement(String,String,Object):int
- /** @deprecated. Creates an element node in the table. */
+ /**
+ * Creates an element node in the table.
+ * @deprecated
+ */
public int createDeferredElement(String elementName) {
return createDeferredElement(null, elementName);
}
- /** @deprecated. Creates an element node with a URI in the table. */
+ /**
+ * Creates an element node with a URI in the table.
+ */
public int createDeferredElement(String elementURI, String elementName) {
// create node
@@ -391,13 +405,13 @@
int elementIndex = elementNodeIndex & CHUNK_MASK;
setChunkValue(fNodeName, elementName, elementChunk, elementIndex);
setChunkValue(fNodeURI, elementURI, elementChunk, elementIndex);
-
+
// return node index
return elementNodeIndex;
} // createDeferredElement(String,String):int
-
-
+
+
/**
* This method is used by the DOMParser to create attributes.
* @param elementNodeIndex
@@ -416,7 +430,7 @@
boolean specified,
boolean id,
Object type) {
-
+
// create attribute
int attrNodeIndex = createDeferredAttribute(attrName, attrURI, attrValue, specified);
int attrChunk = attrNodeIndex >> CHUNK_SHIFT;
@@ -456,8 +470,11 @@
// return node index
return attrNodeIndex;
}
-
- /** @deprecated. Sets an attribute on an element node.*/
+
+ /**
+ * Sets an attribute on an element node.
+ * @deprecated
+ */
public int setDeferredAttribute(int elementNodeIndex,
String attrName, String attrURI,
String attrValue, boolean specified) {
@@ -483,7 +500,7 @@
// add link from element to new last attribute
setChunkIndex(fNodeExtra, attrNodeIndex,
elementChunk, elementIndex);
-
+
// return node index
return attrNodeIndex;
@@ -591,7 +608,7 @@
public int cloneNode(int nodeIndex, boolean deep) {
// clone immediate node
-
+
int nchunk = nodeIndex >> CHUNK_SHIFT;
int nindex = nodeIndex & CHUNK_MASK;
int nodeType = fNodeType[nchunk][nindex];
@@ -619,10 +636,10 @@
prevIndex = clonedChildIndex;
childIndex = getRealPrevSibling(childIndex, false);
}
-
+
}
-
+
// return cloned node index
return cloneIndex;
@@ -1002,11 +1019,6 @@
node = new DeferredElementImpl(this, nodeIndex);
}
- // save the document element node
- if (docElement == null) {
- docElement = (ElementImpl)node;
- }
-
// check to see if this element needs to be
// registered for its ID attributes
if (fIdElement != null) {
@@ -1131,7 +1143,7 @@
if (nodeIndex == -1) {
return null;
}
-
+
int chunk = nodeIndex >> CHUNK_SHIFT;
int index = nodeIndex & CHUNK_MASK;
String value = free ? clearChunkValue(fNodeValue, chunk, index)
@@ -1139,7 +1151,7 @@
if (value == null) {
return null;
}
-
+
int type = getChunkIndex(fNodeType, chunk, index);
if (type == Node.TEXT_NODE) {
int prevSib = getRealPrevSibling(nodeIndex);
@@ -1148,29 +1160,29 @@
// append data that is stored in fNodeValue
// REVISIT: for text nodes it works differently than for CDATA
// nodes.
- fStrChunks.addElement(value);
+ fStrChunks.add(value);
do {
// go in reverse order: find last child, then
// its previous sibling, etc
chunk = prevSib >> CHUNK_SHIFT;
index = prevSib & CHUNK_MASK;
value = getChunkValue(fNodeValue, chunk, index);
- fStrChunks.addElement(value);
+ fStrChunks.add(value);
prevSib = getChunkIndex(fNodePrevSib, chunk, index);
if (prevSib == -1) {
break;
}
} while (getNodeType(prevSib, false) == Node.TEXT_NODE);
-
+
int chunkCount = fStrChunks.size();
// add to the buffer in the correct order.
- for (int i = chunkCount - 1; i >= 0; i--) {
- fBufferStr.append((String)fStrChunks.elementAt(i));
+ for (int i = chunkCount - 1; i >= 0; i--) {
+ fBufferStr.append((String)fStrChunks.get(i));
}
-
+
value = fBufferStr.toString();
- fStrChunks.removeAllElements();
+ fStrChunks.clear();
fBufferStr.setLength(0);
return value;
}
@@ -1187,16 +1199,16 @@
chunk = child >> CHUNK_SHIFT;
index = child & CHUNK_MASK;
value = getChunkValue(fNodeValue, chunk, index);
- fStrChunks.addElement(value);
+ fStrChunks.add(value);
child = getChunkIndex(fNodePrevSib, chunk, index);
}
// add to the buffer in the correct order.
- for (int i=fStrChunks.size()-1; i>=0; i--) {
- fBufferStr.append((String)fStrChunks.elementAt(i));
+ for (int i=fStrChunks.size()-1; i>=0; i--) {
+ fBufferStr.append((String)fStrChunks.get(i));
}
-
+
value = fBufferStr.toString();
- fStrChunks.setSize(0);
+ fStrChunks.clear();
fBufferStr.setLength(0);
return value;
}
@@ -1212,7 +1224,7 @@
public String getNodeValue(int nodeIndex) {
return getNodeValue(nodeIndex, true);
}
-
+
/**
* Clears the type info that is stored in the fNodeValue array
* @param nodeIndex
@@ -1225,8 +1237,8 @@
int chunk = nodeIndex >> CHUNK_SHIFT;
int index = nodeIndex & CHUNK_MASK;
-
-
+
+
Object value = fNodeValue[chunk] != null ? fNodeValue[chunk][index] : null;
if (value != null) {
fNodeValue[chunk][index] = null;
@@ -1924,7 +1936,7 @@
System.arraycopy(INIT_ARRAY, 0, data[chunk], 0, CHUNK_SIZE);
}
- class RefCount {
+ static final class RefCount {
int fCount;
}
@@ -1998,7 +2010,7 @@
return data.toString();
}
}
-
+
/**
* Clears the specified value in the given data at the chunk and index.
@@ -2086,7 +2098,7 @@
/**
* A simple integer vector.
*/
- static class IntVector {
+ static final class IntVector {
//
// Data
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -28,15 +28,17 @@
package com.sun.org.apache.xerces.internal.dom;
+import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
import org.w3c.dom.NamedNodeMap;
+
/**
* DeferredElementNSImpl is to ElementNSImpl, what DeferredElementImpl is to
- * ElementImpl.
- *
+ * ElementImpl.
+ *
* @xerces.internal
- *
+ *
* @see DeferredElementImpl
*/
public class DeferredElementNSImpl
@@ -111,7 +113,7 @@
localName = name.substring(index + 1);
}
- namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
+ namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);
// attributes
@@ -119,10 +121,22 @@
int attrIndex = ownerDocument.getNodeExtra(fNodeIndex);
if (attrIndex != -1) {
NamedNodeMap attrs = getAttributes();
+ boolean seenSchemaDefault = false;
do {
- NodeImpl attr =
- (NodeImpl)ownerDocument.getNodeObject(attrIndex);
- attrs.setNamedItem(attr);
+ AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex);
+ // Take special care of schema defaulted attributes. Calling the
+ // non-namespace aware setAttributeNode() method could overwrite
+ // another attribute with the same local name.
+ if (!attr.getSpecified() && (seenSchemaDefault ||
+ (attr.getNamespaceURI() != null &&
+ attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
+ attr.getName().indexOf(':') < 0))) {
+ seenSchemaDefault = true;
+ attrs.setNamedItemNS(attr);
+ }
+ else {
+ attrs.setNamedItem(attr);
+ }
attrIndex = ownerDocument.getPrevSibling(attrIndex);
} while (attrIndex != -1);
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -37,11 +37,12 @@
* The qualified name is the node name, and we store localName which is also
* used in all queries. On the other hand we recompute the prefix when
* necessary.
- *
+ *
* @xerces.internal
- *
+ *
* @author Elena litani, IBM
* @author Neeraj Bajaj, Sun Microsystems
+ * @version $Id: ElementNSImpl.java,v 1.7 2010-11-01 04:39:39 joehw Exp $
*/
public class ElementNSImpl
extends ElementImpl {
@@ -83,15 +84,15 @@
setName(namespaceURI, qualifiedName);
}
- private void setName(String namespaceURI, String qname) {
+ private void setName(String namespaceURI, String qname) {
- String prefix;
- // DOM Level 3: namespace URI is never empty string.
- this.namespaceURI = namespaceURI;
- if (namespaceURI != null) {
+ String prefix;
+ // DOM Level 3: namespace URI is never empty string.
+ this.namespaceURI = namespaceURI;
+ if (namespaceURI != null) {
//convert the empty string to 'null'
- this.namespaceURI = (namespaceURI.length() == 0) ? null : namespaceURI;
- }
+ this.namespaceURI = (namespaceURI.length() == 0) ? null : namespaceURI;
+ }
int colon1, colon2 ;
@@ -100,63 +101,63 @@
//2. or if the qualifiedName is null and the namespaceURI is different from null,
// We dont need to check for namespaceURI != null, if qualified name is null throw DOMException.
if(qname == null){
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
else{
- colon1 = qname.indexOf(':');
- colon2 = qname.lastIndexOf(':');
+ colon1 = qname.indexOf(':');
+ colon2 = qname.lastIndexOf(':');
}
- ownerDocument.checkNamespaceWF(qname, colon1, colon2);
- if (colon1 < 0) {
- // there is no prefix
- localName = qname;
- if (ownerDocument.errorChecking) {
- ownerDocument.checkQName(null, localName);
- if (qname.equals("xmlns")
- && (namespaceURI == null
- || !namespaceURI.equals(NamespaceContext.XMLNS_URI))
- || (namespaceURI!=null && namespaceURI.equals(NamespaceContext.XMLNS_URI)
- && !qname.equals("xmlns"))) {
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
- }
- }
- }//there is a prefix
- else {
- prefix = qname.substring(0, colon1);
- localName = qname.substring(colon2 + 1);
-
- //NAMESPACE_ERR:
- //1. if the qualifiedName has a prefix and the namespaceURI is null,
-
- //2. or if the qualifiedName has a prefix that is "xml" and the namespaceURI
- //is different from " http://www.w3.org/XML/1998/namespace"
-
- if (ownerDocument.errorChecking) {
- if( namespaceURI == null || ( prefix.equals("xml") && !namespaceURI.equals(NamespaceContext.XML_URI) )){
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
- }
-
- ownerDocument.checkQName(prefix, localName);
- ownerDocument.checkDOMNSErr(prefix, namespaceURI);
- }
- }
- }
+ ownerDocument.checkNamespaceWF(qname, colon1, colon2);
+ if (colon1 < 0) {
+ // there is no prefix
+ localName = qname;
+ if (ownerDocument.errorChecking) {
+ ownerDocument.checkQName(null, localName);
+ if (qname.equals("xmlns")
+ && (namespaceURI == null
+ || !namespaceURI.equals(NamespaceContext.XMLNS_URI))
+ || (namespaceURI!=null && namespaceURI.equals(NamespaceContext.XMLNS_URI)
+ && !qname.equals("xmlns"))) {
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+ }
+ }
+ }//there is a prefix
+ else {
+ prefix = qname.substring(0, colon1);
+ localName = qname.substring(colon2 + 1);
+
+ //NAMESPACE_ERR:
+ //1. if the qualifiedName has a prefix and the namespaceURI is null,
+
+ //2. or if the qualifiedName has a prefix that is "xml" and the namespaceURI
+ //is different from " http://www.w3.org/XML/1998/namespace"
+
+ if (ownerDocument.errorChecking) {
+ if( namespaceURI == null || ( prefix.equals("xml") && !namespaceURI.equals(NamespaceContext.XML_URI) )){
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+ }
+
+ ownerDocument.checkQName(prefix, localName);
+ ownerDocument.checkDOMNSErr(prefix, namespaceURI);
+ }
+ }
+ }
// when local name is known
protected ElementNSImpl(CoreDocumentImpl ownerDocument,
@@ -184,7 +185,7 @@
if (needsSyncData()) {
synchronizeData();
}
- this.name = qualifiedName;
+ this.name = qualifiedName;
setName(namespaceURI, qualifiedName);
reconcileDefaultAttributes();
}
@@ -363,13 +364,13 @@
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e) {
// This may be a relative URI.
-
+
// Start from the base URI of the parent, or if this node has no parent, the owner node.
NodeImpl parentOrOwner = (parentNode() != null) ? parentNode() : ownerNode;
-
+
// Make any parentURI into a URI object to use with the URI(URI, String) constructor.
String parentBaseURI = (parentOrOwner != null) ? parentOrOwner.getBaseURI() : null;
-
+
if (parentBaseURI != null) {
try {
uri = new URI(new URI(parentBaseURI), uri).toString();
@@ -379,7 +380,7 @@
return null;
}
return uri;
- }
+ }
// REVISIT: what should happen in this case?
return null;
}
@@ -427,9 +428,9 @@
*/
public String getTypeName() {
if (type !=null){
- if (type instanceof XSSimpleTypeDefinition) {
+ if (type instanceof XSSimpleTypeDecl) {
return ((XSSimpleTypeDecl) type).getTypeName();
- } else {
+ } else if (type instanceof XSComplexTypeDecl) {
return ((XSComplexTypeDecl) type).getTypeName();
}
}
@@ -450,33 +451,33 @@
* Introduced in DOM Level 2.
* Checks if a type is derived from another by restriction. See:
* http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
+ *
+ * @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
* The name of the ancestor type declaration
* @param type
* The reference type definition
- *
+ *
* @return boolean True if the type is derived by restriciton for the
* reference type
*/
- public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg,
+ public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg,
int derivationMethod) {
if(needsSyncData()) {
synchronizeData();
}
if (type != null) {
- if (type instanceof XSSimpleTypeDefinition) {
+ if (type instanceof XSSimpleTypeDecl) {
return ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
typeNamespaceArg, typeNameArg, derivationMethod);
- } else {
+ } else if (type instanceof XSComplexTypeDecl) {
return ((XSComplexTypeDecl) type).isDOMDerivedFrom(
typeNamespaceArg, typeNameArg, derivationMethod);
}
}
return false;
- }
+ }
/**
* NON-DOM: setting type used by the DOM parser
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,7 +20,12 @@
package com.sun.org.apache.xerces.internal.dom;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
import org.w3c.dom.DOMException;
@@ -51,6 +56,7 @@
*
* @xerces.internal
*
+ * @version $Id: NamedNodeMapImpl.java,v 1.8 2010-11-01 04:39:39 joehw Exp $
* @since PR-DOM-Level-1-19980818.
*/
public class NamedNodeMapImpl
@@ -74,7 +80,7 @@
protected final static short HASDEFAULTS = 0x1<<2;
/** Nodes. */
- protected Vector nodes;
+ protected List nodes;
protected NodeImpl ownerNode; // the node this map belongs to
@@ -98,7 +104,7 @@
* item(getLength()-1).
*/
public int getLength() {
- return (nodes != null) ? nodes.size() : 0;
+ return (nodes != null) ? nodes.size() : 0;
}
/**
@@ -116,8 +122,8 @@
* is greater than or equal to getLength().
*/
public Node item(int index) {
- return (nodes != null && index < nodes.size()) ?
- (Node)(nodes.elementAt(index)) : null;
+ return (nodes != null && index < nodes.size()) ?
+ (Node)(nodes.get(index)) : null;
}
/**
@@ -129,8 +135,8 @@
*/
public Node getNamedItem(String name) {
- int i = findNamePoint(name,0);
- return (i < 0) ? null : (Node)(nodes.elementAt(i));
+ int i = findNamePoint(name,0);
+ return (i < 0) ? null : (Node)(nodes.get(i));
} // getNamedItem(String):Node
@@ -147,8 +153,8 @@
*/
public Node getNamedItemNS(String namespaceURI, String localName) {
- int i = findNamePoint(namespaceURI, localName);
- return (i < 0) ? null : (Node)(nodes.elementAt(i));
+ int i = findNamePoint(namespaceURI, localName);
+ return (i < 0) ? null : (Node)(nodes.get(i));
} // getNamedItemNS(String,String):Node
@@ -187,14 +193,14 @@
int i = findNamePoint(arg.getNodeName(),0);
NodeImpl previous = null;
if (i >= 0) {
- previous = (NodeImpl) nodes.elementAt(i);
- nodes.setElementAt(arg,i);
+ previous = (NodeImpl) nodes.get(i);
+ nodes.set(i, arg);
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
- nodes = new Vector(5, 10);
+ nodes = new ArrayList(5);
}
- nodes.insertElementAt(arg, i);
+ nodes.add(i, arg);
}
return previous;
@@ -230,21 +236,21 @@
int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
NodeImpl previous = null;
if (i >= 0) {
- previous = (NodeImpl) nodes.elementAt(i);
- nodes.setElementAt(arg,i);
+ previous = (NodeImpl) nodes.get(i);
+ nodes.set(i, arg);
} else {
// If we can't find by namespaceURI, localName, then we find by
// nodeName so we know where to insert.
i = findNamePoint(arg.getNodeName(),0);
if (i >= 0) {
- previous = (NodeImpl) nodes.elementAt(i);
- nodes.insertElementAt(arg,i);
+ previous = (NodeImpl) nodes.get(i);
+ nodes.add(i, arg);
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
- nodes = new Vector(5, 10);
+ nodes = new ArrayList(5);
}
- nodes.insertElementAt(arg, i);
+ nodes.add(i, arg);
}
}
return previous;
@@ -260,20 +266,20 @@
public Node removeNamedItem(String name)
throws DOMException {
- if (isReadOnly()) {
+ if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw
new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
- int i = findNamePoint(name,0);
- if (i < 0) {
+ int i = findNamePoint(name,0);
+ if (i < 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
- NodeImpl n = (NodeImpl)nodes.elementAt(i);
- nodes.removeElementAt(i);
+ NodeImpl n = (NodeImpl)nodes.get(i);
+ nodes.remove(i);
return n;
@@ -286,7 +292,7 @@
* The namespace URI of the node to remove.
* When it is null or an empty string, this
* method behaves like removeNamedItem.
- * @param The local name of the node to remove.
+ * @param name The local name of the node to remove.
* @return Node The node removed from the map if a node with such
* a local name and namespace URI exists.
* @throws NOT_FOUND_ERR: Raised if there is no node named
@@ -296,20 +302,20 @@
public Node removeNamedItemNS(String namespaceURI, String name)
throws DOMException {
- if (isReadOnly()) {
+ if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw
new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
- int i = findNamePoint(namespaceURI, name);
- if (i < 0) {
+ int i = findNamePoint(namespaceURI, name);
+ if (i < 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
- NodeImpl n = (NodeImpl)nodes.elementAt(i);
- nodes.removeElementAt(i);
+ NodeImpl n = (NodeImpl)nodes.get(i);
+ nodes.remove(i);
return n;
@@ -325,25 +331,27 @@
*/
public NamedNodeMapImpl cloneMap(NodeImpl ownerNode) {
- NamedNodeMapImpl newmap = new NamedNodeMapImpl(ownerNode);
+ NamedNodeMapImpl newmap = new NamedNodeMapImpl(ownerNode);
newmap.cloneContent(this);
- return newmap;
+ return newmap;
}
protected void cloneContent(NamedNodeMapImpl srcmap) {
- Vector srcnodes = srcmap.nodes;
+ List srcnodes = srcmap.nodes;
if (srcnodes != null) {
int size = srcnodes.size();
if (size != 0) {
if (nodes == null) {
- nodes = new Vector(size);
+ nodes = new ArrayList(size);
}
- nodes.setSize(size);
+ else {
+ nodes.clear();
+ }
for (int i = 0; i < size; ++i) {
- NodeImpl n = (NodeImpl) srcmap.nodes.elementAt(i);
+ NodeImpl n = (NodeImpl) srcmap.nodes.get(i);
NodeImpl clone = (NodeImpl) n.cloneNode(true);
clone.isSpecified(n.isSpecified());
- nodes.setElementAt(clone, i);
+ nodes.add(clone);
}
}
}
@@ -366,11 +374,11 @@
*/
void setReadOnly(boolean readOnly, boolean deep) {
isReadOnly(readOnly);
- if (deep && nodes != null) {
+ if (deep && nodes != null) {
for (int i = nodes.size() - 1; i >= 0; i--) {
- ((NodeImpl) nodes.elementAt(i)).setReadOnly(readOnly,deep);
+ ((NodeImpl) nodes.get(i)).setReadOnly(readOnly,deep);
}
- }
+ }
} // setReadOnly(boolean,boolean)
/**
@@ -378,7 +386,7 @@
*
*/
boolean getReadOnly() {
- return isReadOnly();
+ return isReadOnly();
} // getReadOnly()
@@ -390,9 +398,10 @@
* NON-DOM
* set the ownerDocument of this node, and the attributes it contains
*/
- void setOwnerDocument(CoreDocumentImpl doc) {
+ protected void setOwnerDocument(CoreDocumentImpl doc) {
if (nodes != null) {
- for (int i = 0; i < nodes.size(); i++) {
+ final int size = nodes.size();
+ for (int i = 0; i < size; ++i) {
((NodeImpl)item(i)).setOwnerDocument(doc);
}
}
@@ -440,15 +449,15 @@
*/
protected int findNamePoint(String name, int start) {
- // Binary search
- int i = 0;
- if (nodes != null) {
+ // Binary search
+ int i = 0;
+ if (nodes != null) {
int first = start;
int last = nodes.size() - 1;
while (first <= last) {
i = (first + last) / 2;
- int test = name.compareTo(((Node)(nodes.elementAt(i))).getNodeName());
+ int test = name.compareTo(((Node)(nodes.get(i))).getNodeName());
if (test == 0) {
return i; // Name found
}
@@ -463,9 +472,9 @@
if (first > i) {
i = first;
}
- }
+ }
- return -1 - i; // not-found has to be encoded.
+ return -1 - i; // not-found has to be encoded.
} // findNamePoint(String):int
@@ -476,20 +485,17 @@
if (nodes == null) return -1;
if (name == null) return -1;
- //if namespace uri is empty string, set it to 'null'
- if (namespaceURI != null) {
- namespaceURI = (namespaceURI.length() == 0)? null : namespaceURI;
- }
- // This is a linear search through the same nodes Vector.
- // The Vector is sorted on the DOM Level 1 nodename.
+ // This is a linear search through the same nodes ArrayList.
+ // The ArrayList is sorted on the DOM Level 1 nodename.
// The DOM Level 2 NS keys are namespaceURI and Localname,
// so we must linear search thru it.
// In addition, to get this to work with nodes without any namespace
// (namespaceURI and localNames are both null) we then use the nodeName
- // as a seconday key.
- for (int i = 0; i < nodes.size(); i++) {
- NodeImpl a = (NodeImpl)nodes.elementAt(i);
+ // as a secondary key.
+ final int size = nodes.size();
+ for (int i = 0; i < size; ++i) {
+ NodeImpl a = (NodeImpl)nodes.get(i);
String aNamespaceURI = a.getNamespaceURI();
String aLocalName = a.getLocalName();
if (namespaceURI == null) {
@@ -513,15 +519,15 @@
// return false
protected boolean precedes(Node a, Node b) {
- if (nodes != null) {
- for (int i = 0; i < nodes.size(); i++) {
- Node n = (Node)nodes.elementAt(i);
- if (n==a) return true;
- if (n==b) return false;
- }
- }
-
- return false;
+ if (nodes != null) {
+ final int size = nodes.size();
+ for (int i = 0; i < size; ++i) {
+ Node n = (Node)nodes.get(i);
+ if (n==a) return true;
+ if (n==b) return false;
+ }
+ }
+ return false;
}
@@ -530,58 +536,58 @@
*/
protected void removeItem(int index) {
if (nodes != null && index < nodes.size()){
- nodes.removeElementAt(index);
+ nodes.remove(index);
}
}
protected Object getItem (int index){
- if (nodes !=null) {
- return nodes.elementAt(index);
+ if (nodes != null) {
+ return nodes.get(index);
}
return null;
}
protected int addItem (Node arg) {
- int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
- if (i >= 0) {
- nodes.setElementAt(arg,i);
- }
+ int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
+ if (i >= 0) {
+ nodes.set(i, arg);
+ }
else {
- // If we can't find by namespaceURI, localName, then we find by
- // nodeName so we know where to insert.
- i = findNamePoint(arg.getNodeName(),0);
+ // If we can't find by namespaceURI, localName, then we find by
+ // nodeName so we know where to insert.
+ i = findNamePoint(arg.getNodeName(),0);
if (i >= 0) {
- nodes.insertElementAt(arg,i);
+ nodes.add(i, arg);
}
else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
- nodes = new Vector(5, 10);
+ nodes = new ArrayList(5);
}
- nodes.insertElementAt(arg, i);
+ nodes.add(i, arg);
}
}
return i;
}
/**
- * NON-DOM: copy content of this map into the specified vector
+ * NON-DOM: copy content of this map into the specified ArrayList
*
- * @param list Vector to copy information into.
+ * @param list ArrayList to copy information into.
* @return A copy of this node named map
*/
- protected Vector cloneMap(Vector list){
+ protected ArrayList cloneMap(ArrayList list) {
if (list == null) {
- list = new Vector(5, 10);
+ list = new ArrayList(5);
}
- list.setSize(0);
+ list.clear();
if (nodes != null) {
- for (int i=0; i and some comment after this
return (fMarkupDepth == 0 && elementDepthIsZeroHook() ) ? XMLEvent.END_ELEMENT : XMLEvent.END_ELEMENT ;
-
+
} else if(scanEndElement() == 0) {
//It is last element of the document
if (elementDepthIsZeroHook()) {
@@ -2920,12 +2921,12 @@
//xxx understand this point once again..
return XMLEvent.END_ELEMENT ;
}
-
+
}
setScannerState(SCANNER_STATE_CONTENT);
return XMLEvent.END_ELEMENT ;
}
-
+
case SCANNER_STATE_COMMENT: { //SCANNER_STATE_COMMENT:
scanComment();
setScannerState(SCANNER_STATE_CONTENT);
@@ -2946,7 +2947,7 @@
case SCANNER_STATE_CDATA :{ //SCANNER_STATE_CDATA: {
//xxx: What if CDATA is the first event
//<>]]>append
-
+
//we should not clear the buffer only when the last state was either SCANNER_STATE_REFERENCE or
//SCANNER_STATE_CHARACTER_DATA or SCANNER_STATE_REFERENCE
if(fIsCoalesce && ( fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData)){
@@ -2971,18 +2972,18 @@
if(fIsCoalesce){
fLastSectionWasCData = true ;
//there might be more data to coalesce.
- return fDriver.next();
+ continue;
}else if(fReportCdataEvent){
return XMLEvent.CDATA;
} else{
return XMLEvent.CHARACTERS;
}
}
-
+
case SCANNER_STATE_REFERENCE :{
fMarkupDepth++;
foundBuiltInRefs = false;
-
+
//we should not clear the buffer only when the last state was either CDATA or
//SCANNER_STATE_CHARACTER_DATA or SCANNER_STATE_REFERENCE
if(fIsCoalesce && ( fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData)){
@@ -3013,18 +3014,18 @@
setScannerState(SCANNER_STATE_CONTENT);
return XMLEvent.CHARACTERS;
}
-
+
//if there was a text declaration, call next() it will be taken care.
if(fScannerState == SCANNER_STATE_TEXT_DECL){
fLastSectionWasEntityReference = true ;
- return fDriver.next();
+ continue;
}
-
+
if(fScannerState == SCANNER_STATE_REFERENCE){
setScannerState(SCANNER_STATE_CONTENT);
if (fReplaceEntityReferences && fEntityStore.isDeclaredEntity(fCurrentEntityName)) {
// Skip the entity reference, we don't care
- return fDriver.next();
+ continue;
}
return XMLEvent.ENTITY_REFERENCE;
}
@@ -3033,9 +3034,9 @@
//set the next possible state to SCANNER_STATE_CONTENT
setScannerState(SCANNER_STATE_CONTENT);
fLastSectionWasEntityReference = true ;
- return fDriver.next();
+ continue;
}
-
+
case SCANNER_STATE_TEXT_DECL: {
// scan text decl
if (fEntityScanner.skipString("()
-
-
+
+
/** private constructor, this class can only be instantiated within this class. Instance of this class should
* be obtained using getEntityScanner() or getEntityScanner(ScannedEntity scannedEntity)
* @see getEntityScanner()
@@ -143,10 +155,10 @@
fEntityManager = entityManager ;
reset(propertyManager);
} // ()
-
-
+
+
// set buffer size:
- public void setBufferSize(int size) {
+ public final void setBufferSize(int size) {
// REVISIT: Buffer size passed to entity scanner
// was not being kept in synch with the actual size
// of the buffers in each scanned entity. If any
@@ -159,7 +171,7 @@
// minimum. -- mrglavas
fBufferSize = size;
}
-
+
/**
* Resets the components.
*/
@@ -171,7 +183,7 @@
whiteSpaceInfoNeeded = true;
listeners.clear();
}
-
+
/**
* Resets the component. The component can query the component manager
* about any features and properties that affect the operation of the
@@ -188,7 +200,7 @@
*/
public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {
-
+
//System.out.println(" this is being called");
// xerces features
try {
@@ -196,7 +208,7 @@
} catch (XMLConfigurationException e) {
fAllowJavaEncodings = false;
}
-
+
//xerces properties
fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
@@ -205,42 +217,50 @@
whiteSpaceInfoNeeded = true;
listeners.clear();
} // reset(XMLComponentManager)
-
-
- public void reset(SymbolTable symbolTable, XMLEntityManager entityManager,
+
+
+ public final void reset(SymbolTable symbolTable, XMLEntityManager entityManager,
XMLErrorReporter reporter) {
fCurrentEntity = null;
fSymbolTable = symbolTable;
fEntityManager = entityManager;
fErrorReporter = reporter;
}
-
+
/**
* Returns the XML version of the current entity. This will normally be the
* value from the XML or text declaration or defaulted by the parser. Note that
- * that this value may be different than the version of the processing rules
+ * that this value may be different than the version of the processing rules
* applied to the current entity. For instance, an XML 1.1 document may refer to
- * XML 1.0 entities. In such a case the rules of XML 1.1 are applied to the entire
+ * XML 1.0 entities. In such a case the rules of XML 1.1 are applied to the entire
* document. Also note that, for a given entity, this value can only be considered
* final once the XML or text declaration has been read or once it has been
* determined that there is no such declaration.
*/
- public String getXMLVersion() {
+ public final String getXMLVersion() {
if (fCurrentEntity != null) {
return fCurrentEntity.xmlVersion;
}
return null;
} // getXMLVersion():String
+
+ /**
+ * Sets the XML version. This method is used by the
+ * scanners to report the value of the version pseudo-attribute
+ * in an XML or text declaration.
+ *
+ * @param xmlVersion the XML version of the current entity
+ */
+ public final void setXMLVersion(String xmlVersion) {
+ fCurrentEntity.xmlVersion = xmlVersion;
+ } // setXMLVersion(String)
- void setXMLVersion(String version) {
- fCurrentEntity.xmlVersion = version;
- }
-
+
/** set the instance of current scanned entity.
* @param ScannedEntity
*/
-
- public void setCurrentEntity(Entity.ScannedEntity scannedEntity){
+
+ public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
fCurrentEntity = scannedEntity ;
if(fCurrentEntity != null){
isExternal = fCurrentEntity.isExternal();
@@ -248,112 +268,126 @@
System.out.println("Current Entity is "+scannedEntity.name);
}
}
-
+
public Entity.ScannedEntity getCurrentEntity(){
return fCurrentEntity ;
}
//
// XMLEntityReader methods
//
-
+
/**
* Returns the base system identifier of the currently scanned
* entity, or null if none is available.
*/
- public String getBaseSystemId() {
+ public final String getBaseSystemId() {
return (fCurrentEntity != null && fCurrentEntity.entityLocation != null) ? fCurrentEntity.entityLocation.getExpandedSystemId() : null;
} // getBaseSystemId():String
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setBaseSystemId(String)
*/
public void setBaseSystemId(String systemId) {
//no-op
}
-
+
///////////// Locator methods start.
- public int getLineNumber(){
+ public final int getLineNumber(){
//if the entity is closed, we should return -1
//xxx at first place why such call should be there...
return fCurrentEntity != null ? fCurrentEntity.lineNumber : -1 ;
}
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLLocator#setLineNumber(int)
*/
public void setLineNumber(int line) {
//no-op
}
-
-
- public int getColumnNumber(){
+
+
+ public final int getColumnNumber(){
//if the entity is closed, we should return -1
//xxx at first place why such call should be there...
return fCurrentEntity != null ? fCurrentEntity.columnNumber : -1 ;
}
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLLocator#setColumnNumber(int)
*/
public void setColumnNumber(int col) {
// no-op
}
-
-
- public int getCharacterOffset(){
+
+
+ public final int getCharacterOffset(){
return fCurrentEntity != null ? fCurrentEntity.fTotalCountTillLastLoad + fCurrentEntity.position : -1 ;
}
-
+
/** Returns the expanded system identifier. */
- public String getExpandedSystemId() {
+ public final String getExpandedSystemId() {
return (fCurrentEntity != null && fCurrentEntity.entityLocation != null) ? fCurrentEntity.entityLocation.getExpandedSystemId() : null;
}
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setExpandedSystemId(String)
*/
public void setExpandedSystemId(String systemId) {
//no-op
}
-
+
/** Returns the literal system identifier. */
- public String getLiteralSystemId() {
+ public final String getLiteralSystemId() {
return (fCurrentEntity != null && fCurrentEntity.entityLocation != null) ? fCurrentEntity.entityLocation.getLiteralSystemId() : null;
}
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setLiteralSystemId(String)
*/
public void setLiteralSystemId(String systemId) {
//no-op
}
-
+
/** Returns the public identifier. */
- public String getPublicId() {
+ public final String getPublicId() {
return (fCurrentEntity != null && fCurrentEntity.entityLocation != null) ? fCurrentEntity.entityLocation.getPublicId() : null;
}
-
+
/**
* @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setPublicId(String)
*/
public void setPublicId(String publicId) {
//no-op
}
-
+
///////////////// Locator methods finished.
-
+
/** the version of the current entity being scanned */
public void setVersion(String version){
fCurrentEntity.version = version;
}
-
+
public String getVersion(){
- return fCurrentEntity.version ;
+ if (fCurrentEntity != null)
+ return fCurrentEntity.version ;
+ return null;
}
+
+ /**
+ * Returns the encoding of the current entity.
+ * Note that, for a given entity, this value can only be
+ * considered final once the encoding declaration has been read (or once it
+ * has been determined that there is no such declaration) since, no encoding
+ * having been specified on the XMLInputSource, the parser
+ * will make an initial "guess" which could be in error.
+ */
+ public final String getEncoding() {
+ if (fCurrentEntity != null) {
+ return fCurrentEntity.encoding;
+ }
+ return null;
+ } // getEncoding():String
- public String getEncoding(){
- return fCurrentEntity.encoding ;
- }
/**
* Sets the encoding of the scanner. This method is used by the
* scanners if the XMLDecl or TextDecl line contains an encoding
@@ -372,12 +406,12 @@
*
* @see com.sun.org.apache.xerces.internal.util.EncodingMap
*/
- public void setEncoding(String encoding) throws IOException {
-
+ public final void setEncoding(String encoding) throws IOException {
+
if (DEBUG_ENCODINGS) {
System.out.println("$$$ setEncoding: "+encoding);
}
-
+
if (fCurrentEntity.stream != null) {
// if the encoding is the same, don't change the reader and
// re-use the original reader used by the OneCharReader
@@ -421,20 +455,20 @@
//fCurrentEntity.stream.reset();
fCurrentEntity.reader = createReader(fCurrentEntity.stream, encoding, null);
fCurrentEntity.encoding = encoding;
-
+
} else {
if (DEBUG_ENCODINGS)
System.out.println("$$$ reusing old reader on stream");
}
}
-
+
} // setEncoding(String)
-
+
/** Returns true if the current entity being scanned is external. */
- public boolean isExternal() {
+ public final boolean isExternal() {
return fCurrentEntity.isExternal();
} // isExternal():boolean
-
+
public int getChar(int relative) throws IOException{
if(arrangeCapacity(relative + 1, false)){
return fCurrentEntity.ch[fCurrentEntity.position + relative];
@@ -442,7 +476,7 @@
return -1;
}
}//getChar()
-
+
/**
* Returns the next character on the input.
*
@@ -457,16 +491,16 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// peek at character
int c = fCurrentEntity.ch[fCurrentEntity.position];
-
+
// return peeked character
if (DEBUG_BUFFER) {
System.out.print(")peekChar: ");
@@ -482,9 +516,9 @@
} else {
return c;
}
-
+
} // peekChar():int
-
+
/**
* Returns the next character on the input.
*
@@ -499,13 +533,13 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// scan character
int c = fCurrentEntity.ch[fCurrentEntity.position++];
if (c == '\n' ||
@@ -524,7 +558,7 @@
c = '\n';
}
}
-
+
// return character that was scanned
if (DEBUG_BUFFER) {
System.out.print(")scanChar: ");
@@ -533,9 +567,9 @@
}
fCurrentEntity.columnNumber++;
return c;
-
+
} // scanChar():int
-
+
/**
* Returns a string matching the NMTOKEN production appearing immediately
* on the input as a symbol, or null if NMTOKEN Name string is present.
@@ -557,13 +591,13 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// scan nmtoken
int offset = fCurrentEntity.position;
boolean vc = false;
@@ -577,7 +611,7 @@
vc = XMLChar.isName(c);
}
if(!vc)break;
-
+
if (++fCurrentEntity.position == fCurrentEntity.count) {
int length = fCurrentEntity.position - offset;
invokeListeners(length);
@@ -600,7 +634,7 @@
}
int length = fCurrentEntity.position - offset;
fCurrentEntity.columnNumber += length;
-
+
// return nmtoken
String symbol = null;
if (length > 0) {
@@ -612,9 +646,9 @@
System.out.println(" -> "+String.valueOf(symbol));
}
return symbol;
-
+
} // scanNmtoken():String
-
+
/**
* Returns a string matching the Name production appearing immediately
* on the input as a symbol, or null if no Name string is present.
@@ -637,13 +671,13 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// scan name
int offset = fCurrentEntity.position;
if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
@@ -654,7 +688,7 @@
if (load(1, false)) {
fCurrentEntity.columnNumber++;
String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
-
+
if (DEBUG_BUFFER) {
System.out.print(")scanName: ");
print();
@@ -696,7 +730,7 @@
}
int length = fCurrentEntity.position - offset;
fCurrentEntity.columnNumber += length;
-
+
// return name
String symbol;
if (length > 0) {
@@ -709,9 +743,9 @@
System.out.println(" -> "+String.valueOf(symbol));
}
return symbol;
-
+
} // scanName():String
-
+
/**
* Scans a qualified name from the input, setting the fields of the
* QName structure appropriately.
@@ -740,26 +774,26 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// scan qualified name
int offset = fCurrentEntity.position;
-
+
//making a check if if the specified character is a valid name start character
//as defined by production [5] in the XML 1.0 specification.
// Name ::= (Letter | '_' | ':') (NameChar)*
-
+
if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
if (++fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(1);
fCurrentEntity.ch[0] = fCurrentEntity.ch[offset];
offset = 0;
-
+
if (load(1, false)) {
fCurrentEntity.columnNumber++;
//adding into symbol table.
@@ -777,7 +811,7 @@
int index = -1;
boolean vc = false;
while ( true){
-
+
//XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) ;
char c = fCurrentEntity.ch[fCurrentEntity.position];
if(c < 127){
@@ -822,7 +856,7 @@
String localpart = null;
String rawname = fSymbolTable.addSymbol(fCurrentEntity.ch,
offset, length);
-
+
if (index != -1) {
int prefixLength = index - offset;
prefix = fSymbolTable.addSymbol(fCurrentEntity.ch,
@@ -830,7 +864,7 @@
int len = length - prefixLength - 1;
localpart = fSymbolTable.addSymbol(fCurrentEntity.ch,
index + 1, len);
-
+
} else {
localpart = rawname;
}
@@ -843,7 +877,7 @@
return true;
}
}
-
+
// no qualified name found
if (DEBUG_BUFFER) {
System.out.print(")scanQName, "+qname+": ");
@@ -851,9 +885,9 @@
System.out.println(" -> false");
}
return false;
-
+
} // scanQName(QName):boolean
-
+
/**
* CHANGED:
* Scans a range of parsed character data, This function appends the character data to
@@ -882,7 +916,7 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
@@ -893,7 +927,7 @@
load(1, false);
fCurrentEntity.position = 0;
}
-
+
// normalize newlines
int offset = fCurrentEntity.position;
int c = fCurrentEntity.ch[offset];
@@ -965,7 +999,7 @@
System.out.println();
}
}
-
+
while (fCurrentEntity.position < fCurrentEntity.count) {
c = fCurrentEntity.ch[fCurrentEntity.position++];
if (!XMLChar.isContent(c)) {
@@ -975,7 +1009,7 @@
}
int length = fCurrentEntity.position - offset;
fCurrentEntity.columnNumber += length - newlines;
-
+
//CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
//on buffering the data..
content.setValues(fCurrentEntity.ch, offset, length);
@@ -997,9 +1031,9 @@
System.out.println(" -> '"+(char)c+"'");
}
return c;
-
+
} // scanContent(XMLString):int
-
+
/**
* Scans a range of attribute value data, setting the fields of the
* XMLString structure, appropriately.
@@ -1042,11 +1076,11 @@
} else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
invokeListeners(0);
fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
-
+
load(1, false);
fCurrentEntity.position = 0;
}
-
+
// normalize newlines
int offset = fCurrentEntity.position;
int c = fCurrentEntity.ch[offset];
@@ -1111,7 +1145,7 @@
fCurrentEntity.ch[i] = '\n';
whiteSpaceLookup[whiteSpaceLen++]=i;
}
-
+
int length = fCurrentEntity.position - offset;
if (fCurrentEntity.position == fCurrentEntity.count - 1) {
content.setValues(fCurrentEntity.ch, offset, length);
@@ -1128,8 +1162,8 @@
System.out.println();
}
}
-
- // scan literal value
+
+ // scan literal value
while (fCurrentEntity.position < fCurrentEntity.count) {
c = fCurrentEntity.ch[fCurrentEntity.position++];
if ((c == quote &&
@@ -1137,7 +1171,7 @@
|| c == '%' || !XMLChar.isContent(c)) {
fCurrentEntity.position--;
break;
- }
+ }
if(whiteSpaceInfoNeeded){
if(c == 0x20 || c == 0x9){
if(whiteSpaceLen < whiteSpaceLookup.length){
@@ -1154,7 +1188,7 @@
int length = fCurrentEntity.position - offset;
fCurrentEntity.columnNumber += length - newlines;
content.setValues(fCurrentEntity.ch, offset, length);
-
+
// return next character
if (fCurrentEntity.position != fCurrentEntity.count) {
c = fCurrentEntity.ch[fCurrentEntity.position];
@@ -1173,9 +1207,9 @@
System.out.println(" -> '"+(char)c+"'");
}
return c;
-
+
} // scanLiteral(int,XMLString):int
-
+
//CHANGED:
/**
* Scans a range of character data up to the specified delimiter,
@@ -1193,7 +1227,7 @@
*
* @param delimiter The string that signifies the end of the character
* data to be scanned.
- * @param data The data structure to fill. Data will be appendd to the current buffer.
+ * @param buffer The XMLStringBuffer to fill.
*
* @return Returns true if there is more data to scan, false otherwise.
*
@@ -1202,7 +1236,7 @@
*/
public boolean scanData(String delimiter, XMLStringBuffer buffer)
throws IOException {
-
+
boolean done = false;
int delimLen = delimiter.length();
char charAt0 = delimiter.charAt(0);
@@ -1212,7 +1246,7 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1238,15 +1272,15 @@
if (fCurrentEntity.position > fCurrentEntity.count - delimLen) {
// something must be wrong with the input: e.g., file ends in an unterminated comment
int length = fCurrentEntity.count - fCurrentEntity.position;
- buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
+ buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
fCurrentEntity.columnNumber += fCurrentEntity.count;
fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
fCurrentEntity.position = fCurrentEntity.count;
fCurrentEntity.startPosition = fCurrentEntity.count;
load(0, true);
return false;
- }
-
+ }
+
// normalize newlines
int offset = fCurrentEntity.position;
int c = fCurrentEntity.ch[offset];
@@ -1316,7 +1350,7 @@
System.out.println();
}
}
-
+
// iterate over buffer looking for delimiter
OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
c = fCurrentEntity.ch[fCurrentEntity.position++];
@@ -1355,7 +1389,7 @@
length -= delimLen;
}
buffer.append(fCurrentEntity.ch, offset, length);
-
+
// return true if string was skipped
if (DEBUG_BUFFER) {
System.out.print(")scanData: ");
@@ -1364,9 +1398,9 @@
}
} while (!done);
return !done;
-
+
} // scanData(String,XMLString)
-
+
/**
* Skips a character appearing immediately on the input.
*
@@ -1386,13 +1420,13 @@
print();
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
}
-
+
// skip character
int cc = fCurrentEntity.ch[fCurrentEntity.position];
if (cc == c) {
@@ -1429,7 +1463,7 @@
}
return true;
}
-
+
// character was not skipped
if (DEBUG_BUFFER) {
System.out.print(")skipChar, '"+(char)c+"': ");
@@ -1437,9 +1471,9 @@
System.out.println(" -> false");
}
return false;
-
+
} // skipChar(int):boolean
-
+
public boolean isSpace(char ch){
return (ch == ' ') || (ch == '\n') || (ch == '\t') || (ch == '\r');
}
@@ -1468,7 +1502,7 @@
invokeListeners(0);
load(0, true);
}
-
+
//we are doing this check only in skipSpace() because it is called by
//fMiscDispatcher and we want the parser to exit gracefully when document
//is well-formed.
@@ -1478,7 +1512,7 @@
if(fCurrentEntity == null){
return false ;
}
-
+
// skip spaces
int c = fCurrentEntity.ch[fCurrentEntity.position];
if (XMLChar.isSpace(c)) {
@@ -1514,22 +1548,22 @@
if (!entityChanged){
fCurrentEntity.position++;
}
-
+
if (fCurrentEntity.position == fCurrentEntity.count) {
invokeListeners(0);
load(0, true);
-
+
//we are doing this check only in skipSpace() because it is called by
//fMiscDispatcher and we want the parser to exit gracefully when document
//is well-formed.
-
+
//it is possible that end of document is reached and
//fCurrentEntity becomes null
//nothing was read so entity changed 'false' should be returned.
if(fCurrentEntity == null){
return true ;
}
-
+
}
} while (XMLChar.isSpace(c = fCurrentEntity.ch[fCurrentEntity.position]));
if (DEBUG_BUFFER) {
@@ -1539,7 +1573,7 @@
}
return true;
}
-
+
// no spaces were found
if (DEBUG_BUFFER) {
System.out.print(")skipSpaces: ");
@@ -1547,10 +1581,10 @@
System.out.println(" -> false");
}
return false;
-
+
} // skipSpaces():boolean
-
-
+
+
/**
* @param legnth This function checks that following number of characters are available.
* to the underlying buffer.
@@ -1559,7 +1593,7 @@
public boolean arrangeCapacity(int length) throws IOException{
return arrangeCapacity(length, false);
}
-
+
/**
* @param legnth This function checks that following number of characters are available.
* to the underlying buffer.
@@ -1589,7 +1623,7 @@
fCurrentEntity.count = fCurrentEntity.count - fCurrentEntity.position;
fCurrentEntity.position = 0;
}
-
+
if((fCurrentEntity.count - fCurrentEntity.position) < length){
int pos = fCurrentEntity.position;
invokeListeners(pos);
@@ -1604,7 +1638,7 @@
}
}
//load changes the position.. set it back to the point where we started.
-
+
//after loading check again.
if((fCurrentEntity.count - fCurrentEntity.position) >= length) {
return true;
@@ -1612,7 +1646,7 @@
return false;
}
}
-
+
/**
* Skips the specified string appearing immediately on the input.
*
@@ -1627,9 +1661,9 @@
* @throws EOFException Thrown on end of file.
*/
public boolean skipString(String s) throws IOException {
-
+
final int length = s.length();
-
+
//first make sure that required capacity is avaible
if(arrangeCapacity(length, false)){
final int beforeSkip = fCurrentEntity.position ;
@@ -1638,7 +1672,7 @@
System.out.println("skipString,length = " + s + "," + length);
System.out.println("Buffer string to be skipped = " + new String(fCurrentEntity.ch, beforeSkip, length));
}
-
+
//s.charAt() indexes are 0 to 'Length -1' based.
int i = length - 1 ;
//check from reverse
@@ -1650,23 +1684,23 @@
}
}
}
-
+
return false;
} // skipString(String):boolean
-
+
public boolean skipString(char [] s) throws IOException {
-
+
final int length = s.length;
//first make sure that required capacity is avaible
if(arrangeCapacity(length, false)){
int beforeSkip = fCurrentEntity.position ;
int afterSkip = fCurrentEntity.position + length ;
-
+
if(DEBUG_SKIP_STRING){
System.out.println("skipString,length = " + new String(s) + "," + length);
System.out.println("skipString,length = " + new String(s) + "," + length);
}
-
+
for(int i=0;i XMLEntityManager.DEFAULT_XMLDECL_BUFFER_SIZE) {
+ length = XMLEntityManager.DEFAULT_XMLDECL_BUFFER_SIZE;
+ }
if (DEBUG_BUFFER) System.out.println(" length to try to read: "+length);
int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset, length);
if (DEBUG_BUFFER) System.out.println(" length actually read: "+count);
-
+
// reset count and position
boolean entityChanged = false;
if (count != -1) {
@@ -1734,31 +1769,31 @@
fCurrentEntity.count = offset;
fCurrentEntity.position = offset;
entityChanged = true;
-
+
if (changeEntity) {
//notify the entity manager about the end of entity
fEntityManager.endEntity();
//return if the current entity becomes null
if(fCurrentEntity == null){
- return true ;
+ throw END_OF_DOCUMENT_ENTITY;
}
// handle the trailing edges
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, true);
}
}
-
+
}
if (DEBUG_BUFFER) {
System.out.print(")load, "+offset+": ");
print();
System.out.println();
}
-
+
return entityChanged;
-
+
} // load(int, boolean):boolean
-
+
/**
* Creates a reader capable of reading the given input stream in
* the specified encoding.
@@ -1777,12 +1812,12 @@
*/
protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian)
throws IOException {
-
+
// normalize encoding name
if (encoding == null) {
encoding = "UTF-8";
}
-
+
// try to use an optimized reader
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-8")) {
@@ -1827,7 +1862,7 @@
XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
}
-
+
// check for valid name
boolean validIANA = XMLChar.isValidIANAEncoding(encoding);
boolean validJava = XMLChar.isValidJavaEncoding(encoding);
@@ -1846,7 +1881,7 @@
// on. -Ac
encoding = "ISO-8859-1";
}
-
+
// try to use a Java reader
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null) {
@@ -1867,7 +1902,7 @@
}
return new ASCIIReader(inputStream, fBufferSize, fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), fErrorReporter.getLocale());
}
-
+
if (DEBUG_ENCODINGS) {
System.out.print("$$$ creating Java InputStreamReader: encoding="+javaEncoding);
if (javaEncoding == encoding) {
@@ -1876,9 +1911,9 @@
System.out.println();
}
return new InputStreamReader(inputStream, javaEncoding);
-
+
} // createReader(InputStream,String, Boolean): Reader
-
+
/**
* Returns the IANA encoding name that is auto-detected from
* the bytes specified, with the endian-ness of that encoding where appropriate.
@@ -1890,11 +1925,11 @@
* if it's little-endian, and null if the distinction isn't relevant.
*/
protected Object[] getEncodingName(byte[] b4, int count) {
-
+
if (count < 2) {
return new Object[]{"UTF-8", null};
}
-
+
// UTF-16, with BOM
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
@@ -1906,25 +1941,25 @@
// UTF-16, little-endian
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 new Object [] {"UTF-8", null};
}
-
+
// UTF-8 with a BOM
int b2 = b4[2] & 0xFF;
if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
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 new Object [] {"UTF-8", null};
}
-
+
// other encodings
int b3 = b4[3] & 0xFF;
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
@@ -1961,12 +1996,12 @@
// a la xerces1, return CP037 instead of EBCDIC here
return new Object [] {"CP037", null};
}
-
+
// default encoding
return new Object [] {"UTF-8", null};
-
+
} // getEncodingName(byte[],int):Object[]
-
+
/**
* xxx not removing endEntity() so that i remember that we need to implement it.
* Ends an entity.
@@ -2026,7 +2061,7 @@
}
}
}
-
+
/**
* Registers the listener object and provides callback.
* @param listener listener to which call back should be provided when scanner buffer
@@ -2036,7 +2071,7 @@
if(!listeners.contains(listener))
listeners.add(listener);
}
-
+
/**
*
* @param loadPos Starting position from which new data is being loaded into scanner buffer.
@@ -2047,7 +2082,7 @@
listener.refresh(loadPos);
}
}
-
+
/**
* Skips space characters appearing immediately on the input that would
* match non-terminal S (0x09, 0x0A, 0x0D, 0x20) before end of line
@@ -2065,18 +2100,18 @@
*
* @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
*/
- public boolean skipDeclSpaces() throws IOException {
+ public final boolean skipDeclSpaces() throws IOException {
if (DEBUG_BUFFER) {
System.out.print("(skipDeclSpaces: ");
//XMLEntityManager.print(fCurrentEntity);
System.out.println();
}
-
+
// load more characters, if needed
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, true);
}
-
+
// skip spaces
int c = fCurrentEntity.ch[fCurrentEntity.position];
if (XMLChar.isSpace(c)) {
@@ -2127,7 +2162,7 @@
}
return true;
}
-
+
// no spaces were found
if (DEBUG_BUFFER) {
System.out.print(")skipDeclSpaces: ");
@@ -2135,8 +2170,9 @@
System.out.println(" -> false");
}
return false;
-
+
} // skipDeclSpaces():boolean
+
+
+} // class XMLEntityScanner
-
-} // class XMLEntityScanner
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java Wed Sep 28 17:36:24 2011 +0100
@@ -60,7 +60,6 @@
*/
package com.sun.org.apache.xerces.internal.impl;
-
import java.util.Hashtable;
import java.util.Locale;
@@ -112,6 +111,7 @@
* @author Eric Ye, IBM
* @author Andy Clark, IBM
*
+ * @version $Id: XMLErrorReporter.java,v 1.5 2010-11-01 04:39:41 joehw Exp $
*/
public class XMLErrorReporter
implements XMLComponent {
@@ -208,6 +208,9 @@
*/
protected XMLErrorHandler fDefaultErrorHandler;
+ /** A SAX proxy to the error handler contained in this error reporter. */
+ private ErrorHandler fSaxProxy = null;
+
//
// Constructors
//
@@ -311,15 +314,38 @@
* @param arguments The replacement arguments for the error message,
* if needed.
* @param severity The severity of the error.
+ * @return The formatted error message.
*
* @see #SEVERITY_WARNING
* @see #SEVERITY_ERROR
* @see #SEVERITY_FATAL_ERROR
*/
- public void reportError(String domain, String key, Object[] arguments,
+ public String reportError(String domain, String key, Object[] arguments,
short severity) throws XNIException {
- reportError(fLocator, domain, key, arguments, severity);
- } // reportError(String,String,Object[],short)
+ return reportError(fLocator, domain, key, arguments, severity);
+ } // reportError(String,String,Object[],short):String
+
+ /**
+ * Reports an error. The error message passed to the error handler
+ * is formatted for the locale by the message formatter installed
+ * for the specified error domain.
+ *
+ * @param domain The error domain.
+ * @param key The key of the error message.
+ * @param arguments The replacement arguments for the error message,
+ * if needed.
+ * @param severity The severity of the error.
+ * @param exception The exception to wrap.
+ * @return The formatted error message.
+ *
+ * @see #SEVERITY_WARNING
+ * @see #SEVERITY_ERROR
+ * @see #SEVERITY_FATAL_ERROR
+ */
+ public String reportError(String domain, String key, Object[] arguments,
+ short severity, Exception exception) throws XNIException {
+ return reportError(fLocator, domain, key, arguments, severity, exception);
+ } // reportError(String,String,Object[],short,Exception):String
/**
* Reports an error at a specific location.
@@ -330,14 +356,37 @@
* @param arguments The replacement arguments for the error message,
* if needed.
* @param severity The severity of the error.
+ * @return The formatted error message.
*
* @see #SEVERITY_WARNING
* @see #SEVERITY_ERROR
* @see #SEVERITY_FATAL_ERROR
*/
- public void reportError(XMLLocator location,
+ public String reportError(XMLLocator location,
+ String domain, String key, Object[] arguments,
+ short severity) throws XNIException {
+ return reportError(location, domain, key, arguments, severity, null);
+ } // reportError(XMLLocator,String,String,Object[],short):String
+
+ /**
+ * Reports an error at a specific location.
+ *
+ * @param location The error location.
+ * @param domain The error domain.
+ * @param key The key of the error message.
+ * @param arguments The replacement arguments for the error message,
+ * if needed.
+ * @param severity The severity of the error.
+ * @param exception The exception to wrap.
+ * @return The formatted error message.
+ *
+ * @see #SEVERITY_WARNING
+ * @see #SEVERITY_ERROR
+ * @see #SEVERITY_FATAL_ERROR
+ */
+ public String reportError(XMLLocator location,
String domain, String key, Object[] arguments,
- short severity) throws XNIException {
+ short severity, Exception exception) throws XNIException {
// REVISIT: [Q] Should we do anything about invalid severity
// parameter? -Ac
@@ -365,7 +414,8 @@
}
message = str.toString();
}
- XMLParseException parseException =
+ XMLParseException parseException = (exception != null) ?
+ new XMLParseException(location, message, exception) :
new XMLParseException(location, message);
// get error handler
@@ -395,8 +445,9 @@
break;
}
}
+ return message;
- } // reportError(XMLLocator,String,String,Object[],short)
+ } // reportError(XMLLocator,String,String,Object[],short,Exception):String
//
// XMLComponent methods
@@ -488,7 +539,7 @@
//
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
- final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
+ final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
//
// http://apache.org/xml/features/continue-after-fatal-error
@@ -589,20 +640,19 @@
return fErrorHandler;
}
-
- private ErrorHandler fSaxProxy = null;
-
/**
* Gets the internal XMLErrorHandler
* as SAX ErrorHandler.
*/
public ErrorHandler getSAXErrorHandler() {
- if( fSaxProxy==null )
+ if (fSaxProxy == null) {
fSaxProxy = new ErrorHandlerProxy() {
protected XMLErrorHandler getErrorHandler() {
return fErrorHandler;
}
};
+ }
return fSaxProxy;
}
+
} // class XMLErrorReporter
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -19,18 +19,21 @@
*/
package com.sun.org.apache.xerces.internal.impl.dv.util;
+import java.util.AbstractList;
+
+import com.sun.org.apache.xerces.internal.xs.XSException;
import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList;
-import com.sun.org.apache.xerces.internal.xs.XSException;
/**
* Implementation of com.sun.org.apache.xerces.internal.xs.datatypes.ByteList
.
*
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Ankit Pasricha, IBM
- *
+ *
+ * @version $Id: ByteListImpl.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
-public class ByteListImpl implements ByteList {
+public class ByteListImpl extends AbstractList implements ByteList {
// actually data stored in a byte array
protected final byte[] data;
@@ -86,4 +89,19 @@
return data[index];
}
+ /*
+ * List methods
+ */
+
+ public Object get(int index) {
+ if (index >= 0 && index < data.length) {
+ return new Byte(data[index]);
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
}
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,8 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
+import java.math.BigDecimal;
+
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
@@ -38,463 +40,464 @@
* two parser instances at the same time, then the same simple type
* decl object can be used to validate two strings at the same time.
* -SG
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*
* @author Elena Litani
* @author Len Berman
* @author Gopal Sharma, SUN Microsystems Inc.
*
+ * @version $Id: AbstractDateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public abstract class AbstractDateTimeDV extends TypeValidator {
- //debugging
- private static final boolean DEBUG=false;
+ //debugging
+ private static final boolean DEBUG=false;
- //define shared variables for date/time
+ //define shared variables for date/time
- //define constants to be used in assigning default values for
- //all date/time excluding duration
- protected final static int YEAR=2000;
- protected final static int MONTH=01;
- protected final static int DAY = 01;
+ //define constants to be used in assigning default values for
+ //all date/time excluding duration
+ protected final static int YEAR=2000;
+ protected final static int MONTH=01;
+ protected final static int DAY = 01;
- protected DatatypeFactory factory = new DatatypeFactoryImpl();
+ protected static final DatatypeFactory datatypeFactory = new DatatypeFactoryImpl();
- public short getAllowedFacets(){
- return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE );
- }//getAllowedFacets()
+ public short getAllowedFacets(){
+ return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE );
+ }//getAllowedFacets()
- // distinguishes between identity and equality for date/time values
- // ie: two values representing the same "moment in time" but with different
- // remembered timezones are now equal but not identical.
- public boolean isIdentical (Object value1, Object value2) {
- if (!(value1 instanceof DateTimeData) || !(value2 instanceof DateTimeData)) {
- return false;
- }
+ // distinguishes between identity and equality for date/time values
+ // ie: two values representing the same "moment in time" but with different
+ // remembered timezones are now equal but not identical.
+ public boolean isIdentical (Object value1, Object value2) {
+ if (!(value1 instanceof DateTimeData) || !(value2 instanceof DateTimeData)) {
+ return false;
+ }
- DateTimeData v1 = (DateTimeData)value1;
- DateTimeData v2 = (DateTimeData)value2;
+ DateTimeData v1 = (DateTimeData)value1;
+ DateTimeData v2 = (DateTimeData)value2;
- // original timezones must be the same in addition to date/time values
- // being 'equal'
- if ((v1.timezoneHr == v2.timezoneHr) && (v1.timezoneMin == v2.timezoneMin)) {
- return v1.equals(v2);
- }
+ // original timezones must be the same in addition to date/time values
+ // being 'equal'
+ if ((v1.timezoneHr == v2.timezoneHr) && (v1.timezoneMin == v2.timezoneMin)) {
+ return v1.equals(v2);
+ }
- return false;
- }//isIdentical()
+ return false;
+ }//isIdentical()
- // the parameters are in compiled form (from getActualValue)
- public int compare (Object value1, Object value2) {
- return compareDates(((DateTimeData)value1),
- ((DateTimeData)value2), true);
- }//compare()
+ // the parameters are in compiled form (from getActualValue)
+ public int compare (Object value1, Object value2) {
+ return compareDates(((DateTimeData)value1),
+ ((DateTimeData)value2), true);
+ }//compare()
- /**
- * Compare algorithm described in dateDime (3.2.7).
- * Duration datatype overwrites this method
- *
- * @param date1 normalized date representation of the first value
- * @param date2 normalized date representation of the second value
- * @param strict
- * @return less, greater, less_equal, greater_equal, equal
- */
- protected short compareDates(DateTimeData date1, DateTimeData date2, boolean strict) {
- if (date1.utc == date2.utc) {
- return compareOrder(date1, date2);
- }
- short c1, c2;
+ /**
+ * Compare algorithm described in dateDime (3.2.7).
+ * Duration datatype overwrites this method
+ *
+ * @param date1 normalized date representation of the first value
+ * @param date2 normalized date representation of the second value
+ * @param strict
+ * @return less, greater, less_equal, greater_equal, equal
+ */
+ protected short compareDates(DateTimeData date1, DateTimeData date2, boolean strict) {
+ if (date1.utc == date2.utc) {
+ return compareOrder(date1, date2);
+ }
+ short c1, c2;
- DateTimeData tempDate = new DateTimeData(null, this);
+ DateTimeData tempDate = new DateTimeData(null, this);
- if ( date1.utc=='Z' ) {
+ if ( date1.utc=='Z' ) {
- //compare date1<=date1<=(date2 with time zone -14)
- //
- cloneDate(date2, tempDate); //clones date1 value to global temporary storage: fTempDate
- tempDate.timezoneHr=14;
- tempDate.timezoneMin = 0;
- tempDate.utc='+';
- normalize(tempDate);
- c1 = compareOrder(date1, tempDate);
- if (c1 == LESS_THAN)
- return c1;
+ //compare date1<=date1<=(date2 with time zone -14)
+ //
+ cloneDate(date2, tempDate); //clones date1 value to global temporary storage: fTempDate
+ tempDate.timezoneHr=14;
+ tempDate.timezoneMin = 0;
+ tempDate.utc='+';
+ normalize(tempDate);
+ c1 = compareOrder(date1, tempDate);
+ if (c1 == LESS_THAN)
+ return c1;
- //compare date1>=(date2 with time zone +14)
- //
- cloneDate(date2, tempDate); //clones date1 value to global temporary storage: tempDate
- tempDate.timezoneHr = -14;
- tempDate.timezoneMin = 0;
- tempDate.utc='-';
- normalize(tempDate);
- c2 = compareOrder(date1, tempDate);
- if (c2 == GREATER_THAN)
- return c2;
+ //compare date1>=(date2 with time zone +14)
+ //
+ cloneDate(date2, tempDate); //clones date1 value to global temporary storage: tempDate
+ tempDate.timezoneHr = -14;
+ tempDate.timezoneMin = 0;
+ tempDate.utc='-';
+ normalize(tempDate);
+ c2 = compareOrder(date1, tempDate);
+ if (c2 == GREATER_THAN)
+ return c2;
- return INDETERMINATE;
- }
- else if ( date2.utc=='Z' ) {
+ return INDETERMINATE;
+ }
+ else if ( date2.utc=='Z' ) {
- //compare (date1 with time zone -14)<=date2
- //
- cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
- tempDate.timezoneHr = -14;
- tempDate.timezoneMin = 0;
- tempDate.utc='-';
- if (DEBUG) {
- System.out.println("tempDate=" + dateToString(tempDate));
- }
- normalize(tempDate);
- c1 = compareOrder(tempDate, date2);
- if (DEBUG) {
- System.out.println("date=" + dateToString(date2));
- System.out.println("tempDate=" + dateToString(tempDate));
- }
- if (c1 == LESS_THAN)
- return c1;
+ //compare (date1 with time zone -14)<=date2
+ //
+ cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
+ tempDate.timezoneHr = -14;
+ tempDate.timezoneMin = 0;
+ tempDate.utc='-';
+ if (DEBUG) {
+ System.out.println("tempDate=" + dateToString(tempDate));
+ }
+ normalize(tempDate);
+ c1 = compareOrder(tempDate, date2);
+ if (DEBUG) {
+ System.out.println("date=" + dateToString(date2));
+ System.out.println("tempDate=" + dateToString(tempDate));
+ }
+ if (c1 == LESS_THAN)
+ return c1;
- //compare (date1 with time zone +14)<=date2
- //
- cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
- tempDate.timezoneHr = 14;
- tempDate.timezoneMin = 0;
- tempDate.utc='+';
- normalize(tempDate);
- c2 = compareOrder(tempDate, date2);
- if (DEBUG) {
- System.out.println("tempDate=" + dateToString(tempDate));
- }
- if (c2 == GREATER_THAN)
- return c2;
+ //compare (date1 with time zone +14)<=date2
+ //
+ cloneDate(date1, tempDate); //clones date1 value to global temporary storage: tempDate
+ tempDate.timezoneHr = 14;
+ tempDate.timezoneMin = 0;
+ tempDate.utc='+';
+ normalize(tempDate);
+ c2 = compareOrder(tempDate, date2);
+ if (DEBUG) {
+ System.out.println("tempDate=" + dateToString(tempDate));
+ }
+ if (c2 == GREATER_THAN)
+ return c2;
- return INDETERMINATE;
- }
- return INDETERMINATE;
+ return INDETERMINATE;
+ }
+ return INDETERMINATE;
- }
+ }
- /**
- * Given normalized values, determines order-relation
- * between give date/time objects.
- *
- * @param date1 date/time object
- * @param date2 date/time object
- * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
- */
- protected short compareOrder(DateTimeData date1, DateTimeData date2) {
- if(date1.position < 1) {
- if (date1.year < date2.year)
- return -1;
- if (date1.year > date2.year)
- return 1;
- }
- if(date1.position < 2) {
- if (date1.month < date2.month)
- return -1;
- if (date1.month > date2.month)
- return 1;
- }
- if (date1.day < date2.day)
- return -1;
- if (date1.day > date2.day)
- return 1;
- if (date1.hour < date2.hour)
- return -1;
- if (date1.hour > date2.hour)
- return 1;
- if (date1.minute < date2.minute)
- return -1;
- if (date1.minute > date2.minute)
- return 1;
- if (date1.second < date2.second)
- return -1;
- if (date1.second > date2.second)
- return 1;
- if (date1.utc < date2.utc)
- return -1;
- if (date1.utc > date2.utc)
- return 1;
- return 0;
- }
+ /**
+ * Given normalized values, determines order-relation
+ * between give date/time objects.
+ *
+ * @param date1 date/time object
+ * @param date2 date/time object
+ * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
+ */
+ protected short compareOrder(DateTimeData date1, DateTimeData date2) {
+ if(date1.position < 1) {
+ if (date1.year < date2.year)
+ return -1;
+ if (date1.year > date2.year)
+ return 1;
+ }
+ if(date1.position < 2) {
+ if (date1.month < date2.month)
+ return -1;
+ if (date1.month > date2.month)
+ return 1;
+ }
+ if (date1.day < date2.day)
+ return -1;
+ if (date1.day > date2.day)
+ return 1;
+ if (date1.hour < date2.hour)
+ return -1;
+ if (date1.hour > date2.hour)
+ return 1;
+ if (date1.minute < date2.minute)
+ return -1;
+ if (date1.minute > date2.minute)
+ return 1;
+ if (date1.second < date2.second)
+ return -1;
+ if (date1.second > date2.second)
+ return 1;
+ if (date1.utc < date2.utc)
+ return -1;
+ if (date1.utc > date2.utc)
+ return 1;
+ return 0;
+ }
- /**
- * Parses time hh:mm:ss.sss and time zone if any
- *
- * @param start
- * @param end
- * @param data
- * @exception RuntimeException
- */
- protected void getTime (String buffer, int start, int end, DateTimeData data) throws RuntimeException{
+ /**
+ * Parses time hh:mm:ss.sss and time zone if any
+ *
+ * @param start
+ * @param end
+ * @param data
+ * @exception RuntimeException
+ */
+ protected void getTime (String buffer, int start, int end, DateTimeData data) throws RuntimeException{
- int stop = start+2;
+ int stop = start+2;
- //get hours (hh)
- data.hour=parseInt(buffer, start,stop);
+ //get hours (hh)
+ data.hour=parseInt(buffer, start,stop);
- //get minutes (mm)
+ //get minutes (mm)
- if (buffer.charAt(stop++)!=':') {
- throw new RuntimeException("Error in parsing time zone" );
- }
- start = stop;
- stop = stop+2;
- data.minute=parseInt(buffer, start,stop);
+ if (buffer.charAt(stop++)!=':') {
+ throw new RuntimeException("Error in parsing time zone" );
+ }
+ start = stop;
+ stop = stop+2;
+ data.minute=parseInt(buffer, start,stop);
- //get seconds (ss)
- if (buffer.charAt(stop++)!=':') {
- throw new RuntimeException("Error in parsing time zone" );
- }
+ //get seconds (ss)
+ if (buffer.charAt(stop++)!=':') {
+ throw new RuntimeException("Error in parsing time zone" );
+ }
- //find UTC sign if any
- int sign = findUTCSign(buffer, start, end);
+ //find UTC sign if any
+ int sign = findUTCSign(buffer, start, end);
- //get seconds (ms)
- start = stop;
- stop = sign < 0 ? end : sign;
- data.second = parseSecond(buffer, start, stop);
+ //get seconds (ms)
+ start = stop;
+ stop = sign < 0 ? end : sign;
+ data.second = parseSecond(buffer, start, stop);
- //parse UTC time zone (hh:mm)
- if (sign > 0) {
- getTimeZone(buffer, data, sign, end);
- }
- }
+ //parse UTC time zone (hh:mm)
+ if (sign > 0) {
+ getTimeZone(buffer, data, sign, end);
+ }
+ }
- /**
- * Parses date CCYY-MM-DD
- *
- * @param buffer
- * @param start start position
- * @param end end position
- * @param date
- * @exception RuntimeException
- */
- protected int getDate (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
+ /**
+ * Parses date CCYY-MM-DD
+ *
+ * @param buffer
+ * @param start start position
+ * @param end end position
+ * @param date
+ * @exception RuntimeException
+ */
+ protected int getDate (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
- start = getYearMonth(buffer, start, end, date);
+ start = getYearMonth(buffer, start, end, date);
- if (buffer.charAt(start++) !='-') {
- throw new RuntimeException("CCYY-MM must be followed by '-' sign");
- }
- int stop = start + 2;
- date.day=parseInt(buffer, start, stop);
- return stop;
- }
+ if (buffer.charAt(start++) !='-') {
+ throw new RuntimeException("CCYY-MM must be followed by '-' sign");
+ }
+ int stop = start + 2;
+ date.day=parseInt(buffer, start, stop);
+ return stop;
+ }
- /**
- * Parses date CCYY-MM
- *
- * @param buffer
- * @param start start position
- * @param end end position
- * @param date
- * @exception RuntimeException
- */
- protected int getYearMonth (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
+ /**
+ * Parses date CCYY-MM
+ *
+ * @param buffer
+ * @param start start position
+ * @param end end position
+ * @param date
+ * @exception RuntimeException
+ */
+ protected int getYearMonth (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
- if ( buffer.charAt(0)=='-' ) {
- // REVISIT: date starts with preceding '-' sign
- // do we have to do anything with it?
- //
- start++;
- }
- int i = indexOf(buffer, start, end, '-');
- if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced");
- int length = i-start;
- if (length<4) {
- throw new RuntimeException("Year must have 'CCYY' format");
- }
- else if (length > 4 && buffer.charAt(start)=='0'){
- throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
- }
- date.year= parseIntYear(buffer, i);
- if (buffer.charAt(i)!='-') {
- throw new RuntimeException("CCYY must be followed by '-' sign");
- }
- start = ++i;
- i = start +2;
- date.month=parseInt(buffer, start, i);
- return i; //fStart points right after the MONTH
- }
+ if ( buffer.charAt(0)=='-' ) {
+ // REVISIT: date starts with preceding '-' sign
+ // do we have to do anything with it?
+ //
+ start++;
+ }
+ int i = indexOf(buffer, start, end, '-');
+ if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced");
+ int length = i-start;
+ if (length<4) {
+ throw new RuntimeException("Year must have 'CCYY' format");
+ }
+ else if (length > 4 && buffer.charAt(start)=='0'){
+ throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
+ }
+ date.year= parseIntYear(buffer, i);
+ if (buffer.charAt(i)!='-') {
+ throw new RuntimeException("CCYY must be followed by '-' sign");
+ }
+ start = ++i;
+ i = start +2;
+ date.month=parseInt(buffer, start, i);
+ return i; //fStart points right after the MONTH
+ }
- /**
- * Shared code from Date and YearMonth datatypes.
- * Finds if time zone sign is present
- *
- * @param end
- * @param date
- * @exception RuntimeException
- */
- protected void parseTimeZone (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
+ /**
+ * Shared code from Date and YearMonth datatypes.
+ * Finds if time zone sign is present
+ *
+ * @param end
+ * @param date
+ * @exception RuntimeException
+ */
+ protected void parseTimeZone (String buffer, int start, int end, DateTimeData date) throws RuntimeException{
- //fStart points right after the date
+ //fStart points right after the date
- if ( start < end ) {
- if (!isNextCharUTCSign(buffer, start, end)) {
- throw new RuntimeException ("Error in month parsing");
- }
- else {
- getTimeZone(buffer, date, start, end);
- }
- }
- }
+ if ( start < end ) {
+ if (!isNextCharUTCSign(buffer, start, end)) {
+ throw new RuntimeException ("Error in month parsing");
+ }
+ else {
+ getTimeZone(buffer, date, start, end);
+ }
+ }
+ }
- /**
- * Parses time zone: 'Z' or {+,-} followed by hh:mm
- *
- * @param data
- * @param sign
- * @exception RuntimeException
- */
- protected void getTimeZone (String buffer, DateTimeData data, int sign, int end) throws RuntimeException{
- data.utc=buffer.charAt(sign);
+ /**
+ * Parses time zone: 'Z' or {+,-} followed by hh:mm
+ *
+ * @param data
+ * @param sign
+ * @exception RuntimeException
+ */
+ protected void getTimeZone (String buffer, DateTimeData data, int sign, int end) throws RuntimeException{
+ data.utc=buffer.charAt(sign);
- if ( buffer.charAt(sign) == 'Z' ) {
- if (end>(++sign)) {
- throw new RuntimeException("Error in parsing time zone");
- }
- return;
- }
- if ( sign<=(end-6) ) {
+ if ( buffer.charAt(sign) == 'Z' ) {
+ if (end>(++sign)) {
+ throw new RuntimeException("Error in parsing time zone");
+ }
+ return;
+ }
+ if ( sign<=(end-6) ) {
- int negate = buffer.charAt(sign) == '-'?-1:1;
- //parse hr
- int stop = ++sign+2;
- data.timezoneHr = negate*parseInt(buffer, sign, stop);
- if (buffer.charAt(stop++)!=':') {
- throw new RuntimeException("Error in parsing time zone" );
- }
+ int negate = buffer.charAt(sign) == '-'?-1:1;
+ //parse hr
+ int stop = ++sign+2;
+ data.timezoneHr = negate*parseInt(buffer, sign, stop);
+ if (buffer.charAt(stop++)!=':') {
+ throw new RuntimeException("Error in parsing time zone" );
+ }
- //parse min
- data.timezoneMin = negate*parseInt(buffer, stop, stop+2);
+ //parse min
+ data.timezoneMin = negate*parseInt(buffer, stop, stop+2);
- if ( stop+2!=end ) {
- throw new RuntimeException("Error in parsing time zone");
- }
+ if ( stop+2!=end ) {
+ throw new RuntimeException("Error in parsing time zone");
+ }
if(data.timezoneHr != 0 || data.timezoneMin != 0)
data.normalized = false;
- }
- else {
- throw new RuntimeException("Error in parsing time zone");
- }
- if ( DEBUG ) {
- System.out.println("time[hh]="+data.timezoneHr + " time[mm]=" +data.timezoneMin);
- }
- }
+ }
+ else {
+ throw new RuntimeException("Error in parsing time zone");
+ }
+ if ( DEBUG ) {
+ System.out.println("time[hh]="+data.timezoneHr + " time[mm]=" +data.timezoneMin);
+ }
+ }
- /**
- * Computes index of given char within StringBuffer
- *
- * @param start
- * @param end
- * @param ch character to look for in StringBuffer
- * @return index of ch within StringBuffer
- */
- protected int indexOf (String buffer, int start, int end, char ch) {
- for ( int i=start;i12 ) {
- throw new RuntimeException("The month must have values 1 to 12");
+ if ( data.month<1 || data.month>12 ) {
+ throw new RuntimeException("The month must have values 1 to 12");
- }
+ }
- //validate days
- if ( data.day>maxDayInMonthFor(data.year, data.month) || data.day<1 ) {
- throw new RuntimeException("The day must have values 1 to 31");
- }
+ //validate days
+ if ( data.day>maxDayInMonthFor(data.year, data.month) || data.day<1 ) {
+ throw new RuntimeException("The day must have values 1 to 31");
+ }
- //validate hours
- if ( data.hour>23 || data.hour<0 ) {
- if (data.hour == 24 && data.minute == 0 && data.second == 0) {
- data.hour = 0;
- if (++data.day > maxDayInMonthFor(data.year, data.month)) {
- data.day = 1;
- if (++data.month > 12) {
- data.month = 1;
- if (Constants.SCHEMA_1_1_SUPPORT) {
- ++data.year;
- }
- else if (++data.year == 0) {
- data.year = 1;
- }
- }
- }
- }
- else {
- throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
- }
- }
+ //validate hours
+ if ( data.hour>23 || data.hour<0 ) {
+ if (data.hour == 24 && data.minute == 0 && data.second == 0) {
+ data.hour = 0;
+ if (++data.day > maxDayInMonthFor(data.year, data.month)) {
+ data.day = 1;
+ if (++data.month > 12) {
+ data.month = 1;
+ if (Constants.SCHEMA_1_1_SUPPORT) {
+ ++data.year;
+ }
+ else if (++data.year == 0) {
+ data.year = 1;
+ }
+ }
+ }
+ }
+ else {
+ throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
+ }
+ }
- //validate
- if ( data.minute>59 || data.minute<0 ) {
- throw new RuntimeException("Minute must have values 0-59");
- }
+ //validate
+ if ( data.minute>59 || data.minute<0 ) {
+ throw new RuntimeException("Minute must have values 0-59");
+ }
- //validate
- if ( data.second>=60 || data.second<0 ) {
- throw new RuntimeException("Second must have values 0-59");
+ //validate
+ if ( data.second>=60 || data.second<0 ) {
+ throw new RuntimeException("Second must have values 0-59");
- }
+ }
- //validate
- if ( data.timezoneHr>14 || data.timezoneHr<-14 ) {
- throw new RuntimeException("Time zone should have range -14:00 to +14:00");
- }
- else {
- if((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0)
- throw new RuntimeException("Time zone should have range -14:00 to +14:00");
- else if(data.timezoneMin > 59 || data.timezoneMin < -59)
- throw new RuntimeException("Minute must have values 0-59");
- }
+ //validate
+ if ( data.timezoneHr>14 || data.timezoneHr<-14 ) {
+ throw new RuntimeException("Time zone should have range -14:00 to +14:00");
+ }
+ else {
+ if((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0)
+ throw new RuntimeException("Time zone should have range -14:00 to +14:00");
+ else if(data.timezoneMin > 59 || data.timezoneMin < -59)
+ throw new RuntimeException("Minute must have values 0-59");
+ }
- }
+ }
- /**
- * Return index of UTC char: 'Z', '+', '-'
- *
- * @param start
- * @param end
- * @return index of the UTC character that was found
- */
- protected int findUTCSign (String buffer, int start, int end) {
- int c;
- for ( int i=start;itrue if the character at start is 'Z', '+' or '-'.
@@ -507,136 +510,135 @@
return false;
}
- /**
- * Given start and end position, parses string value
- *
- * @param buffer string to parse
- * @param start start position
- * @param end end position
- * @return return integer representation of characters
- */
- protected int parseInt (String buffer, int start, int end)
- throws NumberFormatException{
- //REVISIT: more testing on this parsing needs to be done.
- int radix=10;
- int result = 0;
- int digit=0;
- int limit = -Integer.MAX_VALUE;
- int multmin = limit / radix;
- int i = start;
- do {
- digit = getDigit(buffer.charAt(i));
- if ( digit < 0 ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- if ( result < multmin ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result *= radix;
- if ( result < limit + digit ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result -= digit;
+ /**
+ * Given start and end position, parses string value
+ *
+ * @param buffer string to parse
+ * @param start start position
+ * @param end end position
+ * @return return integer representation of characters
+ */
+ protected int parseInt (String buffer, int start, int end)
+ throws NumberFormatException{
+ //REVISIT: more testing on this parsing needs to be done.
+ int radix=10;
+ int result = 0;
+ int digit=0;
+ int limit = -Integer.MAX_VALUE;
+ int multmin = limit / radix;
+ int i = start;
+ do {
+ digit = getDigit(buffer.charAt(i));
+ if ( digit < 0 ) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ if ( result < multmin ) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ result *= radix;
+ if ( result < limit + digit ) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ result -= digit;
- }while ( ++i < end );
- return -result;
- }
+ }while ( ++i < end );
+ return -result;
+ }
- // parse Year differently to support negative value.
- protected int parseIntYear (String buffer, int end){
- int radix=10;
- int result = 0;
- boolean negative = false;
- int i=0;
- int limit;
- int multmin;
- int digit=0;
+ // parse Year differently to support negative value.
+ protected int parseIntYear (String buffer, int end){
+ int radix=10;
+ int result = 0;
+ boolean negative = false;
+ int i=0;
+ int limit;
+ int multmin;
+ int digit=0;
- if (buffer.charAt(0) == '-'){
- negative = true;
- limit = Integer.MIN_VALUE;
- i++;
+ if (buffer.charAt(0) == '-'){
+ negative = true;
+ limit = Integer.MIN_VALUE;
+ i++;
- }
- else{
- limit = -Integer.MAX_VALUE;
- }
- multmin = limit / radix;
- while (i < end)
- {
- digit = getDigit(buffer.charAt(i++));
- if (digit < 0) throw new NumberFormatException("'" + buffer + "' has wrong format");
- if (result < multmin) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result *= radix;
- if (result < limit + digit) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result -= digit;
- }
+ }
+ else{
+ limit = -Integer.MAX_VALUE;
+ }
+ multmin = limit / radix;
+ while (i < end)
+ {
+ digit = getDigit(buffer.charAt(i++));
+ if (digit < 0) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ if (result < multmin) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ result *= radix;
+ if (result < limit + digit) throw new NumberFormatException("'" + buffer + "' has wrong format");
+ result -= digit;
+ }
- if (negative)
- {
- if (i > 1) return result;
- else throw new NumberFormatException("'" + buffer + "' has wrong format");
- }
- return -result;
+ if (negative)
+ {
+ if (i > 1) return result;
+ else throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ return -result;
- }
+ }
- /**
- * If timezone present - normalize dateTime [E Adding durations to dateTimes]
- *
- * @param date CCYY-MM-DDThh:mm:ss+03
- * @return CCYY-MM-DDThh:mm:ssZ
- */
- protected void normalize(DateTimeData date) {
+ /**
+ * If timezone present - normalize dateTime [E Adding durations to dateTimes]
+ *
+ * @param date CCYY-MM-DDThh:mm:ss+03
+ */
+ protected void normalize(DateTimeData date) {
+
+ // REVISIT: we have common code in addDuration() for durations
+ // should consider reorganizing it.
+ //
- // REVISIT: we have common code in addDuration() for durations
- // should consider reorganizing it.
- //
+ //add minutes (from time zone)
+ int negate = -1;
- //add minutes (from time zone)
- int negate = -1;
+ if ( DEBUG ) {
+ System.out.println("==>date.minute"+date.minute);
+ System.out.println("==>date.timezoneMin" +date.timezoneMin);
+ }
+ int temp = date.minute + negate * date.timezoneMin;
+ int carry = fQuotient (temp, 60);
+ date.minute= mod(temp, 60, carry);
- if ( DEBUG ) {
- System.out.println("==>date.minute"+date.minute);
- System.out.println("==>date.timezoneMin" +date.timezoneMin);
- }
- int temp = date.minute + negate * date.timezoneMin;
- int carry = fQuotient (temp, 60);
- date.minute= mod(temp, 60, carry);
+ if ( DEBUG ) {
+ System.out.println("==>carry: " + carry);
+ }
+ //add hours
+ temp = date.hour + negate * date.timezoneHr + carry;
+ carry = fQuotient(temp, 24);
+ date.hour=mod(temp, 24, carry);
+ if ( DEBUG ) {
+ System.out.println("==>date.hour"+date.hour);
+ System.out.println("==>carry: " + carry);
+ }
+
+ date.day=date.day+carry;
- if ( DEBUG ) {
- System.out.println("==>carry: " + carry);
- }
- //add hours
- temp = date.hour + negate * date.timezoneHr + carry;
- carry = fQuotient(temp, 24);
- date.hour=mod(temp, 24, carry);
- if ( DEBUG ) {
- System.out.println("==>date.hour"+date.hour);
- System.out.println("==>carry: " + carry);
- }
-
- date.day=date.day+carry;
-
- while ( true ) {
- temp=maxDayInMonthFor(date.year, date.month);
- if (date.day<1) {
- date.day = date.day + maxDayInMonthFor(date.year, date.month-1);
- carry=-1;
- }
- else if ( date.day>temp ) {
- date.day=date.day-temp;
- carry=1;
- }
- else {
- break;
- }
- temp=date.month+carry;
- date.month=modulo(temp, 1, 13);
- date.year=date.year+fQuotient(temp, 1, 13);
+ while ( true ) {
+ temp=maxDayInMonthFor(date.year, date.month);
+ if (date.day<1) {
+ date.day = date.day + maxDayInMonthFor(date.year, date.month-1);
+ carry=-1;
+ }
+ else if ( date.day>temp ) {
+ date.day=date.day-temp;
+ carry=1;
+ }
+ else {
+ break;
+ }
+ temp=date.month+carry;
+ date.month=modulo(temp, 1, 13);
+ date.year=date.year+fQuotient(temp, 1, 13);
if(date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
date.year = (date.timezoneHr < 0 || date.timezoneMin < 0)?1:-1;
}
- }
- date.utc='Z';
- }
+ }
+ date.utc='Z';
+ }
- /**
+ /**
* @param date
*/
protected void saveUnnormalized(DateTimeData date) {
@@ -649,190 +651,271 @@
}
/**
- * Resets object representation of date/time
- *
- * @param data date/time object
- */
- protected void resetDateObj(DateTimeData data) {
- data.year = 0;
- data.month = 0;
- data.day = 0;
- data.hour = 0;
- data.minute = 0;
- data.second = 0;
- data.utc = 0;
- data.timezoneHr = 0;
- data.timezoneMin = 0;
- }
+ * Resets object representation of date/time
+ *
+ * @param data date/time object
+ */
+ protected void resetDateObj(DateTimeData data) {
+ data.year = 0;
+ data.month = 0;
+ data.day = 0;
+ data.hour = 0;
+ data.minute = 0;
+ data.second = 0;
+ data.utc = 0;
+ data.timezoneHr = 0;
+ data.timezoneMin = 0;
+ }
- /**
- * Given {year,month} computes maximum
- * number of days for given month
- *
- * @param year
- * @param month
- * @return integer containg the number of days in a given month
- */
- protected int maxDayInMonthFor(int year, int month) {
- //validate days
- if ( month==4 || month==6 || month==9 || month==11 ) {
- return 30;
- }
- else if ( month==2 ) {
- if ( isLeapYear(year) ) {
- return 29;
- }
- else {
- return 28;
- }
- }
- else {
- return 31;
- }
- }
+ /**
+ * Given {year,month} computes maximum
+ * number of days for given month
+ *
+ * @param year
+ * @param month
+ * @return integer containg the number of days in a given month
+ */
+ protected int maxDayInMonthFor(int year, int month) {
+ //validate days
+ if ( month==4 || month==6 || month==9 || month==11 ) {
+ return 30;
+ }
+ else if ( month==2 ) {
+ if ( isLeapYear(year) ) {
+ return 29;
+ }
+ else {
+ return 28;
+ }
+ }
+ else {
+ return 31;
+ }
+ }
- private boolean isLeapYear(int year) {
+ private boolean isLeapYear(int year) {
- //REVISIT: should we take care about Julian calendar?
- return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
- }
+ //REVISIT: should we take care about Julian calendar?
+ return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int mod (int a, int b, int quotient) {
- //modulo(a, b) = a - fQuotient(a,b)*b
- return (a - quotient*b) ;
- }
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int mod (int a, int b, int quotient) {
+ //modulo(a, b) = a - fQuotient(a,b)*b
+ return (a - quotient*b) ;
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int fQuotient (int a, int b) {
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int fQuotient (int a, int b) {
- //fQuotient(a, b) = the greatest integer less than or equal to a/b
- return (int)Math.floor((float)a/b);
- }
+ //fQuotient(a, b) = the greatest integer less than or equal to a/b
+ return (int)Math.floor((float)a/b);
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int modulo (int temp, int low, int high) {
- //modulo(a - low, high - low) + low
- int a = temp - low;
- int b = high - low;
- return (mod (a, b, fQuotient(a, b)) + low) ;
- }
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int modulo (int temp, int low, int high) {
+ //modulo(a - low, high - low) + low
+ int a = temp - low;
+ int b = high - low;
+ return (mod (a, b, fQuotient(a, b)) + low) ;
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int fQuotient (int temp, int low, int high) {
- //fQuotient(a - low, high - low)
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int fQuotient (int temp, int low, int high) {
+ //fQuotient(a - low, high - low)
- return fQuotient(temp - low, high - low);
- }
+ return fQuotient(temp - low, high - low);
+ }
- protected String dateToString(DateTimeData date) {
- StringBuffer message = new StringBuffer(25);
- append(message, date.year, 4);
- message.append('-');
- append(message, date.month, 2);
- message.append('-');
- append(message, date.day, 2);
- message.append('T');
- append(message, date.hour, 2);
- message.append(':');
- append(message, date.minute, 2);
- message.append(':');
- append(message, date.second);
- append(message, (char)date.utc, 0);
- return message.toString();
- }
+ protected String dateToString(DateTimeData date) {
+ StringBuffer message = new StringBuffer(25);
+ append(message, date.year, 4);
+ message.append('-');
+ append(message, date.month, 2);
+ message.append('-');
+ append(message, date.day, 2);
+ message.append('T');
+ append(message, date.hour, 2);
+ message.append(':');
+ append(message, date.minute, 2);
+ message.append(':');
+ append(message, date.second);
+ append(message, (char)date.utc, 0);
+ return message.toString();
+ }
- protected void append(StringBuffer message, int value, int nch) {
+ protected final void append(StringBuffer message, int value, int nch) {
if (value == Integer.MIN_VALUE) {
message.append(value);
return;
}
- if (value < 0) {
- message.append('-');
- value = -value;
- }
- if (nch == 4) {
- if (value < 10)
- message.append("000");
- else if (value < 100)
- message.append("00");
- else if (value < 1000)
- message.append("0");
- message.append(value);
- }
- else if (nch == 2) {
- if (value < 10)
- message.append('0');
- message.append(value);
- }
- else {
- if (value != 0)
- message.append((char)value);
- }
+ if (value < 0) {
+ message.append('-');
+ value = -value;
+ }
+ if (nch == 4) {
+ if (value < 10)
+ message.append("000");
+ else if (value < 100)
+ message.append("00");
+ else if (value < 1000)
+ message.append('0');
+ message.append(value);
+ }
+ else if (nch == 2) {
+ if (value < 10)
+ message.append('0');
+ message.append(value);
+ }
+ else {
+ if (value != 0)
+ message.append((char)value);
+ }
+ }
+
+ protected final void append(StringBuffer message, double value) {
+ if (value < 0) {
+ message.append('-');
+ value = -value;
+ }
+ if (value < 10) {
+ message.append('0');
+ }
+ append2(message, value);
+ }
+
+ protected final void append2(StringBuffer message, double value) {
+ final int intValue = (int) value;
+ if (value == intValue) {
+ message.append(intValue);
}
-
- protected void append(StringBuffer message, double value) {
- if (value < 0) {
- message.append('-');
- value = -value;
- }
- if (value < 10)
- message.append('0');
- message.append(value);
+ else {
+ append3(message, value);
}
+ }
- protected double parseSecond(String buffer, int start, int end)
- throws NumberFormatException {
- int dot = -1;
- for (int i = start; i < end; i++) {
- char ch = buffer.charAt(i);
- if (ch == '.')
- dot = i;
- else if (ch > '9' || ch < '0')
- throw new NumberFormatException("'" + buffer + "' has wrong format");
+ private void append3(StringBuffer message, double value) {
+ String d = String.valueOf(value);
+ int eIndex = d.indexOf('E');
+ if (eIndex == -1) {
+ message.append(d);
+ return;
+ }
+ int exp;
+ if (value < 1) {
+ // Need to convert from scientific notation of the form
+ // n.nnn...E-N (N >= 4) to a normal decimal value.
+ try {
+ exp = parseInt(d, eIndex+2, d.length());
+ }
+ // This should never happen.
+ // It's only possible if String.valueOf(double) is broken.
+ catch (Exception e) {
+ message.append(d);
+ return;
+ }
+ message.append("0.");
+ for (int i = 1; i < exp; ++i) {
+ message.append('0');
+ }
+ // Remove trailing zeros.
+ int end = eIndex - 1;
+ while (end > 0) {
+ char c = d.charAt(end);
+ if (c != '0') {
+ break;
}
- if (dot == -1) {
- if (start+2 != end)
- throw new NumberFormatException("'" + buffer + "' has wrong format");
+ --end;
+ }
+ // Now append the digits to the end. Skip over the decimal point.
+ for (int i = 0; i <= end; ++i) {
+ char c = d.charAt(i);
+ if (c != '.') {
+ message.append(c);
}
- else if (start+2 != dot || dot+1 == end) {
- throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ }
+ else {
+ // Need to convert from scientific notation of the form
+ // n.nnn...EN (N >= 7) to a normal decimal value.
+ try {
+ exp = parseInt(d, eIndex+1, d.length());
+ }
+ // This should never happen.
+ // It's only possible if String.valueOf(double) is broken.
+ catch (Exception e) {
+ message.append(d);
+ return;
+ }
+ final int integerEnd = exp + 2;
+ for (int i = 0; i < eIndex; ++i) {
+ char c = d.charAt(i);
+ if (c != '.') {
+ if (i == integerEnd) {
+ message.append('.');
+ }
+ message.append(c);
}
- return Double.parseDouble(buffer.substring(start, end));
+ }
+ // Append trailing zeroes if necessary.
+ for (int i = integerEnd - eIndex; i > 0; --i) {
+ message.append('0');
+ }
}
+ }
- //
- //Private help functions
- //
+ protected double parseSecond(String buffer, int start, int end)
+ throws NumberFormatException {
+ int dot = -1;
+ for (int i = start; i < end; i++) {
+ char ch = buffer.charAt(i);
+ if (ch == '.')
+ dot = i;
+ else if (ch > '9' || ch < '0')
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ if (dot == -1) {
+ if (start+2 != end)
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ else if (start+2 != dot || dot+1 == end) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ return Double.parseDouble(buffer.substring(start, end));
+ }
- private void cloneDate (DateTimeData finalValue, DateTimeData tempDate) {
- tempDate.year = finalValue.year;
- tempDate.month = finalValue.month;
- tempDate.day = finalValue.day;
- tempDate.hour = finalValue.hour;
- tempDate.minute = finalValue.minute;
- tempDate.second = finalValue.second;
- tempDate.utc = finalValue.utc;
- tempDate.timezoneHr = finalValue.timezoneHr;
- tempDate.timezoneMin = finalValue.timezoneMin;
- }
+ //
+ //Private help functions
+ //
- /**
- * Represents date time data
- */
- static final class DateTimeData implements XSDateTime {
- int year, month, day, hour, minute, utc;
- double second;
- int timezoneHr, timezoneMin;
+ private void cloneDate (DateTimeData finalValue, DateTimeData tempDate) {
+ tempDate.year = finalValue.year;
+ tempDate.month = finalValue.month;
+ tempDate.day = finalValue.day;
+ tempDate.hour = finalValue.hour;
+ tempDate.minute = finalValue.minute;
+ tempDate.second = finalValue.second;
+ tempDate.utc = finalValue.utc;
+ tempDate.timezoneHr = finalValue.timezoneHr;
+ tempDate.timezoneMin = finalValue.timezoneMin;
+ }
+
+ /**
+ * Represents date time data
+ */
+ static final class DateTimeData implements XSDateTime {
+ int year, month, day, hour, minute, utc;
+ double second;
+ int timezoneHr, timezoneMin;
private String originalValue;
boolean normalized = true;
@@ -843,117 +926,117 @@
int unNormMinute;
double unNormSecond;
- // used for comparisons - to decide the 'interesting' portions of
- // a date/time based data type.
- int position;
- // a pointer to the type that was used go generate this data
- // note that this is not the actual simple type, but one of the
- // statically created XXXDV objects, so this won't cause any GC problem.
- final AbstractDateTimeDV type;
- private String canonical;
- public DateTimeData(String originalValue, AbstractDateTimeDV type) {
+ // used for comparisons - to decide the 'interesting' portions of
+ // a date/time based data type.
+ int position;
+ // a pointer to the type that was used go generate this data
+ // note that this is not the actual simple type, but one of the
+ // statically created XXXDV objects, so this won't cause any GC problem.
+ final AbstractDateTimeDV type;
+ private String canonical;
+ public DateTimeData(String originalValue, AbstractDateTimeDV type) {
this.originalValue = originalValue;
- this.type = type;
- }
- public DateTimeData(int year, int month, int day, int hour, int minute,
- double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) {
- this.year = year;
- this.month = month;
- this.day = day;
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- this.utc = utc;
- this.type = type;
+ this.type = type;
+ }
+ public DateTimeData(int year, int month, int day, int hour, int minute,
+ double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) {
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ this.hour = hour;
+ this.minute = minute;
+ this.second = second;
+ this.utc = utc;
+ this.type = type;
this.originalValue = originalValue;
- }
- public boolean equals(Object obj) {
- if (!(obj instanceof DateTimeData))
- return false;
- return type.compareDates(this, (DateTimeData)obj, true)==0;
- }
- public synchronized String toString() {
- if (canonical == null) {
- canonical = type.dateToString(this);
- }
- return canonical;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getYear()
- */
- public int getYears() {
+ }
+ public boolean equals(Object obj) {
+ if (!(obj instanceof DateTimeData))
+ return false;
+ return type.compareDates(this, (DateTimeData)obj, true)==0;
+ }
+ public synchronized String toString() {
+ if (canonical == null) {
+ canonical = type.dateToString(this);
+ }
+ return canonical;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getYear()
+ */
+ public int getYears() {
if(type instanceof DurationDV)
return 0;
- return normalized?year:unNormYear;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getMonth()
- */
- public int getMonths() {
+ return normalized?year:unNormYear;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getMonth()
+ */
+ public int getMonths() {
if(type instanceof DurationDV) {
return year*12 + month;
}
- return normalized?month:unNormMonth;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getDay()
- */
- public int getDays() {
+ return normalized?month:unNormMonth;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getDay()
+ */
+ public int getDays() {
if(type instanceof DurationDV)
return 0;
- return normalized?day:unNormDay;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getHour()
- */
- public int getHours() {
+ return normalized?day:unNormDay;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getHour()
+ */
+ public int getHours() {
if(type instanceof DurationDV)
return 0;
- return normalized?hour:unNormHour;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getMinutes()
- */
- public int getMinutes() {
+ return normalized?hour:unNormHour;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getMinutes()
+ */
+ public int getMinutes() {
if(type instanceof DurationDV)
return 0;
- return normalized?minute:unNormMinute;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getSeconds()
- */
- public double getSeconds() {
+ return normalized?minute:unNormMinute;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getSeconds()
+ */
+ public double getSeconds() {
if(type instanceof DurationDV) {
return day*24*60*60 + hour*60*60 + minute*60 + second;
}
- return normalized?second:unNormSecond;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#hasTimeZone()
- */
- public boolean hasTimeZone() {
- return utc != 0;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getTimeZoneHours()
- */
- public int getTimeZoneHours() {
- return timezoneHr;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getTimeZoneMinutes()
- */
- public int getTimeZoneMinutes() {
- return timezoneMin;
- }
+ return normalized?second:unNormSecond;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#hasTimeZone()
+ */
+ public boolean hasTimeZone() {
+ return utc != 0;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneHours()
+ */
+ public int getTimeZoneHours() {
+ return timezoneHr;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneMinutes()
+ */
+ public int getTimeZoneMinutes() {
+ return timezoneMin;
+ }
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getLexicalValue()
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getLexicalValue()
*/
public String getLexicalValue() {
return originalValue;
}
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#normalize()
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#normalize()
*/
public XSDateTime normalize() {
if(!normalized) {
@@ -964,7 +1047,7 @@
return this;
}
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#isNormalized()
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#isNormalized()
*/
public boolean isNormalized() {
return normalized;
@@ -987,25 +1070,40 @@
}
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getXMLGregorianCalendar()
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getXMLGregorianCalendar()
*/
public XMLGregorianCalendar getXMLGregorianCalendar() {
return type.getXMLGregorianCalendar(this);
}
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime#getDuration()
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getDuration()
*/
public Duration getDuration() {
return type.getDuration(this);
}
- }
+ }
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData data) {
return null;
}
-
protected Duration getDuration(DateTimeData data) {
return null;
}
+
+ protected final BigDecimal getFractionalSecondsAsBigDecimal(DateTimeData data) {
+ final StringBuffer buf = new StringBuffer();
+ append3(buf, data.unNormSecond);
+ String value = buf.toString();
+ final int index = value.indexOf('.');
+ if (index == -1) {
+ return null;
+ }
+ value = value.substring(index);
+ final BigDecimal _val = new BigDecimal(value);
+ if (_val.compareTo(BigDecimal.valueOf(0)) == 0) {
+ return null;
+ }
+ return _val;
+ }
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -28,11 +28,12 @@
/**
* Represent the schema type "base64Binary"
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: Base64BinaryDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class Base64BinaryDV extends TypeValidator {
@@ -81,5 +82,13 @@
}
return true;
}
+
+ public int hashCode() {
+ int hash = 0;
+ for (int i = 0; i < data.length; ++i) {
+ hash = hash * 37 + (((int) data[i]) & 0xff);
+ }
+ return hash;
+ }
}
} // class Base64BinaryDV
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,20 +21,21 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
+import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
-import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
-import com.sun.org.apache.xerces.internal.util.SymbolHash;
/**
* the factory to create/return built-in schema DVs and create user-defined DVs
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: BaseDVFactory.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class BaseDVFactory extends SchemaDVFactory {
@@ -186,7 +187,7 @@
types.put(NONPOSITIVEINTEGER, nonPositiveDV);
facets.maxInclusive = "-1";
- XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT);
+ XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(nonPositiveDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT);
negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
types.put(NEGATIVEINTEGER, negativeDV);
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,329 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.dv.xs;
+
+import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
+import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
+import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.impl.xs.XSDeclarationPool;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
+
+/**
+ * the base factory to create/return built-in schema DVs and create user-defined DVs
+ *
+ * @xerces.internal
+ *
+ * @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @author Sandy Gao, IBM
+ * @author Khaled Noaman, IBM
+ *
+ * @version $Id: BaseSchemaDVFactory.java,v 1.2 2010-10-26 23:01:03 joehw Exp $
+ */
+public abstract class BaseSchemaDVFactory extends SchemaDVFactory {
+
+ static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
+
+ protected XSDeclarationPool fDeclPool = null;
+
+ // create common built-in types
+ protected static void createBuiltInTypes(SymbolHash builtInTypes, XSSimpleTypeDecl baseAtomicType) {
+ // all schema simple type names
+ final String ANYSIMPLETYPE = "anySimpleType";
+ final String ANYURI = "anyURI";
+ final String BASE64BINARY = "base64Binary";
+ final String BOOLEAN = "boolean";
+ final String BYTE = "byte";
+ final String DATE = "date";
+ final String DATETIME = "dateTime";
+ final String DAY = "gDay";
+ final String DECIMAL = "decimal";
+ final String DOUBLE = "double";
+ final String DURATION = "duration";
+ final String ENTITY = "ENTITY";
+ final String ENTITIES = "ENTITIES";
+ final String FLOAT = "float";
+ final String HEXBINARY = "hexBinary";
+ final String ID = "ID";
+ final String IDREF = "IDREF";
+ final String IDREFS = "IDREFS";
+ final String INT = "int";
+ final String INTEGER = "integer";
+ final String LONG = "long";
+ final String NAME = "Name";
+ final String NEGATIVEINTEGER = "negativeInteger";
+ final String MONTH = "gMonth";
+ final String MONTHDAY = "gMonthDay";
+ final String NCNAME = "NCName";
+ final String NMTOKEN = "NMTOKEN";
+ final String NMTOKENS = "NMTOKENS";
+ final String LANGUAGE = "language";
+ final String NONNEGATIVEINTEGER= "nonNegativeInteger";
+ final String NONPOSITIVEINTEGER= "nonPositiveInteger";
+ final String NORMALIZEDSTRING = "normalizedString";
+ final String NOTATION = "NOTATION";
+ final String POSITIVEINTEGER = "positiveInteger";
+ final String QNAME = "QName";
+ final String SHORT = "short";
+ final String STRING = "string";
+ final String TIME = "time";
+ final String TOKEN = "token";
+ final String UNSIGNEDBYTE = "unsignedByte";
+ final String UNSIGNEDINT = "unsignedInt";
+ final String UNSIGNEDLONG = "unsignedLong";
+ final String UNSIGNEDSHORT = "unsignedShort";
+ final String YEAR = "gYear";
+ final String YEARMONTH = "gYearMonth";
+
+ final XSFacets facets = new XSFacets();
+
+ builtInTypes.put(ANYSIMPLETYPE, XSSimpleTypeDecl.fAnySimpleType);
+
+ XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(baseAtomicType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.STRING_DT);
+ builtInTypes.put(STRING, stringDV);
+ builtInTypes.put(BOOLEAN, new XSSimpleTypeDecl(baseAtomicType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false, true, XSConstants.BOOLEAN_DT));
+ XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(baseAtomicType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.DECIMAL_DT);
+ builtInTypes.put(DECIMAL, decimalDV);
+
+ builtInTypes.put(ANYURI, new XSSimpleTypeDecl(baseAtomicType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT));
+ builtInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(baseAtomicType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT));
+
+ XSSimpleTypeDecl durationDV = new XSSimpleTypeDecl(baseAtomicType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT);
+ builtInTypes.put(DURATION, durationDV);
+
+ builtInTypes.put(DATETIME, new XSSimpleTypeDecl(baseAtomicType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT));
+ builtInTypes.put(TIME, new XSSimpleTypeDecl(baseAtomicType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT));
+ builtInTypes.put(DATE, new XSSimpleTypeDecl(baseAtomicType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT));
+ builtInTypes.put(YEARMONTH, new XSSimpleTypeDecl(baseAtomicType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEARMONTH_DT));
+ builtInTypes.put(YEAR, new XSSimpleTypeDecl(baseAtomicType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEAR_DT));
+ builtInTypes.put(MONTHDAY, new XSSimpleTypeDecl(baseAtomicType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTHDAY_DT));
+ builtInTypes.put(DAY, new XSSimpleTypeDecl(baseAtomicType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GDAY_DT));
+ builtInTypes.put(MONTH, new XSSimpleTypeDecl(baseAtomicType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTH_DT));
+
+ XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, XSSimpleTypeDecl.DV_INTEGER, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.INTEGER_DT);
+ builtInTypes.put(INTEGER, integerDV);
+
+ facets.maxInclusive = "0";
+ XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONPOSITIVEINTEGER_DT);
+ nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
+ builtInTypes.put(NONPOSITIVEINTEGER, nonPositiveDV);
+
+ facets.maxInclusive = "-1";
+ XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(nonPositiveDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT);
+ negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
+ builtInTypes.put(NEGATIVEINTEGER, negativeDV);
+
+ facets.maxInclusive = "9223372036854775807";
+ facets.minInclusive = "-9223372036854775808";
+ XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LONG_DT);
+ longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
+ builtInTypes.put(LONG, longDV);
+
+ facets.maxInclusive = "2147483647";
+ facets.minInclusive = "-2147483648";
+ XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.INT_DT);
+ intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
+ builtInTypes.put(INT, intDV);
+
+ facets.maxInclusive = "32767";
+ facets.minInclusive = "-32768";
+ XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.SHORT_DT);
+ shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
+ builtInTypes.put(SHORT, shortDV);
+
+ facets.maxInclusive = "127";
+ facets.minInclusive = "-128";
+ XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.BYTE_DT);
+ byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
+ builtInTypes.put(BYTE, byteDV);
+
+ facets.minInclusive = "0" ;
+ XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONNEGATIVEINTEGER_DT);
+ nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
+ builtInTypes.put(NONNEGATIVEINTEGER, nonNegativeDV);
+
+ facets.maxInclusive = "18446744073709551615" ;
+ XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDLONG_DT);
+ unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
+ builtInTypes.put(UNSIGNEDLONG, unsignedLongDV);
+
+ facets.maxInclusive = "4294967295" ;
+ XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDINT_DT);
+ unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
+ builtInTypes.put(UNSIGNEDINT, unsignedIntDV);
+
+ facets.maxInclusive = "65535" ;
+ XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDSHORT_DT);
+ unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
+ builtInTypes.put(UNSIGNEDSHORT, unsignedShortDV);
+
+ facets.maxInclusive = "255" ;
+ XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDBYTE_DT);
+ unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
+ builtInTypes.put(UNSIGNEDBYTE, unsignedByteDV);
+
+ facets.minInclusive = "1" ;
+ XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.POSITIVEINTEGER_DT);
+ positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
+ builtInTypes.put(POSITIVEINTEGER, positiveIntegerDV);
+
+ builtInTypes.put(FLOAT, new XSSimpleTypeDecl(baseAtomicType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.FLOAT_DT));
+ builtInTypes.put(DOUBLE, new XSSimpleTypeDecl(baseAtomicType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.DOUBLE_DT));
+ builtInTypes.put(HEXBINARY, new XSSimpleTypeDecl(baseAtomicType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.HEXBINARY_DT));
+ builtInTypes.put(NOTATION, new XSSimpleTypeDecl(baseAtomicType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.NOTATION_DT));
+
+ facets.whiteSpace = XSSimpleType.WS_REPLACE;
+ XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NORMALIZEDSTRING_DT);
+ normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
+ builtInTypes.put(NORMALIZEDSTRING, normalizedDV);
+
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+ XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.TOKEN_DT);
+ tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
+ builtInTypes.put(TOKEN, tokenDV);
+
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+ facets.pattern = "([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*";
+ XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LANGUAGE_DT);
+ languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0);
+ builtInTypes.put(LANGUAGE, languageDV);
+
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+ XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NAME_DT);
+ nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
+ builtInTypes.put(NAME, nameDV);
+
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+ XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NCNAME_DT) ;
+ ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
+ builtInTypes.put(NCNAME, ncnameDV);
+
+ builtInTypes.put(QNAME, new XSSimpleTypeDecl(baseAtomicType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.QNAME_DT));
+
+ builtInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.ID_DT));
+ XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.IDREF_DT);
+ builtInTypes.put(IDREF, idrefDV);
+
+ facets.minLength = 1;
+ XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
+ XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ builtInTypes.put(IDREFS, idrefsDV);
+
+ XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ENTITY_DT);
+ builtInTypes.put(ENTITY, entityDV);
+
+ facets.minLength = 1;
+ tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null);
+ XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ builtInTypes.put(ENTITIES, entitiesDV);
+
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+ XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
+ nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
+ builtInTypes.put(NMTOKEN, nmtokenDV);
+
+ facets.minLength = 1;
+ tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null);
+ XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ builtInTypes.put(NMTOKENS, nmtokensDV);
+ } //createBuiltInTypes()
+
+ /**
+ * Create a new simple type which is derived by restriction from another
+ * simple type.
+ *
+ * @param name name of the new type, could be null
+ * @param targetNamespace target namespace of the new type, could be null
+ * @param finalSet value of "final"
+ * @param base base type of the new type
+ * @param annotations set of annotations
+ * @return the newly created simple type
+ */
+ public XSSimpleType createTypeRestriction(String name, String targetNamespace,
+ short finalSet, XSSimpleType base, XSObjectList annotations) {
+
+ if (fDeclPool != null) {
+ XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
+ return st.setRestrictionValues((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, annotations);
+ }
+ return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, false, annotations);
+ }
+
+ /**
+ * Create a new simple type which is derived by list from another simple
+ * type.
+ *
+ * @param name name of the new type, could be null
+ * @param targetNamespace target namespace of the new type, could be null
+ * @param finalSet value of "final"
+ * @param itemType item type of the list type
+ * @param annotations set of annotations
+ * @return the newly created simple type
+ */
+ public XSSimpleType createTypeList(String name, String targetNamespace,
+ short finalSet, XSSimpleType itemType,
+ XSObjectList annotations) {
+ if (fDeclPool != null) {
+ XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
+ return st.setListValues(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, annotations);
+ }
+ return new XSSimpleTypeDecl(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, false, annotations);
+ }
+
+ /**
+ * Create a new simple type which is derived by union from a list of other
+ * simple types.
+ *
+ * @param name name of the new type, could be null
+ * @param targetNamespace target namespace of the new type, could be null
+ * @param finalSet value of "final"
+ * @param memberTypes member types of the union type
+ * @param annotations set of annotations
+ * @return the newly created simple type
+ */
+ public XSSimpleType createTypeUnion(String name, String targetNamespace,
+ short finalSet, XSSimpleType[] memberTypes,
+ XSObjectList annotations) {
+ int typeNum = memberTypes.length;
+ XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
+ System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
+
+ if (fDeclPool != null) {
+ XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
+ return st.setUnionValues(name, targetNamespace, finalSet, mtypes, annotations);
+ }
+ return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations);
+ }
+
+ public void setDeclPool (XSDeclarationPool declPool){
+ fDeclPool = declPool;
+ }
+
+ /** Implementation internal **/
+ public XSSimpleTypeDecl newXSSimpleTypeDecl() {
+ return new XSSimpleTypeDecl();
+ }
+} //BaseSchemaDVFactory
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,11 +29,12 @@
/**
* Validator for datatype (W3C Schema datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystems Inc.
*
+ * @version $Id: DateDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class DateDV extends DateTimeDV {
@@ -85,8 +86,10 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(date.unNormYear, date.unNormMonth, date.unNormDay
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(date.unNormYear, date.unNormMonth,
+ date.unNormDay, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? (date.timezoneHr * 60 + date.timezoneMin) : DatatypeConstants.FIELD_UNDEFINED);
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,9 +20,9 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
-import java.math.BigDecimal;
import java.math.BigInteger;
+import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
@@ -31,11 +31,12 @@
/**
* Validator for <dateTime> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: DateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class DateTimeDV extends AbstractDateTimeDV {
@@ -87,7 +88,9 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(BigInteger.valueOf(date.unNormYear), date.unNormMonth, date.unNormDay
- , date.unNormHour, date.unNormMinute, (int)date.unNormSecond, date.unNormSecond != 0?new BigDecimal(date.unNormSecond - ((int)date.unNormSecond)):null, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(BigInteger.valueOf(date.unNormYear), date.unNormMonth,
+ date.unNormDay, date.unNormHour, date.unNormMinute,
+ (int)date.unNormSecond, date.unNormSecond != 0 ? getFractionalSecondsAsBigDecimal(date) : null,
+ date.hasTimeZone() ? (date.timezoneHr * 60 + date.timezoneMin) : DatatypeConstants.FIELD_UNDEFINED);
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,10 +29,11 @@
/**
* Validator for <gDay> datatype (W3C Schema datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
+ * @version $Id: DayDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class DayDV extends AbstractDateTimeDV {
@@ -109,8 +110,11 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.unNormDay
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.unNormDay, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
}
}
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -31,10 +31,11 @@
/**
* Used to validate the type
*
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Ankit Pasricha, IBM
- *
+ *
+ * @version $Id: DayTimeDurationDV.java,v 1.6 2010-11-01 04:39:46 joehw Exp $
*/
class DayTimeDurationDV extends DurationDV {
@@ -53,7 +54,7 @@
if (date.day<0 || date.hour<0 || date.minute<0 || date.second<0) {
sign = -1;
}
- return factory.newDuration(sign == 1, null, null,
+ return datatypeFactory.newDuration(sign == 1, null, null,
date.day != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.day):null,
date.hour != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.hour):null,
date.minute != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.minute):null,
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -27,11 +27,12 @@
/**
* Represent the schema type "double"
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: DoubleDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $
*/
public class DoubleDV extends TypeValidator {
@@ -80,7 +81,7 @@
}
private static final class XDouble implements XSDouble {
- private double value;
+ private final double value;
public XDouble(String s) throws NumberFormatException {
if (isPossibleFP(s)) {
value = Double.parseDouble(s);
@@ -117,6 +118,15 @@
return false;
}
+ public int hashCode() {
+ // This check is necessary because doubleToLongBits(+0) != doubleToLongBits(-0)
+ if (value == 0d) {
+ return 0;
+ }
+ long v = Double.doubleToLongBits(value);
+ return (int) (v ^ (v >>> 32));
+ }
+
// NOTE: 0.0 is equal but not identical to -0.0
public boolean isIdentical (XDouble val) {
if (val == this) {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,16 +32,17 @@
/**
* Validator for <duration> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
+ * @version $Id: DurationDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class DurationDV extends AbstractDateTimeDV {
- public static final int DURATION_TYPE = 0;
- public static final int YEARMONTHDURATION_TYPE = 1;
- public static final int DAYTIMEDURATION_TYPE = 2;
+ public static final int DURATION_TYPE = 0;
+ public static final int YEARMONTHDURATION_TYPE = 1;
+ public static final int DAYTIMEDURATION_TYPE = 2;
// order-relation on duration is a partial order. The dates below are used to
// for comparison of 2 durations, based on the fact that
// duration x and y is x<=y iff s+x<=s+y
@@ -341,7 +342,11 @@
if (dot+1 == end) {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
- return Double.parseDouble(buffer.substring(start, end));
+ double value = Double.parseDouble(buffer.substring(start, end));
+ if (value == Double.POSITIVE_INFINITY) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ return value;
}
protected String dateToString(DateTimeData date) {
@@ -362,7 +367,7 @@
message.append('H');
message.append((date.minute < 0?-1:1) * date.minute);
message.append('M');
- message.append((date.second < 0?-1:1) * date.second);
+ append2(message, (date.second < 0?-1:1) * date.second);
message.append('S');
return message.toString();
@@ -374,7 +379,7 @@
|| date.hour<0 || date.minute<0 || date.second<0) {
sign = -1;
}
- return factory.newDuration(sign == 1,
+ return datatypeFactory.newDuration(sign == 1,
date.year != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.year):null,
date.month != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.month):null,
date.day != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.day):null,
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,86 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.dv.xs;
+
+import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
+
+/**
+ * A special factory to create/return built-in schema DVs and create user-defined DVs
+ * that includes anyAtomicType, yearMonthDuration and dayTimeDuration
+ *
+ * @xerces.internal
+ *
+ * @author Khaled Noaman, IBM
+ *
+ * @version $Id: ExtendedSchemaDVFactoryImpl.java,v 1.2 2010-10-26 23:01:03 joehw Exp $
+ */
+public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory {
+
+ static SymbolHash fBuiltInTypes = new SymbolHash();
+ static {
+ createBuiltInTypes();
+ }
+
+ // create all built-in types
+ static void createBuiltInTypes() {
+ final String ANYATOMICTYPE = "anyAtomicType";
+ final String DURATION = "duration";
+ final String YEARMONTHDURATION = "yearMonthDuration";
+ final String DAYTIMEDURATION = "dayTimeDuration";
+
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add anyAtomicType
+ fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add 2 duration types
+ XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
+ fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
+ fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
+ } //createBuiltInTypes()
+
+ /**
+ * Get a built-in simple type of the given name
+ * REVISIT: its still not decided within the Schema WG how to define the
+ * ur-types and if all simple types should be derived from a
+ * complex type, so as of now we ignore the fact that anySimpleType
+ * is derived from anyType, and pass 'null' as the base of
+ * anySimpleType. It needs to be changed as per the decision taken.
+ *
+ * @param name the name of the datatype
+ * @return the datatype validator of the given name
+ */
+ public XSSimpleType getBuiltInType(String name) {
+ return (XSSimpleType)fBuiltInTypes.get(name);
+ }
+
+ /**
+ * get all built-in simple types, which are stored in a hashtable keyed by
+ * the name
+ *
+ * @return a hashtable which contains all built-in simple types
+ */
+ public SymbolHash getBuiltInTypes() {
+ return (SymbolHash)fBuiltInTypes.makeClone();
+ }
+}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -27,11 +27,12 @@
/**
* Represent the schema type "float"
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: FloatDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class FloatDV extends TypeValidator {
@@ -64,7 +65,7 @@
private static final class XFloat implements XSFloat {
- private float value;
+ private final float value;
public XFloat(String s) throws NumberFormatException {
if (DoubleDV.isPossibleFP(s)) {
value = Float.parseFloat(s);
@@ -101,6 +102,11 @@
return false;
}
+ public int hashCode() {
+ // This check is necessary because floatToIntBits(+0) != floatToIntBits(-0)
+ return (value == 0f) ? 0 : Float.floatToIntBits(value);
+ }
+
// NOTE: 0.0 is equal but not identical to -0.0
public boolean isIdentical (XFloat val) {
if (val == this) {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -28,11 +28,12 @@
/**
* Represent the schema type "hexBinary"
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: HexBinaryDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class HexBinaryDV extends TypeValidator {
@@ -79,5 +80,12 @@
return true;
}
+ public int hashCode() {
+ int hash = 0;
+ for (int i = 0; i < data.length; ++i) {
+ hash = hash * 37 + (((int) data[i]) & 0xff);
+ }
+ return hash;
+ }
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,8 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
+import java.util.AbstractList;
+
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
@@ -27,11 +29,12 @@
/**
* Represent the schema list types
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: ListDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class ListDV extends TypeValidator{
@@ -50,7 +53,7 @@
return ((ListData)value).getLength();
}
- final static class ListData implements ObjectList {
+ final static class ListData extends AbstractList implements ObjectList {
final Object[] data;
private String canonical;
public ListData(Object[] data) {
@@ -92,6 +95,14 @@
return true;
}
+ public int hashCode() {
+ int hash = 0;
+ for (int i = 0; i < data.length; ++i) {
+ hash ^= data[i].hashCode();
+ }
+ return hash;
+ }
+
public boolean contains(Object item) {
for (int i = 0;i < data.length; i++) {
if (item == data[i]) {
@@ -107,5 +118,21 @@
}
return data[index];
}
+
+ /*
+ * List methods
+ */
+
+ public Object get(int index) {
+ if (index >= 0 && index < data.length) {
+ return data[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
}
} // class ListDV
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,11 +29,12 @@
/**
* Validator for <gMonth> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: MonthDV.java,v 1.8 2010-11-01 04:39:47 joehw Exp $
*/
public class MonthDV extends AbstractDateTimeDV {
@@ -73,7 +74,6 @@
int stop = 4;
date.month=parseInt(str,2,stop);
- /*
// REVISIT: allow both --MM and --MM-- now.
// need to remove the following 4 lines to disallow --MM--
// when the errata is offically in the rec.
@@ -81,7 +81,6 @@
str.charAt(stop) == '-' && str.charAt(stop+1) == '-') {
stop += 2;
}
- */
if (stop < len) {
if (!isNextCharUTCSign(str, stop, len)) {
throw new SchemaDateTimeException ("Error in month parsing: "+str);
@@ -161,7 +160,9 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth, DatatypeConstants.FIELD_UNDEFINED
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,11 +29,12 @@
/**
* Validator for <gMonthDay> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: MonthDayDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class MonthDayDV extends AbstractDateTimeDV {
@@ -122,7 +123,10 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth, date.unNormDay
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(DatatypeConstants.FIELD_UNDEFINED, date.unNormMonth, date.unNormDay,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
}
}
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,34 +20,34 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
-import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
+
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
-import com.sun.org.apache.xerces.internal.impl.xs.XSDeclarationPool;
import com.sun.org.apache.xerces.internal.util.SymbolHash;
-import com.sun.org.apache.xerces.internal.xs.XSConstants;
-import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* the factory to create/return built-in schema DVs and create user-defined DVs
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: SchemaDVFactoryImpl.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
-public class SchemaDVFactoryImpl extends SchemaDVFactory {
+public class SchemaDVFactoryImpl extends BaseSchemaDVFactory {
- static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
+ static final SymbolHash fBuiltInTypes = new SymbolHash();
- static SymbolHash fBuiltInTypes = new SymbolHash();
static {
createBuiltInTypes();
}
- protected XSDeclarationPool fDeclPool = null;
+ // create all built-in types
+ static void createBuiltInTypes() {
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnySimpleType);
+
+ // TODO: move specific 1.0 DV implementation from base
+ } //createBuiltInTypes()
/**
* Get a built-in simple type of the given name
@@ -74,307 +74,4 @@
return (SymbolHash)fBuiltInTypes.makeClone();
}
- /**
- * Create a new simple type which is derived by restriction from another
- * simple type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param base base type of the new type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeRestriction(String name, String targetNamespace,
- short finalSet, XSSimpleType base, XSObjectList annotations) {
-
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setRestrictionValues((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, annotations);
- }
- return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by list from another simple
- * type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param itemType item type of the list type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType,
- XSObjectList annotations) {
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setListValues(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by union from a list of other
- * simple types.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param memberTypes member types of the union type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[] memberTypes,
- XSObjectList annotations) {
- int typeNum = memberTypes.length;
- XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
- System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
-
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setUnionValues(name, targetNamespace, finalSet, mtypes, annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations);
- }
-
- // create all built-in types
- static void createBuiltInTypes() {
- // all schema simple type names
- final String ANYSIMPLETYPE = "anySimpleType";
- final String ANYATOMICTYPE = "anyAtomicType";
- final String ANYURI = "anyURI";
- final String BASE64BINARY = "base64Binary";
- final String BOOLEAN = "boolean";
- final String BYTE = "byte";
- final String DATE = "date";
- final String DATETIME = "dateTime";
- final String DAY = "gDay";
- final String DECIMAL = "decimal";
- final String DOUBLE = "double";
- final String DURATION = "duration";
- final String ENTITY = "ENTITY";
- final String ENTITIES = "ENTITIES";
- final String FLOAT = "float";
- final String HEXBINARY = "hexBinary";
- final String ID = "ID";
- final String IDREF = "IDREF";
- final String IDREFS = "IDREFS";
- final String INT = "int";
- final String INTEGER = "integer";
- final String LONG = "long";
- final String NAME = "Name";
- final String NEGATIVEINTEGER = "negativeInteger";
- final String MONTH = "gMonth";
- final String MONTHDAY = "gMonthDay";
- final String NCNAME = "NCName";
- final String NMTOKEN = "NMTOKEN";
- final String NMTOKENS = "NMTOKENS";
- final String LANGUAGE = "language";
- final String NONNEGATIVEINTEGER= "nonNegativeInteger";
- final String NONPOSITIVEINTEGER= "nonPositiveInteger";
- final String NORMALIZEDSTRING = "normalizedString";
- final String NOTATION = "NOTATION";
- final String POSITIVEINTEGER = "positiveInteger";
- final String QNAME = "QName";
- final String SHORT = "short";
- final String STRING = "string";
- final String TIME = "time";
- final String TOKEN = "token";
- final String UNSIGNEDBYTE = "unsignedByte";
- final String UNSIGNEDINT = "unsignedInt";
- final String UNSIGNEDLONG = "unsignedLong";
- final String UNSIGNEDSHORT = "unsignedShort";
- final String YEAR = "gYear";
- final String YEARMONTH = "gYearMonth";
- final String YEARMONTHDURATION = "yearMonthDuration";
- final String DAYTIMEDURATION = "dayTimeDuration";
- final String PRECISIONDECIMAL = "precisionDecimal";
-
- final XSFacets facets = new XSFacets();
-
- //REVISIT: passing "anyType" here.
- XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType;
- XSSimpleTypeDecl anyAtomicType = XSSimpleTypeDecl.fAnyAtomicType;
- XSSimpleTypeDecl baseAtomicType = null;
-
- if (Constants.SCHEMA_1_1_SUPPORT) {
- baseAtomicType = anyAtomicType;
- fBuiltInTypes.put(ANYATOMICTYPE, anyAtomicType);
- }
- else {
- baseAtomicType = anySimpleType;
- }
-
- fBuiltInTypes.put(ANYSIMPLETYPE, anySimpleType);
- XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(baseAtomicType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.STRING_DT);
- fBuiltInTypes.put(STRING, stringDV);
- fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(baseAtomicType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false, true, XSConstants.BOOLEAN_DT));
- XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(baseAtomicType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.DECIMAL_DT);
- fBuiltInTypes.put(DECIMAL, decimalDV);
-
- fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(baseAtomicType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT));
- fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(baseAtomicType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT));
-
- XSSimpleTypeDecl durationDV = new XSSimpleTypeDecl(baseAtomicType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT);
- fBuiltInTypes.put(DURATION, durationDV);
-
- if (Constants.SCHEMA_1_1_SUPPORT) {
- fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
- fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
- fBuiltInTypes.put(PRECISIONDECIMAL, new XSSimpleTypeDecl(anySimpleType, PRECISIONDECIMAL, XSSimpleTypeDecl.DV_PRECISIONDECIMAL, XSSimpleType.ORDERED_PARTIAL, false, false, true, true, XSSimpleTypeDecl.PRECISIONDECIMAL_DT));
- }
-
- fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(baseAtomicType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT));
- fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(baseAtomicType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT));
- fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(baseAtomicType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT));
- fBuiltInTypes.put(YEARMONTH, new XSSimpleTypeDecl(baseAtomicType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEARMONTH_DT));
- fBuiltInTypes.put(YEAR, new XSSimpleTypeDecl(baseAtomicType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEAR_DT));
- fBuiltInTypes.put(MONTHDAY, new XSSimpleTypeDecl(baseAtomicType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTHDAY_DT));
- fBuiltInTypes.put(DAY, new XSSimpleTypeDecl(baseAtomicType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GDAY_DT));
- fBuiltInTypes.put(MONTH, new XSSimpleTypeDecl(baseAtomicType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTH_DT));
-
- XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, XSSimpleTypeDecl.DV_INTEGER, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.INTEGER_DT);
- fBuiltInTypes.put(INTEGER, integerDV);
-
- facets.maxInclusive = "0";
- XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONPOSITIVEINTEGER_DT);
- nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- fBuiltInTypes.put(NONPOSITIVEINTEGER, nonPositiveDV);
-
- facets.maxInclusive = "-1";
- XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT);
- negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- fBuiltInTypes.put(NEGATIVEINTEGER, negativeDV);
-
- facets.maxInclusive = "9223372036854775807";
- facets.minInclusive = "-9223372036854775808";
- XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LONG_DT);
- longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(LONG, longDV);
-
-
- facets.maxInclusive = "2147483647";
- facets.minInclusive = "-2147483648";
- XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.INT_DT);
- intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(INT, intDV);
-
- facets.maxInclusive = "32767";
- facets.minInclusive = "-32768";
- XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.SHORT_DT);
- shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(SHORT, shortDV);
-
- facets.maxInclusive = "127";
- facets.minInclusive = "-128";
- XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.BYTE_DT);
- byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(BYTE, byteDV);
-
- facets.minInclusive = "0" ;
- XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONNEGATIVEINTEGER_DT);
- nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- fBuiltInTypes.put(NONNEGATIVEINTEGER, nonNegativeDV);
-
- facets.maxInclusive = "18446744073709551615" ;
- XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDLONG_DT);
- unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDLONG, unsignedLongDV);
-
- facets.maxInclusive = "4294967295" ;
- XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDINT_DT);
- unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDINT, unsignedIntDV);
-
- facets.maxInclusive = "65535" ;
- XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDSHORT_DT);
- unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDSHORT, unsignedShortDV);
-
- facets.maxInclusive = "255" ;
- XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDBYTE_DT);
- unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDBYTE, unsignedByteDV);
-
- facets.minInclusive = "1" ;
- XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.POSITIVEINTEGER_DT);
- positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- fBuiltInTypes.put(POSITIVEINTEGER, positiveIntegerDV);
-
-
- fBuiltInTypes.put(FLOAT, new XSSimpleTypeDecl(baseAtomicType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.FLOAT_DT));
- fBuiltInTypes.put(DOUBLE, new XSSimpleTypeDecl(baseAtomicType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.DOUBLE_DT));
- fBuiltInTypes.put(HEXBINARY, new XSSimpleTypeDecl(baseAtomicType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.HEXBINARY_DT));
- fBuiltInTypes.put(NOTATION, new XSSimpleTypeDecl(baseAtomicType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.NOTATION_DT));
-
-
- facets.whiteSpace = XSSimpleType.WS_REPLACE;
- XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NORMALIZEDSTRING_DT);
- normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- fBuiltInTypes.put(NORMALIZEDSTRING, normalizedDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.TOKEN_DT);
- tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- fBuiltInTypes.put(TOKEN, tokenDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- facets.pattern = "([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*";
- XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LANGUAGE_DT);
- languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0);
- fBuiltInTypes.put(LANGUAGE, languageDV);
-
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NAME_DT);
- nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
- fBuiltInTypes.put(NAME, nameDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NCNAME_DT) ;
- ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
- fBuiltInTypes.put(NCNAME, ncnameDV);
-
- fBuiltInTypes.put(QNAME, new XSSimpleTypeDecl(baseAtomicType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.QNAME_DT));
-
- fBuiltInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.ID_DT));
- XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.IDREF_DT);
- fBuiltInTypes.put(IDREF, idrefDV);
-
- facets.minLength = 1;
- XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
- XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(IDREFS, idrefsDV);
-
- XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ENTITY_DT);
- fBuiltInTypes.put(ENTITY, entityDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null);
- XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(ENTITIES, entitiesDV);
-
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
- nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
- fBuiltInTypes.put(NMTOKEN, nmtokenDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null);
- XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(NMTOKENS, nmtokensDV);
- }//createBuiltInTypes()
-
- public void setDeclPool (XSDeclarationPool declPool){
- fDeclPool = declPool;
- }
-
}//SchemaDVFactoryImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,8 +20,6 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
-import java.math.BigDecimal;
-
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
@@ -30,12 +28,13 @@
/**
* Validator for <time> datatype (W3C Schema Datatypes)
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: TimeDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class TimeDV extends AbstractDateTimeDV {
@@ -82,6 +81,7 @@
if ( date.utc!=0 && date.utc != 'Z') {
normalize(date);
+ date.day = 15;
}
date.position = 2;
return date;
@@ -106,7 +106,9 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(null
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.unNormHour, date.unNormMinute, (int)date.unNormSecond, date.unNormSecond != 0?new BigDecimal(date.unNormSecond - ((int)date.unNormSecond)):null, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(null, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, date.unNormHour, date.unNormMinute,
+ (int)date.unNormSecond, date.unNormSecond != 0 ? getFractionalSecondsAsBigDecimal(date) : null,
+ date.hasTimeZone() ? (date.timezoneHr * 60 + date.timezoneMin) : DatatypeConstants.FIELD_UNDEFINED);
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.dv.xs;
+import java.util.AbstractList;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -59,516 +60,548 @@
* @author Sandy Gao, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
*
- * @version $Id: XSSimpleTypeDecl.java,v 1.9 2010/07/23 02:09:28 joehw Exp $
+ * @version $Id: XSSimpleTypeDecl.java,v 1.11 2010-11-01 04:39:47 joehw Exp $
*/
public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
-
- static final short DV_STRING = PRIMITIVE_STRING;
- static final short DV_BOOLEAN = PRIMITIVE_BOOLEAN;
- static final short DV_DECIMAL = PRIMITIVE_DECIMAL;
- static final short DV_FLOAT = PRIMITIVE_FLOAT;
- static final short DV_DOUBLE = PRIMITIVE_DOUBLE;
- static final short DV_DURATION = PRIMITIVE_DURATION;
- static final short DV_DATETIME = PRIMITIVE_DATETIME;
- static final short DV_TIME = PRIMITIVE_TIME;
- static final short DV_DATE = PRIMITIVE_DATE;
- static final short DV_GYEARMONTH = PRIMITIVE_GYEARMONTH;
- static final short DV_GYEAR = PRIMITIVE_GYEAR;
- static final short DV_GMONTHDAY = PRIMITIVE_GMONTHDAY;
- static final short DV_GDAY = PRIMITIVE_GDAY;
- static final short DV_GMONTH = PRIMITIVE_GMONTH;
- static final short DV_HEXBINARY = PRIMITIVE_HEXBINARY;
- static final short DV_BASE64BINARY = PRIMITIVE_BASE64BINARY;
- static final short DV_ANYURI = PRIMITIVE_ANYURI;
- static final short DV_QNAME = PRIMITIVE_QNAME;
- static final short DV_PRECISIONDECIMAL = PRIMITIVE_PRECISIONDECIMAL;
- static final short DV_NOTATION = PRIMITIVE_NOTATION;
-
- static final short DV_ANYSIMPLETYPE = 0;
- static final short DV_ID = DV_NOTATION + 1;
- static final short DV_IDREF = DV_NOTATION + 2;
- static final short DV_ENTITY = DV_NOTATION + 3;
- static final short DV_INTEGER = DV_NOTATION + 4;
- static final short DV_LIST = DV_NOTATION + 5;
- static final short DV_UNION = DV_NOTATION + 6;
- static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
- static final short DV_DAYTIMEDURATION = DV_NOTATION + 8;
- static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
-
- static final TypeValidator[] fDVs = {
- new AnySimpleDV(),
- new StringDV(),
- new BooleanDV(),
- new DecimalDV(),
- new FloatDV(),
- new DoubleDV(),
- new DurationDV(),
- new DateTimeDV(),
- new TimeDV(),
- new DateDV(),
- new YearMonthDV(),
- new YearDV(),
- new MonthDayDV(),
- new DayDV(),
- new MonthDV(),
- new HexBinaryDV(),
- new Base64BinaryDV(),
- new AnyURIDV(),
- new QNameDV(),
- new PrecisionDecimalDV(), // XML Schema 1.1 type
- new QNameDV(), // notation use the same one as qname
- new IDDV(),
- new IDREFDV(),
- new EntityDV(),
- new IntegerDV(),
- new ListDV(),
- new UnionDV(),
- new YearMonthDurationDV(), // XML Schema 1.1 type
- new DayTimeDurationDV(), // XML Schema 1.1 type
- new AnyAtomicDV() // XML Schema 1.1 type
- };
-
- static final short NORMALIZE_NONE = 0;
- static final short NORMALIZE_TRIM = 1;
- static final short NORMALIZE_FULL = 2;
- static final short[] fDVNormalizeType = {
- NORMALIZE_NONE, //AnySimpleDV(),
- NORMALIZE_FULL, //StringDV(),
- NORMALIZE_TRIM, //BooleanDV(),
- NORMALIZE_TRIM, //DecimalDV(),
- NORMALIZE_TRIM, //FloatDV(),
- NORMALIZE_TRIM, //DoubleDV(),
- NORMALIZE_TRIM, //DurationDV(),
- NORMALIZE_TRIM, //DateTimeDV(),
- NORMALIZE_TRIM, //TimeDV(),
- NORMALIZE_TRIM, //DateDV(),
- NORMALIZE_TRIM, //YearMonthDV(),
- NORMALIZE_TRIM, //YearDV(),
- NORMALIZE_TRIM, //MonthDayDV(),
- NORMALIZE_TRIM, //DayDV(),
- NORMALIZE_TRIM, //MonthDV(),
- NORMALIZE_TRIM, //HexBinaryDV(),
- NORMALIZE_NONE, //Base64BinaryDV(), // Base64 know how to deal with spaces
- NORMALIZE_TRIM, //AnyURIDV(),
- NORMALIZE_TRIM, //QNameDV(),
- NORMALIZE_TRIM, //PrecisionDecimalDV() (Schema 1.1)
- NORMALIZE_TRIM, //QNameDV(), // notation
- NORMALIZE_TRIM, //IDDV(),
- NORMALIZE_TRIM, //IDREFDV(),
- NORMALIZE_TRIM, //EntityDV(),
- NORMALIZE_TRIM, //IntegerDV(),
- NORMALIZE_FULL, //ListDV(),
- NORMALIZE_NONE, //UnionDV(),
- NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
- NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
- NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
- };
-
- static final short SPECIAL_PATTERN_NONE = 0;
- static final short SPECIAL_PATTERN_NMTOKEN = 1;
- static final short SPECIAL_PATTERN_NAME = 2;
- static final short SPECIAL_PATTERN_NCNAME = 3;
-
- static final String[] SPECIAL_PATTERN_STRING = {
- "NONE", "NMTOKEN", "Name", "NCName"
- };
-
- static final String[] WS_FACET_STRING = {
- "preserve", "replace", "collapse"
- };
-
- static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
- static final String ANY_TYPE = "anyType";
-
+
+ protected static final short DV_STRING = PRIMITIVE_STRING;
+ protected static final short DV_BOOLEAN = PRIMITIVE_BOOLEAN;
+ protected static final short DV_DECIMAL = PRIMITIVE_DECIMAL;
+ protected static final short DV_FLOAT = PRIMITIVE_FLOAT;
+ protected static final short DV_DOUBLE = PRIMITIVE_DOUBLE;
+ protected static final short DV_DURATION = PRIMITIVE_DURATION;
+ protected static final short DV_DATETIME = PRIMITIVE_DATETIME;
+ protected static final short DV_TIME = PRIMITIVE_TIME;
+ protected static final short DV_DATE = PRIMITIVE_DATE;
+ protected static final short DV_GYEARMONTH = PRIMITIVE_GYEARMONTH;
+ protected static final short DV_GYEAR = PRIMITIVE_GYEAR;
+ protected static final short DV_GMONTHDAY = PRIMITIVE_GMONTHDAY;
+ protected static final short DV_GDAY = PRIMITIVE_GDAY;
+ protected static final short DV_GMONTH = PRIMITIVE_GMONTH;
+ protected static final short DV_HEXBINARY = PRIMITIVE_HEXBINARY;
+ protected static final short DV_BASE64BINARY = PRIMITIVE_BASE64BINARY;
+ protected static final short DV_ANYURI = PRIMITIVE_ANYURI;
+ protected static final short DV_QNAME = PRIMITIVE_QNAME;
+ protected static final short DV_PRECISIONDECIMAL = PRIMITIVE_PRECISIONDECIMAL;
+ protected static final short DV_NOTATION = PRIMITIVE_NOTATION;
+
+ protected static final short DV_ANYSIMPLETYPE = 0;
+ protected static final short DV_ID = DV_NOTATION + 1;
+ protected static final short DV_IDREF = DV_NOTATION + 2;
+ protected static final short DV_ENTITY = DV_NOTATION + 3;
+ protected static final short DV_INTEGER = DV_NOTATION + 4;
+ protected static final short DV_LIST = DV_NOTATION + 5;
+ protected static final short DV_UNION = DV_NOTATION + 6;
+ protected static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
+ protected static final short DV_DAYTIMEDURATION = DV_NOTATION + 8;
+ protected static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
+
+ private static final TypeValidator[] gDVs = {
+ new AnySimpleDV(),
+ new StringDV(),
+ new BooleanDV(),
+ new DecimalDV(),
+ new FloatDV(),
+ new DoubleDV(),
+ new DurationDV(),
+ new DateTimeDV(),
+ new TimeDV(),
+ new DateDV(),
+ new YearMonthDV(),
+ new YearDV(),
+ new MonthDayDV(),
+ new DayDV(),
+ new MonthDV(),
+ new HexBinaryDV(),
+ new Base64BinaryDV(),
+ new AnyURIDV(),
+ new QNameDV(),
+ new PrecisionDecimalDV(), // XML Schema 1.1 type
+ new QNameDV(), // notation use the same one as qname
+ new IDDV(),
+ new IDREFDV(),
+ new EntityDV(),
+ new IntegerDV(),
+ new ListDV(),
+ new UnionDV(),
+ new YearMonthDurationDV(), // XML Schema 1.1 type
+ new DayTimeDurationDV(), // XML Schema 1.1 type
+ new AnyAtomicDV() // XML Schema 1.1 type
+ };
+
+ static final short NORMALIZE_NONE = 0;
+ static final short NORMALIZE_TRIM = 1;
+ static final short NORMALIZE_FULL = 2;
+ static final short[] fDVNormalizeType = {
+ NORMALIZE_NONE, //AnySimpleDV(),
+ NORMALIZE_FULL, //StringDV(),
+ NORMALIZE_TRIM, //BooleanDV(),
+ NORMALIZE_TRIM, //DecimalDV(),
+ NORMALIZE_TRIM, //FloatDV(),
+ NORMALIZE_TRIM, //DoubleDV(),
+ NORMALIZE_TRIM, //DurationDV(),
+ NORMALIZE_TRIM, //DateTimeDV(),
+ NORMALIZE_TRIM, //TimeDV(),
+ NORMALIZE_TRIM, //DateDV(),
+ NORMALIZE_TRIM, //YearMonthDV(),
+ NORMALIZE_TRIM, //YearDV(),
+ NORMALIZE_TRIM, //MonthDayDV(),
+ NORMALIZE_TRIM, //DayDV(),
+ NORMALIZE_TRIM, //MonthDV(),
+ NORMALIZE_TRIM, //HexBinaryDV(),
+ NORMALIZE_NONE, //Base64BinaryDV(), // Base64 know how to deal with spaces
+ NORMALIZE_TRIM, //AnyURIDV(),
+ NORMALIZE_TRIM, //QNameDV(),
+ NORMALIZE_TRIM, //PrecisionDecimalDV() (Schema 1.1)
+ NORMALIZE_TRIM, //QNameDV(), // notation
+ NORMALIZE_TRIM, //IDDV(),
+ NORMALIZE_TRIM, //IDREFDV(),
+ NORMALIZE_TRIM, //EntityDV(),
+ NORMALIZE_TRIM, //IntegerDV(),
+ NORMALIZE_FULL, //ListDV(),
+ NORMALIZE_NONE, //UnionDV(),
+ NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
+ NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
+ NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
+ };
+
+ static final short SPECIAL_PATTERN_NONE = 0;
+ static final short SPECIAL_PATTERN_NMTOKEN = 1;
+ static final short SPECIAL_PATTERN_NAME = 2;
+ static final short SPECIAL_PATTERN_NCNAME = 3;
+
+ static final String[] SPECIAL_PATTERN_STRING = {
+ "NONE", "NMTOKEN", "Name", "NCName"
+ };
+
+ static final String[] WS_FACET_STRING = {
+ "preserve", "replace", "collapse"
+ };
+
+ static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
+ static final String ANY_TYPE = "anyType";
+
// XML Schema 1.1 type constants
public static final short YEARMONTHDURATION_DT = 46;
- public static final short DAYTIMEDURATION_DT = 47;
+ public static final short DAYTIMEDURATION_DT = 47;
public static final short PRECISIONDECIMAL_DT = 48;
public static final short ANYATOMICTYPE_DT = 49;
-
- // DOM Level 3 TypeInfo Derivation Method constants
- static final int DERIVATION_ANY = 0;
- static final int DERIVATION_RESTRICTION = 1;
- static final int DERIVATION_EXTENSION = 2;
- static final int DERIVATION_UNION = 4;
- static final int DERIVATION_LIST = 8;
-
- static final ValidationContext fEmptyContext = new ValidationContext() {
- public boolean needFacetChecking() {
- return true;
- }
- public boolean needExtraChecking() {
- return false;
- }
- public boolean needToNormalize() {
- return true;
- }
- public boolean useNamespaces () {
- return true;
- }
- public boolean isEntityDeclared (String name) {
- return false;
- }
- public boolean isEntityUnparsed (String name) {
- return false;
- }
- public boolean isIdDeclared (String name) {
- return false;
- }
- public void addId(String name) {
- }
- public void addIdRef(String name) {
- }
- public String getSymbol (String symbol) {
- return symbol.intern();
- }
- public String getURI(String prefix) {
- return null;
- }
- public Locale getLocale() {
- return Locale.getDefault();
- }
- };
-
- // this will be true if this is a static XSSimpleTypeDecl
- // and hence must remain immutable (i.e., applyFacets
- // may not be permitted to have any effect).
- private boolean fIsImmutable = false;
-
- private XSSimpleTypeDecl fItemType;
- private XSSimpleTypeDecl[] fMemberTypes;
- // The most specific built-in type kind.
- private short fBuiltInKind;
-
- private String fTypeName;
- private String fTargetNamespace;
- private short fFinalSet = 0;
- private XSSimpleTypeDecl fBase;
- private short fVariety = -1;
- private short fValidationDV = -1;
-
- 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 Vector fPattern;
- private Vector fPatternStr;
- private Vector fEnumeration;
- private short[] fEnumerationType;
- private ShortList[] fEnumerationItemType; // used in case fenumerationType value is LIST or LISTOFUNION
+
+ // DOM Level 3 TypeInfo Derivation Method constants
+ static final int DERIVATION_ANY = 0;
+ static final int DERIVATION_RESTRICTION = 1;
+ static final int DERIVATION_EXTENSION = 2;
+ static final int DERIVATION_UNION = 4;
+ static final int DERIVATION_LIST = 8;
+
+ static final ValidationContext fEmptyContext = new ValidationContext() {
+ public boolean needFacetChecking() {
+ return true;
+ }
+ public boolean needExtraChecking() {
+ return false;
+ }
+ public boolean needToNormalize() {
+ return true;
+ }
+ public boolean useNamespaces () {
+ return true;
+ }
+ public boolean isEntityDeclared (String name) {
+ return false;
+ }
+ public boolean isEntityUnparsed (String name) {
+ return false;
+ }
+ public boolean isIdDeclared (String name) {
+ return false;
+ }
+ public void addId(String name) {
+ }
+ public void addIdRef(String name) {
+ }
+ public String getSymbol (String symbol) {
+ return symbol.intern();
+ }
+ public String getURI(String prefix) {
+ return null;
+ }
+ public Locale getLocale() {
+ return Locale.getDefault();
+ }
+ };
+
+ protected static TypeValidator[] getGDVs() {
+ return (TypeValidator[])gDVs.clone();
+ }
+ private TypeValidator[] fDVs = gDVs;
+ protected void setDVs(TypeValidator[] dvs) {
+ fDVs = dvs;
+ }
+
+ // this will be true if this is a static XSSimpleTypeDecl
+ // and hence must remain immutable (i.e., applyFacets
+ // may not be permitted to have any effect).
+ private boolean fIsImmutable = false;
+
+ private XSSimpleTypeDecl fItemType;
+ private XSSimpleTypeDecl[] fMemberTypes;
+ // The most specific built-in type kind.
+ private short fBuiltInKind;
+
+ private String fTypeName;
+ private String fTargetNamespace;
+ private short fFinalSet = 0;
+ private XSSimpleTypeDecl fBase;
+ private short fVariety = -1;
+ private short fValidationDV = -1;
+
+ 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 Vector fPattern;
+ private Vector fPatternStr;
+ private Vector fEnumeration;
+ private short[] fEnumerationType;
+ private ShortList[] fEnumerationItemType; // used in case fenumerationType value is LIST or LISTOFUNION
private ShortList fEnumerationTypeList;
private ObjectList fEnumerationItemTypeList;
- private StringList fLexicalPattern;
- private StringList fLexicalEnumeration;
- private ObjectList fActualEnumeration;
- private Object fMaxInclusive;
- private Object fMaxExclusive;
- private Object fMinExclusive;
- private Object fMinInclusive;
-
- // annotations for constraining facets
- public XSAnnotation lengthAnnotation;
- public XSAnnotation minLengthAnnotation;
- public XSAnnotation maxLengthAnnotation;
- public XSAnnotation whiteSpaceAnnotation;
- public XSAnnotation totalDigitsAnnotation;
- public XSAnnotation fractionDigitsAnnotation;
- public XSObjectListImpl patternAnnotations;
- public XSObjectList enumerationAnnotations;
- public XSAnnotation maxInclusiveAnnotation;
- public XSAnnotation maxExclusiveAnnotation;
- public XSAnnotation minInclusiveAnnotation;
- public XSAnnotation minExclusiveAnnotation;
-
- // facets as objects
- private XSObjectListImpl fFacets;
-
- // enumeration and pattern facets
- private XSObjectListImpl fMultiValueFacets;
-
- // simpleType annotations
- private XSObjectList fAnnotations = null;
-
- private short fPatternType = SPECIAL_PATTERN_NONE;
-
- // for fundamental facets
- private short fOrdered;
- private boolean fFinite;
- private boolean fBounded;
- private boolean fNumeric;
-
- // default constructor
- public XSSimpleTypeDecl(){}
-
- //Create a new built-in primitive types (and id/idref/entity/integer/yearMonthDuration)
- protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
- short ordered, boolean bounded, boolean finite,
- boolean numeric, boolean isImmutable, short builtInKind) {
- fIsImmutable = isImmutable;
- fBase = base;
- fTypeName = name;
- fTargetNamespace = URI_SCHEMAFORSCHEMA;
- // To simplify the code for anySimpleType, we treat it as an atomic type
- fVariety = VARIETY_ATOMIC;
- fValidationDV = validateDV;
- fFacetsDefined = FACET_WHITESPACE;
- if (validateDV == DV_STRING) {
- fWhiteSpace = WS_PRESERVE;
- } else {
- fWhiteSpace = WS_COLLAPSE;
- fFixedFacet = FACET_WHITESPACE;
- }
- this.fOrdered = ordered;
- this.fBounded = bounded;
- this.fFinite = finite;
- this.fNumeric = numeric;
- fAnnotations = null;
-
- // Specify the build in kind for this primitive type
- fBuiltInKind = builtInKind;
- }
-
- //Create a new simple type for restriction for built-in types
- protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
- XSObjectList annotations, short builtInKind) {
- this(base, name, uri, finalSet, isImmutable, annotations);
- // Specify the build in kind for this built-in type
- fBuiltInKind = builtInKind;
- }
-
- //Create a new simple type for restriction.
- protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
- XSObjectList annotations) {
- fBase = base;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = fBase.fVariety;
- fValidationDV = fBase.fValidationDV;
- switch (fVariety) {
- case VARIETY_ATOMIC:
- break;
- case VARIETY_LIST:
- fItemType = fBase.fItemType;
- break;
- case VARIETY_UNION:
- fMemberTypes = fBase.fMemberTypes;
- break;
- }
-
- // always inherit facets from the base.
- // in case a type is created, but applyFacets is not called
- fLength = fBase.fLength;
- fMinLength = fBase.fMinLength;
- fMaxLength = fBase.fMaxLength;
- fPattern = fBase.fPattern;
- fPatternStr = fBase.fPatternStr;
- fEnumeration = fBase.fEnumeration;
- fEnumerationType = fBase.fEnumerationType;
+ private StringList fLexicalPattern;
+ private StringList fLexicalEnumeration;
+ private ObjectList fActualEnumeration;
+ private Object fMaxInclusive;
+ private Object fMaxExclusive;
+ private Object fMinExclusive;
+ private Object fMinInclusive;
+
+ // annotations for constraining facets
+ public XSAnnotation lengthAnnotation;
+ public XSAnnotation minLengthAnnotation;
+ public XSAnnotation maxLengthAnnotation;
+ public XSAnnotation whiteSpaceAnnotation;
+ public XSAnnotation totalDigitsAnnotation;
+ public XSAnnotation fractionDigitsAnnotation;
+ public XSObjectListImpl patternAnnotations;
+ public XSObjectList enumerationAnnotations;
+ public XSAnnotation maxInclusiveAnnotation;
+ public XSAnnotation maxExclusiveAnnotation;
+ public XSAnnotation minInclusiveAnnotation;
+ public XSAnnotation minExclusiveAnnotation;
+
+ // facets as objects
+ private XSObjectListImpl fFacets;
+
+ // enumeration and pattern facets
+ private XSObjectListImpl fMultiValueFacets;
+
+ // simpleType annotations
+ private XSObjectList fAnnotations = null;
+
+ private short fPatternType = SPECIAL_PATTERN_NONE;
+
+ // for fundamental facets
+ private short fOrdered;
+ private boolean fFinite;
+ private boolean fBounded;
+ private boolean fNumeric;
+
+ // The namespace schema information item corresponding to the target namespace
+ // of the simple type definition, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
+
+ // default constructor
+ public XSSimpleTypeDecl(){}
+
+ //Create a new built-in primitive types (and id/idref/entity/integer/yearMonthDuration)
+ protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
+ short ordered, boolean bounded, boolean finite,
+ boolean numeric, boolean isImmutable, short builtInKind) {
+ fIsImmutable = isImmutable;
+ fBase = base;
+ fTypeName = name;
+ fTargetNamespace = URI_SCHEMAFORSCHEMA;
+ // To simplify the code for anySimpleType, we treat it as an atomic type
+ fVariety = VARIETY_ATOMIC;
+ fValidationDV = validateDV;
+ fFacetsDefined = FACET_WHITESPACE;
+ if (validateDV == DV_ANYSIMPLETYPE ||
+ validateDV == DV_ANYATOMICTYPE ||
+ validateDV == DV_STRING) {
+ fWhiteSpace = WS_PRESERVE;
+ }
+ else {
+ fWhiteSpace = WS_COLLAPSE;
+ fFixedFacet = FACET_WHITESPACE;
+ }
+ this.fOrdered = ordered;
+ this.fBounded = bounded;
+ this.fFinite = finite;
+ this.fNumeric = numeric;
+ fAnnotations = null;
+
+ // Specify the build in kind for this primitive type
+ fBuiltInKind = builtInKind;
+ }
+
+ //Create a new simple type for restriction for built-in types
+ protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
+ XSObjectList annotations, short builtInKind) {
+ this(base, name, uri, finalSet, isImmutable, annotations);
+ // Specify the build in kind for this built-in type
+ fBuiltInKind = builtInKind;
+ }
+
+ //Create a new simple type for restriction.
+ protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, String uri, short finalSet, boolean isImmutable,
+ XSObjectList annotations) {
+ fBase = base;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = fBase.fVariety;
+ fValidationDV = fBase.fValidationDV;
+ switch (fVariety) {
+ case VARIETY_ATOMIC:
+ break;
+ case VARIETY_LIST:
+ fItemType = fBase.fItemType;
+ break;
+ case VARIETY_UNION:
+ fMemberTypes = fBase.fMemberTypes;
+ break;
+ }
+
+ // always inherit facets from the base.
+ // in case a type is created, but applyFacets is not called
+ fLength = fBase.fLength;
+ fMinLength = fBase.fMinLength;
+ fMaxLength = fBase.fMaxLength;
+ fPattern = fBase.fPattern;
+ fPatternStr = fBase.fPatternStr;
+ fEnumeration = fBase.fEnumeration;
+ fEnumerationType = fBase.fEnumerationType;
fEnumerationItemType = fBase.fEnumerationItemType;
- fWhiteSpace = fBase.fWhiteSpace;
- fMaxExclusive = fBase.fMaxExclusive;
- fMaxInclusive = fBase.fMaxInclusive;
- fMinExclusive = fBase.fMinExclusive;
- fMinInclusive = fBase.fMinInclusive;
- fTotalDigits = fBase.fTotalDigits;
- fFractionDigits = fBase.fFractionDigits;
- fPatternType = fBase.fPatternType;
- fFixedFacet = fBase.fFixedFacet;
- fFacetsDefined = fBase.fFacetsDefined;
-
- //we also set fundamental facets information in case applyFacets is not called.
- caclFundamentalFacets();
- fIsImmutable = isImmutable;
-
- // Inherit from the base type
- fBuiltInKind = base.fBuiltInKind;
- }
-
- //Create a new simple type for list.
- protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable,
- XSObjectList annotations) {
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_LIST;
- fItemType = (XSSimpleTypeDecl)itemType;
- fValidationDV = DV_LIST;
- fFacetsDefined = FACET_WHITESPACE;
- fFixedFacet = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- caclFundamentalFacets();
- fIsImmutable = isImmutable;
-
- // Values of this type are lists
- fBuiltInKind = XSConstants.LIST_DT;
- }
-
- //Create a new simple type for union.
- protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
- XSObjectList annotations) {
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_UNION;
- fMemberTypes = memberTypes;
- fValidationDV = DV_UNION;
- // even for union, we set whitespace to something
- // this will never be used, but we can use fFacetsDefined to check
- // whether applyFacets() is allwwed: it's not allowed
- // if fFacetsDefined != 0
- fFacetsDefined = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- caclFundamentalFacets();
- // none of the schema-defined types are unions, so just set
- // fIsImmutable to false.
- fIsImmutable = false;
-
- // No value can be of this type, so it's unavailable.
- fBuiltInKind = XSConstants.UNAVAILABLE_DT;
- }
-
- //set values for restriction.
- protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base, String name, String uri, short finalSet,
- XSObjectList annotations) {
- //decline to do anything if the object is immutable.
- if(fIsImmutable) return null;
- fBase = base;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = fBase.fVariety;
- fValidationDV = fBase.fValidationDV;
- switch (fVariety) {
- case VARIETY_ATOMIC:
- break;
- case VARIETY_LIST:
- fItemType = fBase.fItemType;
- break;
- case VARIETY_UNION:
- fMemberTypes = fBase.fMemberTypes;
- break;
- }
-
- // always inherit facets from the base.
- // in case a type is created, but applyFacets is not called
- fLength = fBase.fLength;
- fMinLength = fBase.fMinLength;
- fMaxLength = fBase.fMaxLength;
- fPattern = fBase.fPattern;
- fPatternStr = fBase.fPatternStr;
- fEnumeration = fBase.fEnumeration;
- fEnumerationType = fBase.fEnumerationType;
- fEnumerationItemType = fBase.fEnumerationItemType;
- fWhiteSpace = fBase.fWhiteSpace;
- fMaxExclusive = fBase.fMaxExclusive;
- fMaxInclusive = fBase.fMaxInclusive;
- fMinExclusive = fBase.fMinExclusive;
- fMinInclusive = fBase.fMinInclusive;
- fTotalDigits = fBase.fTotalDigits;
- fFractionDigits = fBase.fFractionDigits;
- fPatternType = fBase.fPatternType;
- fFixedFacet = fBase.fFixedFacet;
- fFacetsDefined = fBase.fFacetsDefined;
-
- //we also set fundamental facets information in case applyFacets is not called.
- caclFundamentalFacets();
-
+ fWhiteSpace = fBase.fWhiteSpace;
+ fMaxExclusive = fBase.fMaxExclusive;
+ fMaxInclusive = fBase.fMaxInclusive;
+ fMinExclusive = fBase.fMinExclusive;
+ fMinInclusive = fBase.fMinInclusive;
+ fTotalDigits = fBase.fTotalDigits;
+ fFractionDigits = fBase.fFractionDigits;
+ fPatternType = fBase.fPatternType;
+ fFixedFacet = fBase.fFixedFacet;
+ fFacetsDefined = fBase.fFacetsDefined;
+
+ // always inherit facet annotations in case applyFacets is not called.
+ lengthAnnotation = fBase.lengthAnnotation;
+ minLengthAnnotation = fBase.minLengthAnnotation;
+ maxLengthAnnotation = fBase.maxLengthAnnotation;
+ patternAnnotations = fBase.patternAnnotations;
+ enumerationAnnotations = fBase.enumerationAnnotations;
+ whiteSpaceAnnotation = fBase.whiteSpaceAnnotation;
+ maxExclusiveAnnotation = fBase.maxExclusiveAnnotation;
+ maxInclusiveAnnotation = fBase.maxInclusiveAnnotation;
+ minExclusiveAnnotation = fBase.minExclusiveAnnotation;
+ minInclusiveAnnotation = fBase.minInclusiveAnnotation;
+ totalDigitsAnnotation = fBase.totalDigitsAnnotation;
+ fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
+
+ //we also set fundamental facets information in case applyFacets is not called.
+ calcFundamentalFacets();
+ fIsImmutable = isImmutable;
+
// Inherit from the base type
fBuiltInKind = base.fBuiltInKind;
-
- return this;
- }
-
- //set values for list.
- protected XSSimpleTypeDecl setListValues(String name, String uri, short finalSet, XSSimpleTypeDecl itemType,
- XSObjectList annotations) {
- //decline to do anything if the object is immutable.
- if(fIsImmutable) return null;
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_LIST;
- fItemType = (XSSimpleTypeDecl)itemType;
- fValidationDV = DV_LIST;
- fFacetsDefined = FACET_WHITESPACE;
- fFixedFacet = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- caclFundamentalFacets();
-
+ }
+
+ //Create a new simple type for list.
+ protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable,
+ XSObjectList annotations) {
+ fBase = fAnySimpleType;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = VARIETY_LIST;
+ fItemType = (XSSimpleTypeDecl)itemType;
+ fValidationDV = DV_LIST;
+ fFacetsDefined = FACET_WHITESPACE;
+ fFixedFacet = FACET_WHITESPACE;
+ fWhiteSpace = WS_COLLAPSE;
+
+ //setting fundamental facets
+ calcFundamentalFacets();
+ fIsImmutable = isImmutable;
+
// Values of this type are lists
fBuiltInKind = XSConstants.LIST_DT;
-
- return this;
- }
-
- //set values for union.
- protected XSSimpleTypeDecl setUnionValues(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
- XSObjectList annotations) {
- //decline to do anything if the object is immutable.
- if(fIsImmutable) return null;
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_UNION;
- fMemberTypes = memberTypes;
- fValidationDV = DV_UNION;
- // even for union, we set whitespace to something
- // this will never be used, but we can use fFacetsDefined to check
- // whether applyFacets() is allwwed: it's not allowed
- // if fFacetsDefined != 0
- fFacetsDefined = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- caclFundamentalFacets();
-
+ }
+
+ //Create a new simple type for union.
+ protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
+ XSObjectList annotations) {
+ fBase = fAnySimpleType;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = VARIETY_UNION;
+ fMemberTypes = memberTypes;
+ fValidationDV = DV_UNION;
+ // even for union, we set whitespace to something
+ // this will never be used, but we can use fFacetsDefined to check
+ // whether applyFacets() is allwwed: it's not allowed
+ // if fFacetsDefined != 0
+ fFacetsDefined = FACET_WHITESPACE;
+ fWhiteSpace = WS_COLLAPSE;
+
+ //setting fundamental facets
+ calcFundamentalFacets();
+ // none of the schema-defined types are unions, so just set
+ // fIsImmutable to false.
+ fIsImmutable = false;
+
// No value can be of this type, so it's unavailable.
fBuiltInKind = XSConstants.UNAVAILABLE_DT;
-
- return this;
- }
-
- public short getType () {
- return XSConstants.TYPE_DEFINITION;
- }
-
- public short getTypeCategory () {
- return SIMPLE_TYPE;
- }
-
- public String getName() {
- return getAnonymous()?null:fTypeName;
- }
-
+ }
+
+ //set values for restriction.
+ protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base, String name, String uri, short finalSet,
+ XSObjectList annotations) {
+ //decline to do anything if the object is immutable.
+ if(fIsImmutable) return null;
+ fBase = base;
+ fAnonymous = false;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = fBase.fVariety;
+ fValidationDV = fBase.fValidationDV;
+ switch (fVariety) {
+ case VARIETY_ATOMIC:
+ break;
+ case VARIETY_LIST:
+ fItemType = fBase.fItemType;
+ break;
+ case VARIETY_UNION:
+ fMemberTypes = fBase.fMemberTypes;
+ break;
+ }
+
+ // always inherit facets from the base.
+ // in case a type is created, but applyFacets is not called
+ fLength = fBase.fLength;
+ fMinLength = fBase.fMinLength;
+ fMaxLength = fBase.fMaxLength;
+ fPattern = fBase.fPattern;
+ fPatternStr = fBase.fPatternStr;
+ fEnumeration = fBase.fEnumeration;
+ fEnumerationType = fBase.fEnumerationType;
+ fEnumerationItemType = fBase.fEnumerationItemType;
+ fWhiteSpace = fBase.fWhiteSpace;
+ fMaxExclusive = fBase.fMaxExclusive;
+ fMaxInclusive = fBase.fMaxInclusive;
+ fMinExclusive = fBase.fMinExclusive;
+ fMinInclusive = fBase.fMinInclusive;
+ fTotalDigits = fBase.fTotalDigits;
+ fFractionDigits = fBase.fFractionDigits;
+ fPatternType = fBase.fPatternType;
+ fFixedFacet = fBase.fFixedFacet;
+ fFacetsDefined = fBase.fFacetsDefined;
+
+ //we also set fundamental facets information in case applyFacets is not called.
+ calcFundamentalFacets();
+
+ // Inherit from the base type
+ fBuiltInKind = base.fBuiltInKind;
+
+ return this;
+ }
+
+ //set values for list.
+ protected XSSimpleTypeDecl setListValues(String name, String uri, short finalSet, XSSimpleTypeDecl itemType,
+ XSObjectList annotations) {
+ //decline to do anything if the object is immutable.
+ if(fIsImmutable) return null;
+ fBase = fAnySimpleType;
+ fAnonymous = false;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = VARIETY_LIST;
+ fItemType = (XSSimpleTypeDecl)itemType;
+ fValidationDV = DV_LIST;
+ fFacetsDefined = FACET_WHITESPACE;
+ fFixedFacet = FACET_WHITESPACE;
+ fWhiteSpace = WS_COLLAPSE;
+
+ //setting fundamental facets
+ calcFundamentalFacets();
+
+ // Values of this type are lists
+ fBuiltInKind = XSConstants.LIST_DT;
+
+ return this;
+ }
+
+ //set values for union.
+ protected XSSimpleTypeDecl setUnionValues(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
+ XSObjectList annotations) {
+ //decline to do anything if the object is immutable.
+ if(fIsImmutable) return null;
+ fBase = fAnySimpleType;
+ fAnonymous = false;
+ fTypeName = name;
+ fTargetNamespace = uri;
+ fFinalSet = finalSet;
+ fAnnotations = annotations;
+
+ fVariety = VARIETY_UNION;
+ fMemberTypes = memberTypes;
+ fValidationDV = DV_UNION;
+ // even for union, we set whitespace to something
+ // this will never be used, but we can use fFacetsDefined to check
+ // whether applyFacets() is allwwed: it's not allowed
+ // if fFacetsDefined != 0
+ fFacetsDefined = FACET_WHITESPACE;
+ fWhiteSpace = WS_COLLAPSE;
+
+ //setting fundamental facets
+ calcFundamentalFacets();
+
+ // No value can be of this type, so it's unavailable.
+ fBuiltInKind = XSConstants.UNAVAILABLE_DT;
+
+ return this;
+ }
+
+ public short getType () {
+ return XSConstants.TYPE_DEFINITION;
+ }
+
+ public short getTypeCategory () {
+ return SIMPLE_TYPE;
+ }
+
+ public String getName() {
+ return getAnonymous()?null:fTypeName;
+ }
+
public String getTypeName() {
return fTypeName;
}
@@ -600,15 +633,15 @@
public boolean isIDType(){
switch (fVariety) {
- case VARIETY_ATOMIC:
- return fValidationDV == DV_ID;
- case VARIETY_LIST:
- return fItemType.isIDType();
- case VARIETY_UNION:
- for (int i = 0; i < fMemberTypes.length; i++) {
- if (fMemberTypes[i].isIDType())
- return true;
- }
+ case VARIETY_ATOMIC:
+ return fValidationDV == DV_ID;
+ case VARIETY_LIST:
+ return fItemType.isIDType();
+ case VARIETY_UNION:
+ for (int i = 0; i < fMemberTypes.length; i++) {
+ if (fMemberTypes[i].isIDType())
+ return true;
+ }
}
return false;
}
@@ -622,25 +655,25 @@
public short getPrimitiveKind() {
if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
- if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
- return DV_STRING;
- }
- else if (fValidationDV == DV_INTEGER) {
- return DV_DECIMAL;
- }
- else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
- return DV_DURATION;
- }
- else {
- return fValidationDV;
- }
+ if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
+ return DV_STRING;
+ }
+ else if (fValidationDV == DV_INTEGER) {
+ return DV_DECIMAL;
+ }
+ else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
+ return DV_DURATION;
+ }
+ else {
+ return fValidationDV;
+ }
}
else {
- // REVISIT: error situation. runtime exception?
- return (short)0;
+ // REVISIT: error situation. runtime exception?
+ return (short)0;
}
}
-
+
/**
* Returns the closest built-in type category this type represents or
* derived from. For example, if this simple type is a built-in derived
@@ -694,8 +727,7 @@
return new XSObjectListImpl(fMemberTypes, fMemberTypes.length);
}
else {
- // REVISIT: error situation. runtime exception?
- return null;
+ return XSObjectListImpl.EMPTY_LIST;
}
}
@@ -703,7 +735,10 @@
* If is chosen
*/
public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
- throws InvalidDatatypeFacetException {
+ throws InvalidDatatypeFacetException {
+ if (context == null) {
+ context = fEmptyContext;
+ }
applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, context);
}
@@ -741,7 +776,7 @@
* If is chosen, or built-in derived types by restriction
*/
void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context)
- throws InvalidDatatypeFacetException {
+ throws InvalidDatatypeFacetException {
// if the object is immutable, should not apply facets...
if(fIsImmutable) return;
@@ -807,8 +842,8 @@
RegularExpression regex = null;
try {
regex = new RegularExpression(facets.pattern, "X", context.getLocale());
- } catch (ParseException e) {
- reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage(), new Integer(e.getLocation())});
+ } catch (Exception e) {
+ reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
}
if (regex != null) {
fPattern = new Vector();
@@ -822,36 +857,6 @@
}
}
- // enumeration
- if ((presentFacet & FACET_ENUMERATION) != 0) {
- if ((allowedFacet & FACET_ENUMERATION) == 0) {
- reportError("cos-applicable-facets", new Object[]{"enumeration", fTypeName});
- } else {
- fEnumeration = new Vector();
- Vector enumVals = facets.enumeration;
- fEnumerationType = new short[enumVals.size()];
- fEnumerationItemType = new ShortList[enumVals.size()];
- Vector enumNSDecls = facets.enumNSDecls;
- ValidationContextImpl ctx = new ValidationContextImpl(context);
- enumerationAnnotations = facets.enumAnnotations;
- for (int i = 0; i < enumVals.size(); i++) {
- if (enumNSDecls != null)
- ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
- try {
- ValidatedInfo info = this.fBase.validateWithInfo((String)enumVals.elementAt(i), ctx, tempInfo);
- // check 4.3.5.c0 must: enumeration values from the value space of base
- fEnumeration.addElement(info.actualValue);
- fEnumerationType[i] = info.actualValueType;
- fEnumerationItemType[i] = info.itemValueTypes;
- } catch (InvalidDatatypeValueException ide) {
- reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()});
- }
- }
- fFacetsDefined |= FACET_ENUMERATION;
- if ((fixedFacet & FACET_ENUMERATION) != 0)
- fFixedFacet |= FACET_ENUMERATION;
- }
- }
// whiteSpace
if ((presentFacet & FACET_WHITESPACE) != 0) {
if ((allowedFacet & FACET_WHITESPACE) == 0) {
@@ -864,6 +869,36 @@
fFixedFacet |= FACET_WHITESPACE;
}
}
+ // enumeration
+ if ((presentFacet & FACET_ENUMERATION) != 0) {
+ if ((allowedFacet & FACET_ENUMERATION) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"enumeration", fTypeName});
+ } else {
+ fEnumeration = new Vector();
+ Vector enumVals = facets.enumeration;
+ fEnumerationType = new short[enumVals.size()];
+ fEnumerationItemType = new ShortList[enumVals.size()];
+ Vector enumNSDecls = facets.enumNSDecls;
+ ValidationContextImpl ctx = new ValidationContextImpl(context);
+ enumerationAnnotations = facets.enumAnnotations;
+ for (int i = 0; i < enumVals.size(); i++) {
+ if (enumNSDecls != null)
+ ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
+ try {
+ ValidatedInfo info = getActualEnumValue((String)enumVals.elementAt(i), ctx, tempInfo);
+ // check 4.3.5.c0 must: enumeration values from the value space of base
+ fEnumeration.addElement(info.actualValue);
+ fEnumerationType[i] = info.actualValueType;
+ fEnumerationItemType[i] = info.itemValueTypes;
+ } catch (InvalidDatatypeValueException ide) {
+ reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()});
+ }
+ }
+ fFacetsDefined |= FACET_ENUMERATION;
+ if ((fixedFacet & FACET_ENUMERATION) != 0)
+ fFixedFacet |= FACET_ENUMERATION;
+ }
+ }
// maxInclusive
if ((presentFacet & FACET_MAXINCLUSIVE) != 0) {
@@ -879,23 +914,23 @@
} catch (InvalidDatatypeValueException ide) {
reportError(ide.getKey(), ide.getArgs());
reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
- "maxInclusive", fBase.getName()});
+ "maxInclusive", fBase.getName()});
}
// check against fixed value in base
if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0) {
- if (fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive) != 0)
- reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
- }
+ if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0) {
+ if (fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive) != 0)
+ reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
+ }
}
// maxInclusive from base
try {
- fBase.validate(context, tempInfo);
+ fBase.validate(context, tempInfo);
} catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
- "maxInclusive", fBase.getName()});
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
+ "maxInclusive", fBase.getName()});
}
}
}
@@ -903,129 +938,129 @@
// maxExclusive
boolean needCheckBase = true;
if ((presentFacet & FACET_MAXEXCLUSIVE) != 0) {
- if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
- reportError("cos-applicable-facets", new Object[]{"maxExclusive", fTypeName});
- } else {
- maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
- try {
- fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
- fFacetsDefined |= FACET_MAXEXCLUSIVE;
- if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
- fFixedFacet |= FACET_MAXEXCLUSIVE;
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
- "maxExclusive", fBase.getName()});
- }
-
- // check against fixed value in base
- if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
- if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"maxExclusive", facets.maxExclusive, fBase.fMaxExclusive, fTypeName});
- }
- if (result == 0) {
- needCheckBase = false;
- }
- }
- // maxExclusive from base
- if (needCheckBase) {
- try {
- fBase.validate(context, tempInfo);
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
- "maxExclusive", fBase.getName()});
- }
- }
- // If maxExclusive == base.maxExclusive, then we only need to check
- // maxExclusive <= base.maxInclusive
- else if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- if (fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive) > 0) {
- reportError( "maxExclusive-valid-restriction.2", new Object[]{facets.maxExclusive, fBase.fMaxInclusive});
- }
- }
+ if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"maxExclusive", fTypeName});
+ } else {
+ maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
+ try {
+ fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
+ fFacetsDefined |= FACET_MAXEXCLUSIVE;
+ if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
+ fFixedFacet |= FACET_MAXEXCLUSIVE;
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
+ "maxExclusive", fBase.getName()});
}
+
+ // check against fixed value in base
+ if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
+ if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"maxExclusive", facets.maxExclusive, fBase.fMaxExclusive, fTypeName});
+ }
+ if (result == 0) {
+ needCheckBase = false;
+ }
+ }
+ // maxExclusive from base
+ if (needCheckBase) {
+ try {
+ fBase.validate(context, tempInfo);
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxExclusive,
+ "maxExclusive", fBase.getName()});
+ }
+ }
+ // If maxExclusive == base.maxExclusive, then we only need to check
+ // maxExclusive <= base.maxInclusive
+ else if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ if (fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive) > 0) {
+ reportError( "maxExclusive-valid-restriction.2", new Object[]{facets.maxExclusive, fBase.fMaxInclusive});
+ }
+ }
+ }
}
// minExclusive
needCheckBase = true;
if ((presentFacet & FACET_MINEXCLUSIVE) != 0) {
- if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
- reportError("cos-applicable-facets", new Object[]{"minExclusive", fTypeName});
- } else {
- minExclusiveAnnotation = facets.minExclusiveAnnotation;
- try {
- fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
- fFacetsDefined |= FACET_MINEXCLUSIVE;
- if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
- fFixedFacet |= FACET_MINEXCLUSIVE;
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
- "minExclusive", fBase.getName()});
- }
-
- // check against fixed value in base
- if (((fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
- if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"minExclusive", facets.minExclusive, fBase.fMinExclusive, fTypeName});
- }
- if (result == 0) {
- needCheckBase = false;
- }
- }
- // minExclusive from base
- if (needCheckBase) {
- try {
- fBase.validate(context, tempInfo);
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
- "minExclusive", fBase.getName()});
- }
- }
- // If minExclusive == base.minExclusive, then we only need to check
- // minExclusive >= base.minInclusive
- else if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- if (fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive) < 0) {
- reportError( "minExclusive-valid-restriction.3", new Object[]{facets.minExclusive, fBase.fMinInclusive});
- }
- }
+ if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"minExclusive", fTypeName});
+ } else {
+ minExclusiveAnnotation = facets.minExclusiveAnnotation;
+ try {
+ fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
+ fFacetsDefined |= FACET_MINEXCLUSIVE;
+ if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
+ fFixedFacet |= FACET_MINEXCLUSIVE;
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
+ "minExclusive", fBase.getName()});
}
+
+ // check against fixed value in base
+ if (((fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
+ if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"minExclusive", facets.minExclusive, fBase.fMinExclusive, fTypeName});
+ }
+ if (result == 0) {
+ needCheckBase = false;
+ }
+ }
+ // minExclusive from base
+ if (needCheckBase) {
+ try {
+ fBase.validate(context, tempInfo);
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minExclusive,
+ "minExclusive", fBase.getName()});
+ }
+ }
+ // If minExclusive == base.minExclusive, then we only need to check
+ // minExclusive >= base.minInclusive
+ else if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ if (fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive) < 0) {
+ reportError( "minExclusive-valid-restriction.3", new Object[]{facets.minExclusive, fBase.fMinInclusive});
+ }
+ }
+ }
}
// minInclusive
if ((presentFacet & FACET_MININCLUSIVE) != 0) {
if ((allowedFacet & FACET_MININCLUSIVE) == 0) {
- reportError("cos-applicable-facets", new Object[]{"minInclusive", fTypeName});
+ reportError("cos-applicable-facets", new Object[]{"minInclusive", fTypeName});
} else {
- minInclusiveAnnotation = facets.minInclusiveAnnotation;
- try {
- fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
- fFacetsDefined |= FACET_MININCLUSIVE;
- if ((fixedFacet & FACET_MININCLUSIVE) != 0)
- fFixedFacet |= FACET_MININCLUSIVE;
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
- "minInclusive", fBase.getName()});
+ minInclusiveAnnotation = facets.minInclusiveAnnotation;
+ try {
+ fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
+ fFacetsDefined |= FACET_MININCLUSIVE;
+ if ((fixedFacet & FACET_MININCLUSIVE) != 0)
+ fFixedFacet |= FACET_MININCLUSIVE;
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
+ "minInclusive", fBase.getName()});
+ }
+
+ // check against fixed value in base
+ if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0) {
+ if (fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive) != 0)
+ reportError( "FixedFacetValue", new Object[]{"minInclusive", facets.minInclusive, fBase.fMinInclusive, fTypeName});
}
-
- // check against fixed value in base
- if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0) {
- if (fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive) != 0)
- reportError( "FixedFacetValue", new Object[]{"minInclusive", facets.minInclusive, fBase.fMinInclusive, fTypeName});
- }
- }
- // minInclusive from base
- try {
- fBase.validate(context, tempInfo);
- } catch (InvalidDatatypeValueException ide) {
- reportError(ide.getKey(), ide.getArgs());
- reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
- "minInclusive", fBase.getName()});
- }
+ }
+ // minInclusive from base
+ try {
+ fBase.validate(context, tempInfo);
+ } catch (InvalidDatatypeValueException ide) {
+ reportError(ide.getKey(), ide.getArgs());
+ reportError("FacetValueFromBase", new Object[]{fTypeName, facets.minInclusive,
+ "minInclusive", fBase.getName()});
+ }
}
}
@@ -1062,29 +1097,11 @@
// step 2: check facets against each other: length, bounds
if(fFacetsDefined != 0) {
- // check 4.3.1.c1 error: length & (maxLength | minLength)
- if((fFacetsDefined & FACET_LENGTH) != 0 ){
- if ((fFacetsDefined & FACET_MINLENGTH) != 0) {
- if ((fFacetsDefined & FACET_MAXLENGTH) != 0) {
- // length, minLength and maxLength defined
- reportError("length-minLength-maxLength.a", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fMinLength), Integer.toString(fMaxLength)});
- }
- else {
- // length and minLength defined
- reportError("length-minLength-maxLength.b", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fMinLength)});
- }
- }
- else if ((fFacetsDefined & FACET_MAXLENGTH) != 0) {
- // length and maxLength defined
- reportError("length-minLength-maxLength.c", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fMaxLength)});
- }
- }
-
// check 4.3.2.c1 must: minLength <= maxLength
if(((fFacetsDefined & FACET_MINLENGTH ) != 0 ) && ((fFacetsDefined & FACET_MAXLENGTH) != 0))
{
- if(fMinLength > fMaxLength)
- reportError("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fMinLength), Integer.toString(fMaxLength), fTypeName});
+ if(fMinLength > fMaxLength)
+ reportError("minLength-less-than-equal-to-maxLength", new Object[]{Integer.toString(fMinLength), Integer.toString(fMaxLength), fTypeName});
}
// check 4.3.8.c1 error: maxInclusive + maxExclusive
@@ -1099,33 +1116,33 @@
// check 4.3.7.c1 must: minInclusive <= maxInclusive
if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMinInclusive, fMaxInclusive);
- if (result != -1 && result != 0)
- reportError("minInclusive-less-than-equal-to-maxInclusive", new Object[]{fMinInclusive, fMaxInclusive, fTypeName});
+ result = fDVs[fValidationDV].compare(fMinInclusive, fMaxInclusive);
+ if (result != -1 && result != 0)
+ reportError("minInclusive-less-than-equal-to-maxInclusive", new Object[]{fMinInclusive, fMaxInclusive, fTypeName});
}
// check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMinExclusive, fMaxExclusive);
- if (result != -1 && result != 0)
- reportError( "minExclusive-less-than-equal-to-maxExclusive", new Object[]{fMinExclusive, fMaxExclusive, fTypeName});
+ result = fDVs[fValidationDV].compare(fMinExclusive, fMaxExclusive);
+ if (result != -1 && result != 0)
+ reportError( "minExclusive-less-than-equal-to-maxExclusive", new Object[]{fMinExclusive, fMaxExclusive, fTypeName});
}
// check 4.3.9.c2 must: minExclusive < maxInclusive
if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
- if (fDVs[fValidationDV].compare(fMinExclusive, fMaxInclusive) != -1)
- reportError( "minExclusive-less-than-maxInclusive", new Object[]{fMinExclusive, fMaxInclusive, fTypeName});
+ if (fDVs[fValidationDV].compare(fMinExclusive, fMaxInclusive) != -1)
+ reportError( "minExclusive-less-than-maxInclusive", new Object[]{fMinExclusive, fMaxInclusive, fTypeName});
}
// check 4.3.10.c1 must: minInclusive < maxExclusive
if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- if (fDVs[fValidationDV].compare(fMinInclusive, fMaxExclusive) != -1)
- reportError( "minInclusive-less-than-maxExclusive", new Object[]{fMinInclusive, fMaxExclusive, fTypeName});
+ if (fDVs[fValidationDV].compare(fMinInclusive, fMaxExclusive) != -1)
+ reportError( "minInclusive-less-than-maxExclusive", new Object[]{fMinInclusive, fMaxExclusive, fTypeName});
}
// check 4.3.12.c1 must: fractionDigits <= totalDigits
if (((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) &&
- ((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
+ ((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
if (fFractionDigits > fTotalDigits)
reportError( "fractionDigits-totalDigits", new Object[]{Integer.toString(fFractionDigits), Integer.toString(fTotalDigits), fTypeName});
}
@@ -1134,14 +1151,14 @@
// check 4.3.1.c1 error: length & (fBase.maxLength | fBase.minLength)
if((fFacetsDefined & FACET_LENGTH) != 0 ){
if ((fBase.fFacetsDefined & FACET_MINLENGTH) != 0 &&
- fLength < fBase.fMinLength) {
+ fLength < fBase.fMinLength) {
// length, fBase.minLength and fBase.maxLength defined
- reportError("length-minLength-maxLength.d", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMinLength)});
+ reportError("length-minLength-maxLength.1.1", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMinLength)});
}
if ((fBase.fFacetsDefined & FACET_MAXLENGTH) != 0 &&
- fLength > fBase.fMaxLength) {
+ fLength > fBase.fMaxLength) {
// length and fBase.maxLength defined
- reportError("length-minLength-maxLength.e", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMaxLength)});
+ reportError("length-minLength-maxLength.2.1", new Object[]{fTypeName, Integer.toString(fLength), Integer.toString(fBase.fMaxLength)});
}
if ( (fBase.fFacetsDefined & FACET_LENGTH) != 0 ) {
// check 4.3.1.c2 error: length != fBase.length
@@ -1151,16 +1168,30 @@
}
// check 4.3.1.c1 error: fBase.length & (maxLength | minLength)
- else if((fBase.fFacetsDefined & FACET_LENGTH) != 0 ){
- if ((fFacetsDefined & FACET_MINLENGTH) != 0 &&
- fBase.fLength < fMinLength) {
- // fBase.length, minLength and maxLength defined
- reportError("length-minLength-maxLength.d", new Object[]{fTypeName, Integer.toString(fBase.fLength), Integer.toString(fMinLength)});
+ if((fBase.fFacetsDefined & FACET_LENGTH) != 0 || (fFacetsDefined & FACET_LENGTH) != 0){
+ if ((fFacetsDefined & FACET_MINLENGTH) != 0){
+ if (fBase.fLength < fMinLength) {
+ // fBase.length, minLength and maxLength defined
+ reportError("length-minLength-maxLength.1.1", new Object[]{fTypeName, Integer.toString(fBase.fLength), Integer.toString(fMinLength)});
+ }
+ if ((fBase.fFacetsDefined & FACET_MINLENGTH) == 0){
+ reportError("length-minLength-maxLength.1.2.a", new Object[]{fTypeName});
+ }
+ if (fMinLength != fBase.fMinLength){
+ reportError("length-minLength-maxLength.1.2.b", new Object[]{fTypeName, Integer.toString(fMinLength), Integer.toString(fBase.fMinLength)});
+ }
}
- if ((fFacetsDefined & FACET_MAXLENGTH) != 0 &&
- fBase.fLength > fMaxLength) {
- // fBase.length and maxLength defined
- reportError("length-minLength-maxLength.e", new Object[]{this, Integer.toString(fBase.fLength), Integer.toString(fMaxLength)});
+ if ((fFacetsDefined & FACET_MAXLENGTH) != 0){
+ if (fBase.fLength > fMaxLength) {
+ // fBase.length, minLength and maxLength defined
+ reportError("length-minLength-maxLength.2.1", new Object[]{fTypeName, Integer.toString(fBase.fLength), Integer.toString(fMaxLength)});
+ }
+ if ((fBase.fFacetsDefined & FACET_MAXLENGTH) == 0){
+ reportError("length-minLength-maxLength.2.2.a", new Object[]{fTypeName});
+ }
+ if (fMaxLength != fBase.fMaxLength){
+ reportError("length-minLength-maxLength.2.2.b", new Object[]{fTypeName, Integer.toString(fMaxLength), Integer.toString(fBase.fBase.fMaxLength)});
+ }
}
}
@@ -1203,138 +1234,138 @@
}
}
-/* // check 4.3.7.c2 error:
- // maxInclusive > fBase.maxInclusive
- // maxInclusive >= fBase.maxExclusive
- // maxInclusive < fBase.minInclusive
- // maxInclusive <= fBase.minExclusive
-
- if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive);
- if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
- }
- if (result != -1 && result != 0) {
- reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxInclusive, fTypeName});
- }
- }
- if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxExclusive) != -1){
- reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxExclusive, fTypeName});
- }
-
- if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinInclusive);
- if (result != 1 && result != 0) {
- reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinInclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinExclusive ) != 1)
- reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinExclusive, fTypeName});
- }
-
- // check 4.3.8.c3 error:
- // maxExclusive > fBase.maxExclusive
- // maxExclusive > fBase.maxInclusive
- // maxExclusive <= fBase.minInclusive
- // maxExclusive <= fBase.minExclusive
- if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
- if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
- result= fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
- if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"maxExclusive", fMaxExclusive, fBase.fMaxExclusive, fTypeName});
- }
- if (result != -1 && result != 0) {
- reportError( "maxExclusive-valid-restriction.1", new Object[]{fMaxExclusive, fBase.fMaxExclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- result= fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive);
- if (result != -1 && result != 0) {
- reportError( "maxExclusive-valid-restriction.2", new Object[]{fMaxExclusive, fBase.fMaxInclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinExclusive ) != 1)
- reportError( "maxExclusive-valid-restriction.3", new Object[]{fMaxExclusive, fBase.fMinExclusive, fTypeName});
-
- if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinInclusive) != 1)
- reportError( "maxExclusive-valid-restriction.4", new Object[]{fMaxExclusive, fBase.fMinInclusive, fTypeName});
- }
-
- // check 4.3.9.c3 error:
- // minExclusive < fBase.minExclusive
- // minExclusive > fBase.maxInclusive
- // minExclusive < fBase.minInclusive
- // minExclusive >= fBase.maxExclusive
- if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
- if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
- result= fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
- if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"minExclusive", fMinExclusive, fBase.fMinExclusive, fTypeName});
- }
- if (result != 1 && result != 0) {
- reportError( "minExclusive-valid-restriction.1", new Object[]{fMinExclusive, fBase.fMinExclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- result=fDVs[fValidationDV].compare(fMinExclusive, fBase.fMaxInclusive);
-
- if (result != -1 && result != 0) {
- reportError( "minExclusive-valid-restriction.2", new Object[]{fMinExclusive, fBase.fMaxInclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive);
-
- if (result != 1 && result != 0) {
- reportError( "minExclusive-valid-restriction.3", new Object[]{fMinExclusive, fBase.fMinInclusive, fTypeName});
- }
- }
-
- if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMinExclusive, fBase.fMaxExclusive) != -1)
- reportError( "minExclusive-valid-restriction.4", new Object[]{fMinExclusive, fBase.fMaxExclusive, fTypeName});
- }
-
- // check 4.3.10.c2 error:
- // minInclusive < fBase.minInclusive
- // minInclusive > fBase.maxInclusive
- // minInclusive <= fBase.minExclusive
- // minInclusive >= fBase.maxExclusive
- if (((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
- result = fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive);
-
- if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0 && result != 0) {
- reportError( "FixedFacetValue", new Object[]{"minInclusive", fMinInclusive, fBase.fMinInclusive, fTypeName});
- }
- if (result != 1 && result != 0) {
- reportError( "minInclusive-valid-restriction.1", new Object[]{fMinInclusive, fBase.fMinInclusive, fTypeName});
- }
- }
- if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
- result=fDVs[fValidationDV].compare(fMinInclusive, fBase.fMaxInclusive);
- if (result != -1 && result != 0) {
- reportError( "minInclusive-valid-restriction.2", new Object[]{fMinInclusive, fBase.fMaxInclusive, fTypeName});
- }
- }
- if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinExclusive ) != 1)
- reportError( "minInclusive-valid-restriction.3", new Object[]{fMinInclusive, fBase.fMinExclusive, fTypeName});
- if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
- fDVs[fValidationDV].compare(fMinInclusive, fBase.fMaxExclusive) != -1)
- reportError( "minInclusive-valid-restriction.4", new Object[]{fMinInclusive, fBase.fMaxExclusive, fTypeName});
- }
-*/
+ /* // check 4.3.7.c2 error:
+ // maxInclusive > fBase.maxInclusive
+ // maxInclusive >= fBase.maxExclusive
+ // maxInclusive < fBase.minInclusive
+ // maxInclusive <= fBase.minExclusive
+
+ if (((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ if (((fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxInclusive);
+ if ((fBase.fFixedFacet & FACET_MAXINCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"maxInclusive", fMaxInclusive, fBase.fMaxInclusive, fTypeName});
+ }
+ if (result != -1 && result != 0) {
+ reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxInclusive, fTypeName});
+ }
+ }
+ if (((fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMaxExclusive) != -1){
+ reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMaxExclusive, fTypeName});
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinInclusive);
+ if (result != 1 && result != 0) {
+ reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinInclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMaxInclusive, fBase.fMinExclusive ) != 1)
+ reportError( "maxInclusive-valid-restriction.1", new Object[]{fMaxInclusive, fBase.fMinExclusive, fTypeName});
+ }
+
+ // check 4.3.8.c3 error:
+ // maxExclusive > fBase.maxExclusive
+ // maxExclusive > fBase.maxInclusive
+ // maxExclusive <= fBase.minInclusive
+ // maxExclusive <= fBase.minExclusive
+ if (((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
+ if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) {
+ result= fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxExclusive);
+ if ((fBase.fFixedFacet & FACET_MAXEXCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"maxExclusive", fMaxExclusive, fBase.fMaxExclusive, fTypeName});
+ }
+ if (result != -1 && result != 0) {
+ reportError( "maxExclusive-valid-restriction.1", new Object[]{fMaxExclusive, fBase.fMaxExclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ result= fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMaxInclusive);
+ if (result != -1 && result != 0) {
+ reportError( "maxExclusive-valid-restriction.2", new Object[]{fMaxExclusive, fBase.fMaxInclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinExclusive ) != 1)
+ reportError( "maxExclusive-valid-restriction.3", new Object[]{fMaxExclusive, fBase.fMinExclusive, fTypeName});
+
+ if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMaxExclusive, fBase.fMinInclusive) != 1)
+ reportError( "maxExclusive-valid-restriction.4", new Object[]{fMaxExclusive, fBase.fMinInclusive, fTypeName});
+ }
+
+ // check 4.3.9.c3 error:
+ // minExclusive < fBase.minExclusive
+ // minExclusive > fBase.maxInclusive
+ // minExclusive < fBase.minInclusive
+ // minExclusive >= fBase.maxExclusive
+ if (((fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+ if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0)) {
+ result= fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinExclusive);
+ if ((fBase.fFixedFacet & FACET_MINEXCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"minExclusive", fMinExclusive, fBase.fMinExclusive, fTypeName});
+ }
+ if (result != 1 && result != 0) {
+ reportError( "minExclusive-valid-restriction.1", new Object[]{fMinExclusive, fBase.fMinExclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ result=fDVs[fValidationDV].compare(fMinExclusive, fBase.fMaxInclusive);
+
+ if (result != -1 && result != 0) {
+ reportError( "minExclusive-valid-restriction.2", new Object[]{fMinExclusive, fBase.fMaxInclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMinExclusive, fBase.fMinInclusive);
+
+ if (result != 1 && result != 0) {
+ reportError( "minExclusive-valid-restriction.3", new Object[]{fMinExclusive, fBase.fMinInclusive, fTypeName});
+ }
+ }
+
+ if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMinExclusive, fBase.fMaxExclusive) != -1)
+ reportError( "minExclusive-valid-restriction.4", new Object[]{fMinExclusive, fBase.fMaxExclusive, fTypeName});
+ }
+
+ // check 4.3.10.c2 error:
+ // minInclusive < fBase.minInclusive
+ // minInclusive > fBase.maxInclusive
+ // minInclusive <= fBase.minExclusive
+ // minInclusive >= fBase.maxExclusive
+ if (((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ if (((fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ result = fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinInclusive);
+
+ if ((fBase.fFixedFacet & FACET_MININCLUSIVE) != 0 && result != 0) {
+ reportError( "FixedFacetValue", new Object[]{"minInclusive", fMinInclusive, fBase.fMinInclusive, fTypeName});
+ }
+ if (result != 1 && result != 0) {
+ reportError( "minInclusive-valid-restriction.1", new Object[]{fMinInclusive, fBase.fMinInclusive, fTypeName});
+ }
+ }
+ if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ result=fDVs[fValidationDV].compare(fMinInclusive, fBase.fMaxInclusive);
+ if (result != -1 && result != 0) {
+ reportError( "minInclusive-valid-restriction.2", new Object[]{fMinInclusive, fBase.fMaxInclusive, fTypeName});
+ }
+ }
+ if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMinInclusive, fBase.fMinExclusive ) != 1)
+ reportError( "minInclusive-valid-restriction.3", new Object[]{fMinInclusive, fBase.fMinExclusive, fTypeName});
+ if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
+ fDVs[fValidationDV].compare(fMinInclusive, fBase.fMaxExclusive) != -1)
+ reportError( "minInclusive-valid-restriction.4", new Object[]{fMinInclusive, fBase.fMaxExclusive, fTypeName});
+ }
+ */
// check 4.3.11.c1 error: totalDigits > fBase.totalDigits
if (((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
@@ -1359,13 +1390,17 @@
// check fixed value for fractionDigits
if (((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
if ((( fBase.fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
- if ((fBase.fFixedFacet & FACET_FRACTIONDIGITS) != 0 && fFractionDigits != fBase.fFractionDigits) {
+ if (((fBase.fFixedFacet & FACET_FRACTIONDIGITS) != 0 && fFractionDigits != fBase.fFractionDigits) ||
+ (fValidationDV == DV_INTEGER && fFractionDigits != 0)) {
reportError("FixedFacetValue", new Object[]{"fractionDigits", Integer.toString(fFractionDigits), Integer.toString(fBase.fFractionDigits), fTypeName});
}
if (fFractionDigits > fBase.fFractionDigits) {
reportError( "fractionDigits-valid-restriction", new Object[]{Integer.toString(fFractionDigits), Integer.toString(fBase.fFractionDigits), fTypeName});
}
}
+ else if (fValidationDV == DV_INTEGER && fFractionDigits != 0) {
+ reportError("FixedFacetValue", new Object[]{"fractionDigits", Integer.toString(fFractionDigits), "0", fTypeName});
+ }
}
// check 4.3.6.c1 error:
@@ -1412,18 +1447,24 @@
// inherit pattern
if ( (fBase.fFacetsDefined & FACET_PATTERN) != 0 ) {
if ((fFacetsDefined & FACET_PATTERN) == 0) {
+ fFacetsDefined |= FACET_PATTERN;
fPattern = fBase.fPattern;
fPatternStr = fBase.fPatternStr;
- fFacetsDefined |= FACET_PATTERN;
+ patternAnnotations = fBase.patternAnnotations;
}
else {
- for (int i = fBase.fPattern.size()-1; i >= 0; i--) {
+ for (int i = fBase.fPattern.size()-1; i >= 0; --i) {
fPattern.addElement(fBase.fPattern.elementAt(i));
- fPatternStr.addElement(fBase.fPatternStr.elementAt(i));
+ fPatternStr.addElement(fBase.fPatternStr.elementAt(i));
}
- if (fBase.patternAnnotations != null){
- for (int i = fBase.patternAnnotations.getLength()-1;i>=0;i--){
- patternAnnotations.add(fBase.patternAnnotations.item(i));
+ if (fBase.patternAnnotations != null) {
+ if (patternAnnotations != null) {
+ for (int i = fBase.patternAnnotations.getLength()-1; i >= 0; --i) {
+ patternAnnotations.addXSObject(fBase.patternAnnotations.item(i));
+ }
+ }
+ else {
+ patternAnnotations = fBase.patternAnnotations;
}
}
}
@@ -1442,42 +1483,42 @@
}
// inherit maxExclusive
if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
- !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MAXEXCLUSIVE;
fMaxExclusive = fBase.fMaxExclusive;
maxExclusiveAnnotation = fBase.maxExclusiveAnnotation;
}
// inherit maxInclusive
if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) &&
- !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
+ !((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MAXINCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MAXINCLUSIVE;
fMaxInclusive = fBase.fMaxInclusive;
maxInclusiveAnnotation = fBase.maxInclusiveAnnotation;
}
// inherit minExclusive
if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
- !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MINEXCLUSIVE;
fMinExclusive = fBase.fMinExclusive;
minExclusiveAnnotation = fBase.minExclusiveAnnotation;
}
// inherit minExclusive
if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
- !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
+ !((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & FACET_MININCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MININCLUSIVE;
fMinInclusive = fBase.fMinInclusive;
minInclusiveAnnotation = fBase.minInclusiveAnnotation;
}
// inherit totalDigits
if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0) &&
- !((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
+ !((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
fFacetsDefined |= FACET_TOTALDIGITS;
fTotalDigits = fBase.fTotalDigits;
totalDigitsAnnotation = fBase.totalDigitsAnnotation;
}
// inherit fractionDigits
if ((( fBase.fFacetsDefined & FACET_FRACTIONDIGITS) != 0)
- && !((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
+ && !((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
fFacetsDefined |= FACET_FRACTIONDIGITS;
fFractionDigits = fBase.fFractionDigits;
fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
@@ -1491,7 +1532,7 @@
fFixedFacet |= fBase.fFixedFacet;
//step 6: setting fundamental facets
- caclFundamentalFacets();
+ calcFundamentalFacets();
} //applyFacets()
@@ -1517,30 +1558,35 @@
return ob;
}
-
+
+ protected ValidatedInfo getActualEnumValue(String lexical, ValidationContext ctx, ValidatedInfo info)
+ throws InvalidDatatypeValueException {
+ return fBase.validateWithInfo(lexical, ctx, info);
+ }
+
/**
* validate a value, and return the compiled form
*/
public ValidatedInfo validateWithInfo(String content, ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
- if (context == null)
- context = fEmptyContext;
-
- if (validatedInfo == null)
- validatedInfo = new ValidatedInfo();
- else
- validatedInfo.memberType = null;
-
- // first normalize string value, and convert it to actual value
- boolean needNormalize = context==null||context.needToNormalize();
- getActualValue(content, context, validatedInfo, needNormalize);
-
- validate(context, validatedInfo);
-
- return validatedInfo;
+ if (context == null)
+ context = fEmptyContext;
+
+ if (validatedInfo == null)
+ validatedInfo = new ValidatedInfo();
+ else
+ validatedInfo.memberType = null;
+
+ // first normalize string value, and convert it to actual value
+ boolean needNormalize = context==null||context.needToNormalize();
+ getActualValue(content, context, validatedInfo, needNormalize);
+
+ validate(context, validatedInfo);
+
+ return validatedInfo;
}
-
+
/**
* validate a value, and return the compiled form
*/
@@ -1578,7 +1624,7 @@
// then validate the actual value against the facets
if (context.needFacetChecking() &&
- (fFacetsDefined != 0 && fFacetsDefined != FACET_WHITESPACE)) {
+ (fFacetsDefined != 0 && fFacetsDefined != FACET_WHITESPACE)) {
checkFacets(validatedInfo);
}
@@ -1595,7 +1641,7 @@
String content = validatedInfo.normalizedValue;
short type = validatedInfo.actualValueType;
ShortList itemType = validatedInfo.itemValueTypes;
-
+
// For QName and NOTATION types, we don't check length facets
if (fValidationDV != DV_QNAME && fValidationDV != DV_NOTATION) {
int length = fDVs[fValidationDV].getDataLength(ob);
@@ -1633,9 +1679,9 @@
for (int i = 0; i < enumSize; i++) {
final short primitiveType2 = convertToPrimitiveKind(fEnumerationType[i]);
if ((primitiveType1 == primitiveType2 ||
- primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
- primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT)
- && fEnumeration.elementAt(i).equals(ob)) {
+ primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
+ primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT)
+ && fEnumeration.elementAt(i).equals(ob)) {
if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
ShortList enumItemType = fEnumerationItemType[i];
final int typeList1Length = itemType != null ? itemType.getLength() : 0;
@@ -1647,7 +1693,7 @@
final short primitiveItem2 = convertToPrimitiveKind(enumItemType.item(j));
if (primitiveItem1 != primitiveItem2) {
if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
- primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
+ primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
continue;
}
break;
@@ -1670,215 +1716,220 @@
new Object [] {content, fEnumeration.toString()});
}
}
-
- //fractionDigits
- if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
- int scale = fDVs[fValidationDV].getFractionDigits(ob);
- if (scale > fFractionDigits) {
- throw new InvalidDatatypeValueException("cvc-fractionDigits-valid",
- new Object[] {content, Integer.toString(scale), Integer.toString(fFractionDigits)});
- }
- }
-
- //totalDigits
- if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
- int totalDigits = fDVs[fValidationDV].getTotalDigits(ob);
- if (totalDigits > fTotalDigits) {
- throw new InvalidDatatypeValueException("cvc-totalDigits-valid",
- new Object[] {content, Integer.toString(totalDigits), Integer.toString(fTotalDigits)});
- }
- }
-
- int compare;
-
- //maxinclusive
- if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
- compare = fDVs[fValidationDV].compare(ob, fMaxInclusive);
- if (compare != -1 && compare != 0) {
- throw new InvalidDatatypeValueException("cvc-maxInclusive-valid",
- new Object[] {content, fMaxInclusive, fTypeName});
- }
- }
-
- //maxExclusive
- if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
- compare = fDVs[fValidationDV].compare(ob, fMaxExclusive );
- if (compare != -1) {
- throw new InvalidDatatypeValueException("cvc-maxExclusive-valid",
- new Object[] {content, fMaxExclusive, fTypeName});
- }
- }
-
- //minInclusive
- if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
- compare = fDVs[fValidationDV].compare(ob, fMinInclusive);
- if (compare != 1 && compare != 0) {
- throw new InvalidDatatypeValueException("cvc-minInclusive-valid",
- new Object[] {content, fMinInclusive, fTypeName});
- }
- }
-
- //minExclusive
- if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
- compare = fDVs[fValidationDV].compare(ob, fMinExclusive);
- if (compare != 1) {
- throw new InvalidDatatypeValueException("cvc-minExclusive-valid",
- new Object[] {content, fMinExclusive, fTypeName});
- }
- }
-
- }
-
- private void checkExtraRules(ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
-
- Object ob = validatedInfo.actualValue;
-
- if (fVariety == VARIETY_ATOMIC) {
-
- fDVs[fValidationDV].checkExtraRules(ob, context);
-
- } else if (fVariety == VARIETY_LIST) {
-
- ListDV.ListData values = (ListDV.ListData)ob;
- int len = values.getLength();
- if (fItemType.fVariety == VARIETY_UNION) {
- XSSimpleTypeDecl[] memberTypes = (XSSimpleTypeDecl[])validatedInfo.memberTypes;
- XSSimpleType memberType = validatedInfo.memberType;
- for (int i = len-1; i >= 0; i--) {
- validatedInfo.actualValue = values.item(i);
- validatedInfo.memberType = memberTypes[i];
- fItemType.checkExtraRules(context, validatedInfo);
- }
- validatedInfo.memberType = memberType;
- } else { // (fVariety == VARIETY_ATOMIC)
- for (int i = len-1; i >= 0; i--) {
- validatedInfo.actualValue = values.item(i);
- fItemType.checkExtraRules(context, validatedInfo);
- }
- }
- validatedInfo.actualValue = values;
-
- } else { // (fVariety == VARIETY_UNION)
-
- ((XSSimpleTypeDecl)validatedInfo.memberType).checkExtraRules(context, validatedInfo);
-
- }
-
- }// checkExtraRules()
-
- //we can still return object for internal use.
- private Object getActualValue(Object content, ValidationContext context,
- ValidatedInfo validatedInfo, boolean needNormalize)
- throws InvalidDatatypeValueException{
-
- String nvalue;
- if (needNormalize) {
- nvalue = normalize(content, fWhiteSpace);
- } else {
- nvalue = content.toString();
- }
- if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
- RegularExpression regex;
- for (int idx = fPattern.size()-1; idx >= 0; idx--) {
- regex = (RegularExpression)fPattern.elementAt(idx);
- if (!regex.matches(nvalue)){
- throw new InvalidDatatypeValueException("cvc-pattern-valid",
- new Object[]{content,
- fPatternStr.elementAt(idx),
-
- fTypeName});
- }
- }
- }
-
- if (fVariety == VARIETY_ATOMIC) {
-
- // validate special kinds of token, in place of old pattern matching
- if (fPatternType != SPECIAL_PATTERN_NONE) {
-
- boolean seenErr = false;
- if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
- // PATTERN "\\c+"
- seenErr = !XMLChar.isValidNmtoken(nvalue);
- }
- else if (fPatternType == SPECIAL_PATTERN_NAME) {
- // PATTERN "\\i\\c*"
- seenErr = !XMLChar.isValidName(nvalue);
- }
- else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
- // PATTERN "[\\i-[:]][\\c-[:]]*"
- seenErr = !XMLChar.isValidNCName(nvalue);
- }
- if (seenErr) {
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
- new Object[]{nvalue, SPECIAL_PATTERN_STRING[fPatternType]});
- }
- }
-
- validatedInfo.normalizedValue = nvalue;
- Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
- validatedInfo.actualValue = avalue;
- validatedInfo.actualValueType = fBuiltInKind;
-
- return avalue;
-
- } else if (fVariety == VARIETY_LIST) {
-
- StringTokenizer parsedList = new StringTokenizer(nvalue, " ");
- int countOfTokens = parsedList.countTokens() ;
- Object[] avalue = new Object[countOfTokens];
- boolean isUnion = fItemType.getVariety() == VARIETY_UNION;
- short[] itemTypes = new short[isUnion ? countOfTokens : 1];
- if (!isUnion)
- itemTypes[0] = fItemType.fBuiltInKind;
- XSSimpleTypeDecl[] memberTypes = new XSSimpleTypeDecl[countOfTokens];
- for(int i = 0 ; i < countOfTokens ; i ++){
- // we can't call fItemType.validate(), otherwise checkExtraRules()
- // will be called twice: once in fItemType.validate, once in
- // validate method of this type.
- // so we take two steps to get the actual value:
- // 1. fItemType.getActualValue()
- // 2. fItemType.chekcFacets()
- avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false);
- if (context.needFacetChecking() &&
- (fItemType.fFacetsDefined != 0 && fItemType.fFacetsDefined != FACET_WHITESPACE)) {
- fItemType.checkFacets(validatedInfo);
- }
- memberTypes[i] = (XSSimpleTypeDecl)validatedInfo.memberType;
- if (isUnion)
- itemTypes[i] = memberTypes[i].fBuiltInKind;
- }
-
- ListDV.ListData v = new ListDV.ListData(avalue);
- validatedInfo.actualValue = v;
- validatedInfo.actualValueType = isUnion ? XSConstants.LISTOFUNION_DT : XSConstants.LIST_DT;
- validatedInfo.memberType = null;
- validatedInfo.memberTypes = memberTypes;
- validatedInfo.itemValueTypes = new ShortListImpl(itemTypes, itemTypes.length);
- validatedInfo.normalizedValue = nvalue;
-
- return v;
-
- } else { // (fVariety == VARIETY_UNION)
- for(int i = 0 ; i < fMemberTypes.length; i++) {
- try {
- // we can't call fMemberType[i].validate(), otherwise checkExtraRules()
- // will be called twice: once in fMemberType[i].validate, once in
- // validate method of this type.
- // so we take two steps to get the actual value:
- // 1. fMemberType[i].getActualValue()
- // 2. fMemberType[i].chekcFacets()
- Object aValue = fMemberTypes[i].getActualValue(content, context, validatedInfo, true);
- if (context.needFacetChecking() &&
- (fMemberTypes[i].fFacetsDefined != 0 && fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) {
- fMemberTypes[i].checkFacets(validatedInfo);
- }
- validatedInfo.memberType = fMemberTypes[i];
- return aValue;
- } catch(InvalidDatatypeValueException invalidValue) {
- }
- }
- StringBuffer typesBuffer = new StringBuffer();
+
+ //fractionDigits
+ if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
+ int scale = fDVs[fValidationDV].getFractionDigits(ob);
+ if (scale > fFractionDigits) {
+ throw new InvalidDatatypeValueException("cvc-fractionDigits-valid",
+ new Object[] {content, Integer.toString(scale), Integer.toString(fFractionDigits)});
+ }
+ }
+
+ //totalDigits
+ if ((fFacetsDefined & FACET_TOTALDIGITS)!=0) {
+ int totalDigits = fDVs[fValidationDV].getTotalDigits(ob);
+ if (totalDigits > fTotalDigits) {
+ throw new InvalidDatatypeValueException("cvc-totalDigits-valid",
+ new Object[] {content, Integer.toString(totalDigits), Integer.toString(fTotalDigits)});
+ }
+ }
+
+ int compare;
+
+ //maxinclusive
+ if ( (fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) {
+ compare = fDVs[fValidationDV].compare(ob, fMaxInclusive);
+ if (compare != -1 && compare != 0) {
+ throw new InvalidDatatypeValueException("cvc-maxInclusive-valid",
+ new Object[] {content, fMaxInclusive, fTypeName});
+ }
+ }
+
+ //maxExclusive
+ if ( (fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 ) {
+ compare = fDVs[fValidationDV].compare(ob, fMaxExclusive );
+ if (compare != -1) {
+ throw new InvalidDatatypeValueException("cvc-maxExclusive-valid",
+ new Object[] {content, fMaxExclusive, fTypeName});
+ }
+ }
+
+ //minInclusive
+ if ( (fFacetsDefined & FACET_MININCLUSIVE) != 0 ) {
+ compare = fDVs[fValidationDV].compare(ob, fMinInclusive);
+ if (compare != 1 && compare != 0) {
+ throw new InvalidDatatypeValueException("cvc-minInclusive-valid",
+ new Object[] {content, fMinInclusive, fTypeName});
+ }
+ }
+
+ //minExclusive
+ if ( (fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ) {
+ compare = fDVs[fValidationDV].compare(ob, fMinExclusive);
+ if (compare != 1) {
+ throw new InvalidDatatypeValueException("cvc-minExclusive-valid",
+ new Object[] {content, fMinExclusive, fTypeName});
+ }
+ }
+
+ }
+
+ private void checkExtraRules(ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
+
+ Object ob = validatedInfo.actualValue;
+
+ if (fVariety == VARIETY_ATOMIC) {
+
+ fDVs[fValidationDV].checkExtraRules(ob, context);
+
+ } else if (fVariety == VARIETY_LIST) {
+
+ ListDV.ListData values = (ListDV.ListData)ob;
+ XSSimpleType memberType = validatedInfo.memberType;
+ int len = values.getLength();
+ try {
+ if (fItemType.fVariety == VARIETY_UNION) {
+ XSSimpleTypeDecl[] memberTypes = (XSSimpleTypeDecl[])validatedInfo.memberTypes;
+ for (int i = len-1; i >= 0; i--) {
+ validatedInfo.actualValue = values.item(i);
+ validatedInfo.memberType = memberTypes[i];
+ fItemType.checkExtraRules(context, validatedInfo);
+ }
+ } else { // (fVariety == VARIETY_ATOMIC)
+ for (int i = len-1; i >= 0; i--) {
+ validatedInfo.actualValue = values.item(i);
+ fItemType.checkExtraRules(context, validatedInfo);
+ }
+ }
+ }
+ finally {
+ validatedInfo.actualValue = values;
+ validatedInfo.memberType = memberType;
+ }
+
+ } else { // (fVariety == VARIETY_UNION)
+
+ ((XSSimpleTypeDecl)validatedInfo.memberType).checkExtraRules(context, validatedInfo);
+
+ }
+
+ }// checkExtraRules()
+
+ //we can still return object for internal use.
+ private Object getActualValue(Object content, ValidationContext context,
+ ValidatedInfo validatedInfo, boolean needNormalize)
+ throws InvalidDatatypeValueException{
+
+ String nvalue;
+ if (needNormalize) {
+ nvalue = normalize(content, fWhiteSpace);
+ } else {
+ nvalue = content.toString();
+ }
+ if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
+ RegularExpression regex;
+ for (int idx = fPattern.size()-1; idx >= 0; idx--) {
+ regex = (RegularExpression)fPattern.elementAt(idx);
+ if (!regex.matches(nvalue)){
+ throw new InvalidDatatypeValueException("cvc-pattern-valid",
+ new Object[]{content,
+ fPatternStr.elementAt(idx),
+
+ fTypeName});
+ }
+ }
+ }
+
+ if (fVariety == VARIETY_ATOMIC) {
+
+ // validate special kinds of token, in place of old pattern matching
+ if (fPatternType != SPECIAL_PATTERN_NONE) {
+
+ boolean seenErr = false;
+ if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
+ // PATTERN "\\c+"
+ seenErr = !XMLChar.isValidNmtoken(nvalue);
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NAME) {
+ // PATTERN "\\i\\c*"
+ seenErr = !XMLChar.isValidName(nvalue);
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
+ // PATTERN "[\\i-[:]][\\c-[:]]*"
+ seenErr = !XMLChar.isValidNCName(nvalue);
+ }
+ if (seenErr) {
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
+ new Object[]{nvalue, SPECIAL_PATTERN_STRING[fPatternType]});
+ }
+ }
+
+ validatedInfo.normalizedValue = nvalue;
+ Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
+ validatedInfo.actualValue = avalue;
+ validatedInfo.actualValueType = fBuiltInKind;
+
+ return avalue;
+
+ } else if (fVariety == VARIETY_LIST) {
+
+ StringTokenizer parsedList = new StringTokenizer(nvalue, " ");
+ int countOfTokens = parsedList.countTokens() ;
+ Object[] avalue = new Object[countOfTokens];
+ boolean isUnion = fItemType.getVariety() == VARIETY_UNION;
+ short[] itemTypes = new short[isUnion ? countOfTokens : 1];
+ if (!isUnion)
+ itemTypes[0] = fItemType.fBuiltInKind;
+ XSSimpleTypeDecl[] memberTypes = new XSSimpleTypeDecl[countOfTokens];
+ for(int i = 0 ; i < countOfTokens ; i ++){
+ // we can't call fItemType.validate(), otherwise checkExtraRules()
+ // will be called twice: once in fItemType.validate, once in
+ // validate method of this type.
+ // so we take two steps to get the actual value:
+ // 1. fItemType.getActualValue()
+ // 2. fItemType.chekcFacets()
+ avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false);
+ if (context.needFacetChecking() &&
+ (fItemType.fFacetsDefined != 0 && fItemType.fFacetsDefined != FACET_WHITESPACE)) {
+ fItemType.checkFacets(validatedInfo);
+ }
+ memberTypes[i] = (XSSimpleTypeDecl)validatedInfo.memberType;
+ if (isUnion)
+ itemTypes[i] = memberTypes[i].fBuiltInKind;
+ }
+
+ ListDV.ListData v = new ListDV.ListData(avalue);
+ validatedInfo.actualValue = v;
+ validatedInfo.actualValueType = isUnion ? XSConstants.LISTOFUNION_DT : XSConstants.LIST_DT;
+ validatedInfo.memberType = null;
+ validatedInfo.memberTypes = memberTypes;
+ validatedInfo.itemValueTypes = new ShortListImpl(itemTypes, itemTypes.length);
+ validatedInfo.normalizedValue = nvalue;
+
+ return v;
+
+ } else { // (fVariety == VARIETY_UNION)
+ final Object _content = (fMemberTypes.length > 1 && content != null) ? content.toString() : content;
+ for (int i = 0; i < fMemberTypes.length; i++) {
+ try {
+ // we can't call fMemberType[i].validate(), otherwise checkExtraRules()
+ // will be called twice: once in fMemberType[i].validate, once in
+ // validate method of this type.
+ // so we take two steps to get the actual value:
+ // 1. fMemberType[i].getActualValue()
+ // 2. fMemberType[i].chekcFacets()
+ Object aValue = fMemberTypes[i].getActualValue(_content, context, validatedInfo, true);
+ if (context.needFacetChecking() &&
+ (fMemberTypes[i].fFacetsDefined != 0 && fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) {
+ fMemberTypes[i].checkFacets(validatedInfo);
+ }
+ validatedInfo.memberType = fMemberTypes[i];
+ return aValue;
+ } catch(InvalidDatatypeValueException invalidValue) {
+ }
+ }
+ StringBuffer typesBuffer = new StringBuffer();
XSSimpleTypeDecl decl;
for(int i = 0;i < fMemberTypes.length; i++) {
if(i != 0)
@@ -1899,312 +1950,330 @@
typesBuffer.append(v.elementAt(j));
}
typesBuffer.append(']');
- }
+ }
+ }
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3",
+ new Object[]{content, fTypeName, typesBuffer.toString()});
+ }
+
+ }//getActualValue()
+
+ public boolean isEqual(Object value1, Object value2) {
+ if (value1 == null) {
+ return false;
+ }
+ return value1.equals(value2);
+ }//isEqual()
+
+ // determine whether the two values are identical
+ public boolean isIdentical (Object value1, Object value2) {
+ if (value1 == null) {
+ return false;
+ }
+ return fDVs[fValidationDV].isIdentical(value1, value2);
+ }//isIdentical()
+
+ // normalize the string according to the whiteSpace facet
+ public static String normalize(String content, short ws) {
+ int len = content == null ? 0 : content.length();
+ if (len == 0 || ws == WS_PRESERVE)
+ return content;
+
+ StringBuffer sb = new StringBuffer();
+ if (ws == WS_REPLACE) {
+ char ch;
+ // when it's replace, just replace #x9, #xa, #xd by #x20
+ for (int i = 0; i < len; i++) {
+ ch = content.charAt(i);
+ if (ch != 0x9 && ch != 0xa && ch != 0xd)
+ sb.append(ch);
+ else
+ sb.append((char)0x20);
+ }
+ } else {
+ char ch;
+ int i;
+ boolean isLeading = true;
+ // when it's collapse
+ for (i = 0; i < len; i++) {
+ ch = content.charAt(i);
+ // append real characters, so we passed leading ws
+ if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
+ sb.append(ch);
+ isLeading = false;
+ }
+ else {
+ // for whitespaces, we skip all following ws
+ for (; i < len-1; i++) {
+ ch = content.charAt(i+1);
+ if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20)
+ break;
+ }
+ // if it's not a leading or tailing ws, then append a space
+ if (i < len - 1 && !isLeading)
+ sb.append((char)0x20);
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+
+ // normalize the string according to the whiteSpace facet
+ protected String normalize(Object content, short ws) {
+ if (content == null)
+ return null;
+
+ // If pattern is not defined, we can skip some of the normalization.
+ // Otherwise we have to normalize the data for correct result of
+ // pattern validation.
+ if ( (fFacetsDefined & FACET_PATTERN ) == 0 ) {
+ short norm_type = fDVNormalizeType[fValidationDV];
+ if (norm_type == NORMALIZE_NONE) {
+ return content.toString();
+ }
+ else if (norm_type == NORMALIZE_TRIM) {
+ return XMLChar.trim(content.toString());
+ }
+ }
+
+ if (!(content instanceof StringBuffer)) {
+ String strContent = content.toString();
+ return normalize(strContent, ws);
+ }
+
+ StringBuffer sb = (StringBuffer)content;
+ int len = sb.length();
+ if (len == 0)
+ return "";
+ if (ws == WS_PRESERVE)
+ return sb.toString();
+
+ if (ws == WS_REPLACE) {
+ char ch;
+ // when it's replace, just replace #x9, #xa, #xd by #x20
+ for (int i = 0; i < len; i++) {
+ ch = sb.charAt(i);
+ if (ch == 0x9 || ch == 0xa || ch == 0xd)
+ sb.setCharAt(i, (char)0x20);
+ }
+ } else {
+ char ch;
+ int i, j = 0;
+ boolean isLeading = true;
+ // when it's collapse
+ for (i = 0; i < len; i++) {
+ ch = sb.charAt(i);
+ // append real characters, so we passed leading ws
+ if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
+ sb.setCharAt(j++, ch);
+ isLeading = false;
+ }
+ else {
+ // for whitespaces, we skip all following ws
+ for (; i < len-1; i++) {
+ ch = sb.charAt(i+1);
+ if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20)
+ break;
+ }
+ // if it's not a leading or tailing ws, then append a space
+ if (i < len - 1 && !isLeading)
+ sb.setCharAt(j++, (char)0x20);
+ }
}
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3",
- new Object[]{content, fTypeName, typesBuffer.toString()});
- }
-
- }//getActualValue()
-
- public boolean isEqual(Object value1, Object value2) {
- if (value1 == null) {
- return false;
- }
- return value1.equals(value2);
- }//isEqual()
-
- // determine whether the two values are identical
- public boolean isIdentical (Object value1, Object value2) {
- if (value1 == null) {
- return false;
- }
- return fDVs[fValidationDV].isIdentical(value1, value2);
- }//isIdentical()
-
- // normalize the string according to the whiteSpace facet
- public static String normalize(String content, short ws) {
- int len = content == null ? 0 : content.length();
- if (len == 0 || ws == WS_PRESERVE)
- return content;
-
- StringBuffer sb = new StringBuffer();
- if (ws == WS_REPLACE) {
- char ch;
- // when it's replace, just replace #x9, #xa, #xd by #x20
- for (int i = 0; i < len; i++) {
- ch = content.charAt(i);
- if (ch != 0x9 && ch != 0xa && ch != 0xd)
- sb.append(ch);
- else
- sb.append((char)0x20);
- }
- } else {
- char ch;
- int i;
- boolean isLeading = true;
- // when it's collapse
- for (i = 0; i < len; i++) {
- ch = content.charAt(i);
- // append real characters, so we passed leading ws
- if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
- sb.append(ch);
- isLeading = false;
- }
- else {
- // for whitespaces, we skip all following ws
- for (; i < len-1; i++) {
- ch = content.charAt(i+1);
- if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20)
- break;
- }
- // if it's not a leading or tailing ws, then append a space
- if (i < len - 1 && !isLeading)
- sb.append((char)0x20);
- }
- }
- }
-
- return sb.toString();
- }
-
- // normalize the string according to the whiteSpace facet
- protected String normalize(Object content, short ws) {
- if (content == null)
- return null;
-
- // If pattern is not defined, we can skip some of the normalization.
- // Otherwise we have to normalize the data for correct result of
- // pattern validation.
- if ( (fFacetsDefined & FACET_PATTERN ) == 0 ) {
- short norm_type = fDVNormalizeType[fValidationDV];
- if (norm_type == NORMALIZE_NONE) {
- return content.toString();
- }
- else if (norm_type == NORMALIZE_TRIM) {
- return content.toString().trim();
- }
- }
-
- if (!(content instanceof StringBuffer)) {
- String strContent = content.toString();
- return normalize(strContent, ws);
- }
-
- StringBuffer sb = (StringBuffer)content;
- int len = sb.length();
- if (len == 0)
- return "";
- if (ws == WS_PRESERVE)
- return sb.toString();
-
- if (ws == WS_REPLACE) {
- char ch;
- // when it's replace, just replace #x9, #xa, #xd by #x20
- for (int i = 0; i < len; i++) {
- ch = sb.charAt(i);
- if (ch == 0x9 || ch == 0xa || ch == 0xd)
- sb.setCharAt(i, (char)0x20);
- }
- } else {
- char ch;
- int i, j = 0;
- boolean isLeading = true;
- // when it's collapse
- for (i = 0; i < len; i++) {
- ch = sb.charAt(i);
- // append real characters, so we passed leading ws
- if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
- sb.setCharAt(j++, ch);
- isLeading = false;
- }
- else {
- // for whitespaces, we skip all following ws
- for (; i < len-1; i++) {
- ch = sb.charAt(i+1);
- if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20)
- break;
- }
- // if it's not a leading or tailing ws, then append a space
- if (i < len - 1 && !isLeading)
- sb.setCharAt(j++, (char)0x20);
- }
- }
- sb.setLength(j);
- }
-
- return sb.toString();
- }
-
- void reportError(String key, Object[] args) throws InvalidDatatypeFacetException {
- throw new InvalidDatatypeFacetException(key, args);
- }
-
-
- private String whiteSpaceValue(short ws){
- return WS_FACET_STRING[ws];
- }
-
- /**
- * Fundamental Facet: ordered.
- */
- public short getOrdered() {
- return fOrdered;
- }
-
- /**
- * Fundamental Facet: bounded.
- */
- public boolean getBounded(){
- return fBounded;
- }
-
- /**
- * Fundamental Facet: cardinality.
- */
- public boolean getFinite(){
- return fFinite;
- }
-
- /**
- * Fundamental Facet: numeric.
- */
- public boolean getNumeric(){
- return fNumeric;
- }
-
- /**
- * Convenience method. [Facets]: check whether a facet is defined on this
- * type.
- * @param facetName The name of the facet.
- * @return True if the facet is defined, false otherwise.
- */
- public boolean isDefinedFacet(short facetName) {
- if ((fFacetsDefined & facetName) != 0)
- return true;
- if (fPatternType != SPECIAL_PATTERN_NONE)
- return facetName == FACET_PATTERN;
- if (fValidationDV == DV_INTEGER)
- return facetName == FACET_PATTERN || facetName == FACET_FRACTIONDIGITS;
- return false;
- }
-
- /**
- * [facets]: all facets defined on this type. The value is a bit
- * combination of FACET_XXX constants of all defined facets.
- */
- public short getDefinedFacets() {
- if (fPatternType != SPECIAL_PATTERN_NONE)
- return (short)(fFacetsDefined | FACET_PATTERN);
- if (fValidationDV == DV_INTEGER)
- return (short)(fFacetsDefined | FACET_PATTERN | FACET_FRACTIONDIGITS);
- return fFacetsDefined;
- }
-
- /**
- * Convenience method. [Facets]: check whether a facet is defined and
- * fixed on this type.
- * @param facetName The name of the facet.
- * @return True if the facet is fixed, false otherwise.
- */
- public boolean isFixedFacet(short facetName) {
- if ((fFixedFacet & facetName) != 0)
- return true;
- if (fValidationDV == DV_INTEGER)
- return facetName == FACET_FRACTIONDIGITS;
- return false;
- }
-
- /**
- * [facets]: all defined facets for this type which are fixed.
- */
- public short getFixedFacets() {
- if (fValidationDV == DV_INTEGER)
- return (short)(fFixedFacet | FACET_FRACTIONDIGITS);
- return fFixedFacet;
- }
-
- /**
- * Convenience method. Returns a value of a single constraining facet for
- * this simple type definition. This method must not be used to retrieve
- * values for enumeration
and pattern
facets.
- * @param facetName The name of the facet, i.e.
- * FACET_LENGTH, FACET_TOTALDIGITS
(see
- * XSConstants
). To retrieve the value for a pattern or
- * an enumeration, see enumeration
and
- * pattern
.
- * @return A value of the facet specified in facetName
for
- * this simple type definition or null
.
- */
- public String getLexicalFacetValue(short facetName) {
- switch (facetName) {
- case FACET_LENGTH:
- return (fLength == -1)?null:Integer.toString(fLength);
- case FACET_MINLENGTH:
- return (fMinLength == -1)?null:Integer.toString(fMinLength);
- case FACET_MAXLENGTH:
- return (fMaxLength == -1)?null:Integer.toString(fMaxLength);
- case FACET_WHITESPACE:
- return WS_FACET_STRING[fWhiteSpace];
- case FACET_MAXINCLUSIVE:
- return (fMaxInclusive == null)?null:fMaxInclusive.toString();
- case FACET_MAXEXCLUSIVE:
- return (fMaxExclusive == null)?null:fMaxExclusive.toString();
- case FACET_MINEXCLUSIVE:
- return (fMinExclusive == null)?null:fMinExclusive.toString();
- case FACET_MININCLUSIVE:
- return (fMinInclusive == null)?null:fMinInclusive.toString();
- case FACET_TOTALDIGITS:
- if (fValidationDV == DV_INTEGER)
- return "0";
- return (fTotalDigits == -1)?null:Integer.toString(fTotalDigits);
- case FACET_FRACTIONDIGITS:
- return (fFractionDigits == -1)?null:Integer.toString(fFractionDigits);
- }
- return null;
- }
-
- /**
- * A list of enumeration values if it exists, otherwise an empty
- * StringList
.
- */
- public StringList getLexicalEnumeration() {
- if (fLexicalEnumeration == null){
- if (fEnumeration == null)
- return StringListImpl.EMPTY_LIST;
- int size = fEnumeration.size();
- String[] strs = new String[size];
- for (int i = 0; i < size; i++)
- strs[i] = fEnumeration.elementAt(i).toString();
- fLexicalEnumeration = new StringListImpl(strs, size);
- }
- return fLexicalEnumeration;
- }
-
- /**
- * A list of actual enumeration values if it exists, otherwise an empty
- * ObjectList
.
- */
- public ObjectList getActualEnumeration() {
- if (fActualEnumeration == null) {
- fActualEnumeration = new ObjectList () {
- public int getLength() {
- return (fEnumeration != null) ? fEnumeration.size() : 0;
- }
- public boolean contains(Object item) {
- return (fEnumeration != null && fEnumeration.contains(item));
- }
- public Object item(int index) {
- if (index < 0 || index >= getLength()) {
- return null;
- }
- return fEnumeration.elementAt(index);
- }
- };
- }
- return fActualEnumeration;
- }
-
+ sb.setLength(j);
+ }
+
+ return sb.toString();
+ }
+
+ void reportError(String key, Object[] args) throws InvalidDatatypeFacetException {
+ throw new InvalidDatatypeFacetException(key, args);
+ }
+
+
+ private String whiteSpaceValue(short ws){
+ return WS_FACET_STRING[ws];
+ }
+
+ /**
+ * Fundamental Facet: ordered.
+ */
+ public short getOrdered() {
+ return fOrdered;
+ }
+
+ /**
+ * Fundamental Facet: bounded.
+ */
+ public boolean getBounded(){
+ return fBounded;
+ }
+
+ /**
+ * Fundamental Facet: cardinality.
+ */
+ public boolean getFinite(){
+ return fFinite;
+ }
+
+ /**
+ * Fundamental Facet: numeric.
+ */
+ public boolean getNumeric(){
+ return fNumeric;
+ }
+
+ /**
+ * Convenience method. [Facets]: check whether a facet is defined on this
+ * type.
+ * @param facetName The name of the facet.
+ * @return True if the facet is defined, false otherwise.
+ */
+ public boolean isDefinedFacet(short facetName) {
+ if (fValidationDV == DV_ANYSIMPLETYPE ||
+ fValidationDV == DV_ANYATOMICTYPE) {
+ return false;
+ }
+ if ((fFacetsDefined & facetName) != 0) {
+ return true;
+ }
+ if (fPatternType != SPECIAL_PATTERN_NONE) {
+ return facetName == FACET_PATTERN;
+ }
+ if (fValidationDV == DV_INTEGER) {
+ return facetName == FACET_PATTERN || facetName == FACET_FRACTIONDIGITS;
+ }
+ return false;
+ }
+
+ /**
+ * [facets]: all facets defined on this type. The value is a bit
+ * combination of FACET_XXX constants of all defined facets.
+ */
+ public short getDefinedFacets() {
+ if (fValidationDV == DV_ANYSIMPLETYPE ||
+ fValidationDV == DV_ANYATOMICTYPE) {
+ return FACET_NONE;
+ }
+ if (fPatternType != SPECIAL_PATTERN_NONE) {
+ return (short)(fFacetsDefined | FACET_PATTERN);
+ }
+ if (fValidationDV == DV_INTEGER) {
+ return (short)(fFacetsDefined | FACET_PATTERN | FACET_FRACTIONDIGITS);
+ }
+ return fFacetsDefined;
+ }
+
+ /**
+ * Convenience method. [Facets]: check whether a facet is defined and
+ * fixed on this type.
+ * @param facetName The name of the facet.
+ * @return True if the facet is fixed, false otherwise.
+ */
+ public boolean isFixedFacet(short facetName) {
+ if ((fFixedFacet & facetName) != 0)
+ return true;
+ if (fValidationDV == DV_INTEGER)
+ return facetName == FACET_FRACTIONDIGITS;
+ return false;
+ }
+
+ /**
+ * [facets]: all defined facets for this type which are fixed.
+ */
+ public short getFixedFacets() {
+ if (fValidationDV == DV_INTEGER)
+ return (short)(fFixedFacet | FACET_FRACTIONDIGITS);
+ return fFixedFacet;
+ }
+
+ /**
+ * Convenience method. Returns a value of a single constraining facet for
+ * this simple type definition. This method must not be used to retrieve
+ * values for enumeration
and pattern
facets.
+ * @param facetName The name of the facet, i.e.
+ * FACET_LENGTH, FACET_TOTALDIGITS
(see
+ * XSConstants
). To retrieve the value for a pattern or
+ * an enumeration, see enumeration
and
+ * pattern
.
+ * @return A value of the facet specified in facetName
for
+ * this simple type definition or null
.
+ */
+ public String getLexicalFacetValue(short facetName) {
+ switch (facetName) {
+ case FACET_LENGTH:
+ return (fLength == -1)?null:Integer.toString(fLength);
+ case FACET_MINLENGTH:
+ return (fMinLength == -1)?null:Integer.toString(fMinLength);
+ case FACET_MAXLENGTH:
+ return (fMaxLength == -1)?null:Integer.toString(fMaxLength);
+ case FACET_WHITESPACE:
+ if (fValidationDV == DV_ANYSIMPLETYPE ||
+ fValidationDV == DV_ANYATOMICTYPE) {
+ return null;
+ }
+ return WS_FACET_STRING[fWhiteSpace];
+ case FACET_MAXINCLUSIVE:
+ return (fMaxInclusive == null)?null:fMaxInclusive.toString();
+ case FACET_MAXEXCLUSIVE:
+ return (fMaxExclusive == null)?null:fMaxExclusive.toString();
+ case FACET_MINEXCLUSIVE:
+ return (fMinExclusive == null)?null:fMinExclusive.toString();
+ case FACET_MININCLUSIVE:
+ return (fMinInclusive == null)?null:fMinInclusive.toString();
+ case FACET_TOTALDIGITS:
+ return (fTotalDigits == -1)?null:Integer.toString(fTotalDigits);
+ case FACET_FRACTIONDIGITS:
+ if (fValidationDV == DV_INTEGER) {
+ return "0";
+ }
+ return (fFractionDigits == -1)?null:Integer.toString(fFractionDigits);
+ }
+ return null;
+ }
+
+ /**
+ * A list of enumeration values if it exists, otherwise an empty
+ * StringList
.
+ */
+ public StringList getLexicalEnumeration() {
+ if (fLexicalEnumeration == null){
+ if (fEnumeration == null)
+ return StringListImpl.EMPTY_LIST;
+ int size = fEnumeration.size();
+ String[] strs = new String[size];
+ for (int i = 0; i < size; i++)
+ strs[i] = fEnumeration.elementAt(i).toString();
+ fLexicalEnumeration = new StringListImpl(strs, size);
+ }
+ return fLexicalEnumeration;
+ }
+
+ /**
+ * A list of actual enumeration values if it exists, otherwise an empty
+ * ObjectList
.
+ */
+ public ObjectList getActualEnumeration() {
+ if (fActualEnumeration == null) {
+ fActualEnumeration = new AbstractObjectList() {
+ public int getLength() {
+ return (fEnumeration != null) ? fEnumeration.size() : 0;
+ }
+ public boolean contains(Object item) {
+ return (fEnumeration != null && fEnumeration.contains(item));
+ }
+ public Object item(int index) {
+ if (index < 0 || index >= getLength()) {
+ return null;
+ }
+ return fEnumeration.elementAt(index);
+ }
+ };
+ }
+ return fActualEnumeration;
+ }
+
/**
* A list of enumeration type values (as a list of ShortList objects) if it exists, otherwise returns
* null
@@ -2213,17 +2282,17 @@
if (fEnumerationItemTypeList == null) {
if(fEnumerationItemType == null)
return null;
- fEnumerationItemTypeList = new ObjectList () {
+ fEnumerationItemTypeList = new AbstractObjectList() {
public int getLength() {
return (fEnumerationItemType != null) ? fEnumerationItemType.length : 0;
}
public boolean contains(Object item) {
- if(fEnumerationItemType == null || !(item instanceof ShortList))
- return false;
- for(int i = 0;i < fEnumerationItemType.length; i++)
- if(fEnumerationItemType[i] == item)
- return true;
- return false;
+ if(fEnumerationItemType == null || !(item instanceof ShortList))
+ return false;
+ for(int i = 0;i < fEnumerationItemType.length; i++)
+ if(fEnumerationItemType[i] == item)
+ return true;
+ return false;
}
public Object item(int index) {
if (index < 0 || index >= getLength()) {
@@ -2235,1015 +2304,1066 @@
}
return fEnumerationItemTypeList;
}
-
- public ShortList getEnumerationTypeList() {
- if (fEnumerationTypeList == null) {
- if (fEnumerationType == null)
- return null;
+
+ public ShortList getEnumerationTypeList() {
+ if (fEnumerationTypeList == null) {
+ if (fEnumerationType == null) {
+ return ShortListImpl.EMPTY_LIST;
+ }
fEnumerationTypeList = new ShortListImpl (fEnumerationType, fEnumerationType.length);
- }
- return fEnumerationTypeList;
- }
-
- /**
- * A list of pattern values if it exists, otherwise an empty
- * StringList
.
- */
- public StringList getLexicalPattern() {
- if (fPatternType == SPECIAL_PATTERN_NONE && fValidationDV != DV_INTEGER && fPatternStr == null)
- return StringListImpl.EMPTY_LIST;
- if (fLexicalPattern == null){
- int size = fPatternStr == null ? 0 : fPatternStr.size();
- String[] strs;
- if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
- strs = new String[size+1];
- strs[size] = "\\c+";
- }
- else if (fPatternType == SPECIAL_PATTERN_NAME) {
- strs = new String[size+1];
- strs[size] = "\\i\\c*";
- }
- else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
- strs = new String[size+2];
- strs[size] = "\\i\\c*";
- strs[size+1] = "[\\i-[:]][\\c-[:]]*";
- }
- else if (fValidationDV == DV_INTEGER) {
- strs = new String[size+1];
- strs[size] = "[\\-+]?[0-9]+";
- }
- else {
- strs = new String[size];
- }
- for (int i = 0; i < size; i++)
- strs[i] = (String)fPatternStr.elementAt(i);
- fLexicalPattern = new StringListImpl(strs, strs.length);
- }
- return fLexicalPattern;
- }
-
- /**
- * [annotations]: a set of annotations for this simple type component if
- * it exists, otherwise an empty XSObjectList
.
- */
- public XSObjectList getAnnotations() {
- return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
- }
-
- 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 = fMemberTypes;
- for(int i = 0 ; i < memberTypes.length ; i++){
- if(!memberTypes[i].getNumeric() ){
- 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].getBounded() || (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.fFinite){
- this.fFinite = true;
- }
- else {// (!fBase.fFinite)
- if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )
- || ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){
- this.fFinite = true;
- }
- 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.fFinite = true;
- }
- else{
- this.fFinite = false;
- }
- }
- else{
- this.fFinite = false;
- }
- }
- }
- else if(fVariety == VARIETY_LIST){
- if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ( ((this.fFacetsDefined & FACET_MINLENGTH) != 0 )
- && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){
- this.fFinite = true;
- }
- else{
- this.fFinite = false;
- }
-
- }
- else if(fVariety == VARIETY_UNION){
- XSSimpleType [] memberTypes = fMemberTypes;
- for(int i = 0 ; i < memberTypes.length ; i++){
- if(!(memberTypes[i].getFinite()) ){
- this.fFinite = false;
- return;
- }
- }
- this.fFinite = true;
- }
-
- }//setCardinality
-
- private short getPrimitiveDV(short validationDV){
-
- if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
- return DV_STRING;
- }
- else if (validationDV == DV_INTEGER) {
- return DV_DECIMAL;
- }
- else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
- return DV_DURATION;
- }
- else {
- return validationDV;
- }
-
- }//getPrimitiveDV()
-
- public boolean derivedFromType(XSTypeDefinition ancestor, short derivation) {
- // REVISIT: implement according to derivation
-
- // ancestor is null, retur false
- if (ancestor == null)
- return false;
- // ancestor is anyType, return true
- // anyType is the only type whose base type is itself
- if (ancestor.getBaseType() == ancestor)
- return true;
- // recursively get base, and compare it with ancestor
- XSTypeDefinition type = this;
- while (type != ancestor && // compare with ancestor
- type != fAnySimpleType) { // reached anySimpleType
- type = type.getBaseType();
- }
-
- return type == ancestor;
- }
-
- public boolean derivedFrom(String ancestorNS, String ancestorName, short derivation) {
- // REVISIT: implement according to derivation
-
- // ancestor is null, retur false
- if (ancestorName == null)
- return false;
- // ancestor is anyType, return true
- if (URI_SCHEMAFORSCHEMA.equals(ancestorNS) &&
- ANY_TYPE.equals(ancestorName)) {
- return true;
- }
-
- // recursively get base, and compare it with ancestor
- XSTypeDefinition type = this;
- while (!(ancestorName.equals(type.getName()) &&
- ((ancestorNS == null && type.getNamespace() == null) ||
- (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
- type != fAnySimpleType) { // reached anySimpleType
- type = (XSTypeDefinition)type.getBaseType();
- }
-
- return type != fAnySimpleType;
- }
-
- /**
- * Checks if a type is derived from another by restriction, given the name
- * and namespace. See:
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param derivationMethod
- * The derivation method
- *
- * @return boolean True if the ancestor type is derived from the reference type by the specifiied derivation method.
- */
- public boolean isDOMDerivedFrom(String ancestorNS, String ancestorName, int derivationMethod) {
-
- // ancestor is null, return false
- if (ancestorName == null)
- return false;
-
- // ancestor is anyType, return true
- if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(ancestorNS)
- && SchemaSymbols.ATTVAL_ANYTYPE.equals(ancestorName)
- && (((derivationMethod & DERIVATION_RESTRICTION) != 0)
- || (derivationMethod == DERIVATION_ANY))) {
- return true;
- }
-
- // restriction
- if ((derivationMethod & DERIVATION_RESTRICTION) != 0) {
- if (isDerivedByRestriction(ancestorNS, ancestorName, this)) {
- return true;
- }
- }
-
- // list
- if ((derivationMethod & DERIVATION_LIST) != 0) {
- if (isDerivedByList(ancestorNS, ancestorName, this)) {
- return true;
- }
- }
-
- // union
- if ((derivationMethod & DERIVATION_UNION) != 0) {
- if (isDerivedByUnion(ancestorNS, ancestorName, this)) {
- return true;
- }
- }
-
- // extension
- if (((derivationMethod & DERIVATION_EXTENSION) != 0)
- && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
- && ((derivationMethod & DERIVATION_LIST) == 0)
- && ((derivationMethod & DERIVATION_UNION) == 0))) {
- return false;
- }
-
- // If the value of the parameter is 0 i.e. no bit (corresponding to
- // restriction, list, extension or union) is set to 1 for the
- // derivationMethod parameter.
- if (((derivationMethod & DERIVATION_EXTENSION) == 0)
- && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
- && ((derivationMethod & DERIVATION_LIST) == 0)
- && ((derivationMethod & DERIVATION_UNION) == 0))) {
- return isDerivedByAny(ancestorNS, ancestorName, this);
- }
-
- return false;
- }
-
-
- /**
- * Checks if a type is derived from another by any combination of restriction, list ir union. See:
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by restriciton for the reference type
- */
- private boolean isDerivedByAny(String ancestorNS, String ancestorName,
- XSTypeDefinition type) {
-
- boolean derivedFrom = false;
- XSTypeDefinition oldType = null;
- // for each base, item or member type
- while (type != null && type != oldType) {
-
- // If the ancestor type is reached or is the same as this type.
- if ((ancestorName.equals(type.getName()))
- && ((ancestorNS == null && type.getNamespace() == null)
- || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
- derivedFrom = true;
- break;
- }
-
- // check if derived by restriction or list or union
- if (isDerivedByRestriction(ancestorNS, ancestorName, type)) {
- return true;
- } else if (isDerivedByList(ancestorNS, ancestorName, type)) {
- return true;
- } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) {
- return true;
- }
- oldType = type;
- // get the base, item or member type depending on the variety
- if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT
- || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) {
- type = type.getBaseType();
- } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) {
- for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) {
- return isDerivedByAny(ancestorNS, ancestorName,
- (XSTypeDefinition) ((XSSimpleTypeDecl) type)
- .getMemberTypes().item(i));
- }
- } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) {
- type = ((XSSimpleTypeDecl) type).getItemType();
- }
- }
-
- return derivedFrom;
- }
-
- /**
- * DOM Level 3
- * Checks if a type is derived from another by restriction. See:
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by restriciton for the
- * reference type
- */
- private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) {
+ }
+ return fEnumerationTypeList;
+ }
+
+ /**
+ * A list of pattern values if it exists, otherwise an empty
+ * StringList
.
+ */
+ public StringList getLexicalPattern() {
+ if (fPatternType == SPECIAL_PATTERN_NONE && fValidationDV != DV_INTEGER && fPatternStr == null)
+ return StringListImpl.EMPTY_LIST;
+ if (fLexicalPattern == null){
+ int size = fPatternStr == null ? 0 : fPatternStr.size();
+ String[] strs;
+ if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
+ strs = new String[size+1];
+ strs[size] = "\\c+";
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NAME) {
+ strs = new String[size+1];
+ strs[size] = "\\i\\c*";
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
+ strs = new String[size+2];
+ strs[size] = "\\i\\c*";
+ strs[size+1] = "[\\i-[:]][\\c-[:]]*";
+ }
+ else if (fValidationDV == DV_INTEGER) {
+ strs = new String[size+1];
+ strs[size] = "[\\-+]?[0-9]+";
+ }
+ else {
+ strs = new String[size];
+ }
+ for (int i = 0; i < size; i++)
+ strs[i] = (String)fPatternStr.elementAt(i);
+ fLexicalPattern = new StringListImpl(strs, strs.length);
+ }
+ return fLexicalPattern;
+ }
+
+ /**
+ * [annotations]: a set of annotations for this simple type component if
+ * it exists, otherwise an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
+ }
+
+ private void calcFundamentalFacets() {
+ 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 = fMemberTypes;
+ for(int i = 0 ; i < memberTypes.length ; i++){
+ if(!memberTypes[i].getNumeric() ){
+ 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].getBounded() || (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.fFinite){
+ this.fFinite = true;
+ }
+ else {// (!fBase.fFinite)
+ if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )
+ || ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){
+ this.fFinite = true;
+ }
+ 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.fFinite = true;
+ }
+ else{
+ this.fFinite = false;
+ }
+ }
+ else{
+ this.fFinite = false;
+ }
+ }
+ }
+ else if(fVariety == VARIETY_LIST){
+ if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ( ((this.fFacetsDefined & FACET_MINLENGTH) != 0 )
+ && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){
+ this.fFinite = true;
+ }
+ else{
+ this.fFinite = false;
+ }
+
+ }
+ else if(fVariety == VARIETY_UNION){
+ XSSimpleType [] memberTypes = fMemberTypes;
+ for(int i = 0 ; i < memberTypes.length ; i++){
+ if(!(memberTypes[i].getFinite()) ){
+ this.fFinite = false;
+ return;
+ }
+ }
+ this.fFinite = true;
+ }
+
+ }//setCardinality
+
+ private short getPrimitiveDV(short validationDV){
+
+ if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
+ return DV_STRING;
+ }
+ else if (validationDV == DV_INTEGER) {
+ return DV_DECIMAL;
+ }
+ else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
+ return DV_DURATION;
+ }
+ else {
+ return validationDV;
+ }
+
+ }//getPrimitiveDV()
+
+ public boolean derivedFromType(XSTypeDefinition ancestor, short derivation) {
+ // REVISIT: implement according to derivation
+
+ // ancestor is null, return false
+ if (ancestor == null) {
+ return false;
+ }
+ // extract the actual XSTypeDefinition if the given ancestor is a delegate.
+ while (ancestor instanceof XSSimpleTypeDelegate) {
+ ancestor = ((XSSimpleTypeDelegate) ancestor).type;
+ }
+ // ancestor is anyType, return true
+ // anyType is the only type whose base type is itself
+ if (ancestor.getBaseType() == ancestor) {
+ return true;
+ }
+ // recursively get base, and compare it with ancestor
+ XSTypeDefinition type = this;
+ while (type != ancestor && // compare with ancestor
+ type != fAnySimpleType) { // reached anySimpleType
+ type = type.getBaseType();
+ }
+ return type == ancestor;
+ }
+
+ public boolean derivedFrom(String ancestorNS, String ancestorName, short derivation) {
+ // REVISIT: implement according to derivation
+
+ // ancestor is null, retur false
+ if (ancestorName == null)
+ return false;
+ // ancestor is anyType, return true
+ if (URI_SCHEMAFORSCHEMA.equals(ancestorNS) &&
+ ANY_TYPE.equals(ancestorName)) {
+ return true;
+ }
+
+ // recursively get base, and compare it with ancestor
+ XSTypeDefinition type = this;
+ while (!(ancestorName.equals(type.getName()) &&
+ ((ancestorNS == null && type.getNamespace() == null) ||
+ (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
+ type != fAnySimpleType) { // reached anySimpleType
+ type = (XSTypeDefinition)type.getBaseType();
+ }
+
+ return type != fAnySimpleType;
+ }
+
+ /**
+ * Checks if a type is derived from another by restriction, given the name
+ * and namespace. See:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
+ *
+ * @param ancestorNS
+ * The namspace of the ancestor type declaration
+ * @param ancestorName
+ * The name of the ancestor type declaration
+ * @param derivationMethod
+ * The derivation method
+ *
+ * @return boolean True if the ancestor type is derived from the reference type by the specifiied derivation method.
+ */
+ public boolean isDOMDerivedFrom(String ancestorNS, String ancestorName, int derivationMethod) {
+
+ // ancestor is null, return false
+ if (ancestorName == null)
+ return false;
+
+ // ancestor is anyType, return true
+ if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(ancestorNS)
+ && SchemaSymbols.ATTVAL_ANYTYPE.equals(ancestorName)
+ && (((derivationMethod & DERIVATION_RESTRICTION) != 0)
+ || (derivationMethod == DERIVATION_ANY))) {
+ return true;
+ }
+
+ // restriction
+ if ((derivationMethod & DERIVATION_RESTRICTION) != 0) {
+ if (isDerivedByRestriction(ancestorNS, ancestorName, this)) {
+ return true;
+ }
+ }
+
+ // list
+ if ((derivationMethod & DERIVATION_LIST) != 0) {
+ if (isDerivedByList(ancestorNS, ancestorName, this)) {
+ return true;
+ }
+ }
+
+ // union
+ if ((derivationMethod & DERIVATION_UNION) != 0) {
+ if (isDerivedByUnion(ancestorNS, ancestorName, this)) {
+ return true;
+ }
+ }
+
+ // extension
+ if (((derivationMethod & DERIVATION_EXTENSION) != 0)
+ && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
+ && ((derivationMethod & DERIVATION_LIST) == 0)
+ && ((derivationMethod & DERIVATION_UNION) == 0))) {
+ return false;
+ }
+
+ // If the value of the parameter is 0 i.e. no bit (corresponding to
+ // restriction, list, extension or union) is set to 1 for the
+ // derivationMethod parameter.
+ if (((derivationMethod & DERIVATION_EXTENSION) == 0)
+ && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
+ && ((derivationMethod & DERIVATION_LIST) == 0)
+ && ((derivationMethod & DERIVATION_UNION) == 0))) {
+ return isDerivedByAny(ancestorNS, ancestorName, this);
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Checks if a type is derived from another by any combination of restriction, list ir union. See:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
+ *
+ * @param ancestorNS
+ * The namspace of the ancestor type declaration
+ * @param ancestorName
+ * The name of the ancestor type declaration
+ * @param type
+ * The reference type definition
+ *
+ * @return boolean True if the type is derived by restriciton for the reference type
+ */
+ private boolean isDerivedByAny(String ancestorNS, String ancestorName,
+ XSTypeDefinition type) {
+
+ boolean derivedFrom = false;
+ XSTypeDefinition oldType = null;
+ // for each base, item or member type
+ while (type != null && type != oldType) {
+
+ // If the ancestor type is reached or is the same as this type.
+ if ((ancestorName.equals(type.getName()))
+ && ((ancestorNS == null && type.getNamespace() == null)
+ || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
+ derivedFrom = true;
+ break;
+ }
+
+ // check if derived by restriction or list or union
+ if (isDerivedByRestriction(ancestorNS, ancestorName, type)) {
+ return true;
+ } else if (isDerivedByList(ancestorNS, ancestorName, type)) {
+ return true;
+ } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) {
+ return true;
+ }
+ oldType = type;
+ // get the base, item or member type depending on the variety
+ if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT
+ || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) {
+ type = type.getBaseType();
+ } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) {
+ for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) {
+ return isDerivedByAny(ancestorNS, ancestorName,
+ (XSTypeDefinition) ((XSSimpleTypeDecl) type)
+ .getMemberTypes().item(i));
+ }
+ } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) {
+ type = ((XSSimpleTypeDecl) type).getItemType();
+ }
+ }
+
+ return derivedFrom;
+ }
+
+ /**
+ * DOM Level 3
+ * Checks if a type is derived from another by restriction. See:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
+ *
+ * @param ancestorNS
+ * The namspace of the ancestor type declaration
+ * @param ancestorName
+ * The name of the ancestor type declaration
+ * @param type
+ * The reference type definition
+ *
+ * @return boolean True if the type is derived by restriciton for the
+ * reference type
+ */
+ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) {
XSTypeDefinition oldType = null;
- while (type != null && type != oldType) {
- if ((ancestorName.equals(type.getName()))
- && ((ancestorNS != null && ancestorNS.equals(type.getNamespace()))
- || (type.getNamespace() == null && ancestorNS == null))) {
-
- return true;
- }
+ while (type != null && type != oldType) {
+ if ((ancestorName.equals(type.getName()))
+ && ((ancestorNS != null && ancestorNS.equals(type.getNamespace()))
+ || (type.getNamespace() == null && ancestorNS == null))) {
+
+ return true;
+ }
oldType = type;
- type = type.getBaseType();
- }
-
- return false;
- }
-
- /**
- * Checks if a type is derived from another by list. See:
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by list for the reference type
- */
- private boolean isDerivedByList (String ancestorNS, String ancestorName, XSTypeDefinition type) {
- // If the variety is union
- if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() == VARIETY_LIST) {
-
- // get the {item type}
- XSTypeDefinition itemType = ((XSSimpleTypeDefinition)type).getItemType();
-
- // T2 is the {item type definition}
- if (itemType != null) {
-
- // T2 is derived from the other type definition by DERIVATION_RESTRICTION
- if (isDerivedByRestriction(ancestorNS, ancestorName, itemType)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Checks if a type is derived from another by union. See:
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by union for the reference type
- */
- private boolean isDerivedByUnion (String ancestorNS, String ancestorName, XSTypeDefinition type) {
-
- // If the variety is union
- if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() == VARIETY_UNION) {
-
- // get member types
- XSObjectList memberTypes = ((XSSimpleTypeDefinition)type).getMemberTypes();
-
- for (int i = 0; i < memberTypes.getLength(); i++) {
- // One of the {member type definitions} is T2.
- if (memberTypes.item(i) != null) {
- // T2 is derived from the other type definition by DERIVATION_RESTRICTION
- if (isDerivedByRestriction(ancestorNS, ancestorName,(XSSimpleTypeDefinition)memberTypes.item(i))) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
- static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, true, false, true, XSConstants.ANYSIMPLETYPE_DT);
-
- static final XSSimpleTypeDecl fAnyAtomicType = new XSSimpleTypeDecl(fAnySimpleType, "anyAtomicType", DV_ANYATOMICTYPE, ORDERED_FALSE, false, true, false, true, XSSimpleTypeDecl.ANYATOMICTYPE_DT);
-
- /**
- * Validation context used to validate facet values.
- */
- static final ValidationContext fDummyContext = new ValidationContext() {
- public boolean needFacetChecking() {
- return true;
- }
-
- public boolean needExtraChecking() {
- return false;
- }
- public boolean needToNormalize() {
- return false;
- }
- public boolean useNamespaces() {
- return true;
- }
-
- public boolean isEntityDeclared(String name) {
- return false;
- }
-
- public boolean isEntityUnparsed(String name) {
- return false;
- }
-
- public boolean isIdDeclared(String name) {
- return false;
- }
-
- public void addId(String name) {
- }
-
- public void addIdRef(String name) {
- }
-
- public String getSymbol (String symbol) {
- return symbol.intern();
- }
-
- public String getURI(String prefix) {
- return null;
- }
-
- public Locale getLocale() {
- return Locale.getDefault();
+ type = type.getBaseType();
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if a type is derived from another by list. See:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
+ *
+ * @param ancestorNS
+ * The namspace of the ancestor type declaration
+ * @param ancestorName
+ * The name of the ancestor type declaration
+ * @param type
+ * The reference type definition
+ *
+ * @return boolean True if the type is derived by list for the reference type
+ */
+ private boolean isDerivedByList (String ancestorNS, String ancestorName, XSTypeDefinition type) {
+ // If the variety is union
+ if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() == VARIETY_LIST) {
+
+ // get the {item type}
+ XSTypeDefinition itemType = ((XSSimpleTypeDefinition)type).getItemType();
+
+ // T2 is the {item type definition}
+ if (itemType != null) {
+
+ // T2 is derived from the other type definition by DERIVATION_RESTRICTION
+ if (isDerivedByRestriction(ancestorNS, ancestorName, itemType)) {
+ return true;
}
- };
-
- private boolean fAnonymous = false;
-
- /**
- * A wrapper of ValidationContext, to provide a way of switching to a
- * different Namespace declaration context.
- */
- class ValidationContextImpl implements ValidationContext {
- ValidationContext fExternal;
- ValidationContextImpl(ValidationContext external) {
- fExternal = external;
- }
-
- NamespaceContext fNSContext;
- void setNSContext(NamespaceContext nsContext) {
- fNSContext = nsContext;
- }
-
- public boolean needFacetChecking() {
- return fExternal.needFacetChecking();
- }
-
- public boolean needExtraChecking() {
- return fExternal.needExtraChecking();
- }
- public boolean needToNormalize() {
- return fExternal.needToNormalize();
- }
- // schema validation is predicated upon namespaces
- public boolean useNamespaces() {
- return true;
- }
-
- public boolean isEntityDeclared (String name) {
- return fExternal.isEntityDeclared(name);
- }
-
- public boolean isEntityUnparsed (String name) {
- return fExternal.isEntityUnparsed(name);
- }
-
- public boolean isIdDeclared (String name) {
- return fExternal.isIdDeclared(name);
- }
-
- public void addId(String name) {
- fExternal.addId(name);
- }
-
- public void addIdRef(String name) {
- fExternal.addIdRef(name);
- }
-
- public String getSymbol (String symbol) {
- return fExternal.getSymbol(symbol);
- }
-
- public String getURI(String prefix) {
- if (fNSContext == null)
- return fExternal.getURI(prefix);
- else
- return fNSContext.getURI(prefix);
- }
-
- public Locale getLocale() {
- return fExternal.getLocale();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a type is derived from another by union. See:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
+ *
+ * @param ancestorNS
+ * The namspace of the ancestor type declaration
+ * @param ancestorName
+ * The name of the ancestor type declaration
+ * @param type
+ * The reference type definition
+ *
+ * @return boolean True if the type is derived by union for the reference type
+ */
+ private boolean isDerivedByUnion (String ancestorNS, String ancestorName, XSTypeDefinition type) {
+
+ // If the variety is union
+ if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() == VARIETY_UNION) {
+
+ // get member types
+ XSObjectList memberTypes = ((XSSimpleTypeDefinition)type).getMemberTypes();
+
+ for (int i = 0; i < memberTypes.getLength(); i++) {
+ // One of the {member type definitions} is T2.
+ if (memberTypes.item(i) != null) {
+ // T2 is derived from the other type definition by DERIVATION_RESTRICTION
+ if (isDerivedByRestriction(ancestorNS, ancestorName,(XSSimpleTypeDefinition)memberTypes.item(i))) {
+ return true;
+ }
}
- }
-
- public void reset(){
-
- // if it's immutable, can't be reset:
- if (fIsImmutable) return;
- fItemType = null;
- fMemberTypes = null;
-
- fTypeName = null;
- fTargetNamespace = null;
- fFinalSet = 0;
- fBase = null;
- fVariety = -1;
- fValidationDV = -1;
-
- fFacetsDefined = 0;
- fFixedFacet = 0;
-
- //for constraining facets
- fWhiteSpace = 0;
- fLength = -1;
- fMinLength = -1;
- fMaxLength = -1;
- fTotalDigits = -1;
- fFractionDigits = -1;
- fPattern = null;
- fPatternStr = null;
- fEnumeration = null;
- fEnumerationType = null;
+ }
+ }
+ return false;
+ }
+
+
+ static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, true, false, true, XSConstants.ANYSIMPLETYPE_DT);
+
+ static final XSSimpleTypeDecl fAnyAtomicType = new XSSimpleTypeDecl(fAnySimpleType, "anyAtomicType", DV_ANYATOMICTYPE, ORDERED_FALSE, false, true, false, true, XSSimpleTypeDecl.ANYATOMICTYPE_DT);
+
+ /**
+ * Validation context used to validate facet values.
+ */
+ static final ValidationContext fDummyContext = new ValidationContext() {
+ public boolean needFacetChecking() {
+ return true;
+ }
+
+ public boolean needExtraChecking() {
+ return false;
+ }
+ public boolean needToNormalize() {
+ return false;
+ }
+ public boolean useNamespaces() {
+ return true;
+ }
+
+ public boolean isEntityDeclared(String name) {
+ return false;
+ }
+
+ public boolean isEntityUnparsed(String name) {
+ return false;
+ }
+
+ public boolean isIdDeclared(String name) {
+ return false;
+ }
+
+ public void addId(String name) {
+ }
+
+ public void addIdRef(String name) {
+ }
+
+ public String getSymbol (String symbol) {
+ return symbol.intern();
+ }
+
+ public String getURI(String prefix) {
+ return null;
+ }
+
+ public Locale getLocale() {
+ return Locale.getDefault();
+ }
+ };
+
+ private boolean fAnonymous = false;
+
+ /**
+ * A wrapper of ValidationContext, to provide a way of switching to a
+ * different Namespace declaration context.
+ */
+ static final class ValidationContextImpl implements ValidationContext {
+
+ final ValidationContext fExternal;
+
+ ValidationContextImpl(ValidationContext external) {
+ fExternal = external;
+ }
+
+ NamespaceContext fNSContext;
+ void setNSContext(NamespaceContext nsContext) {
+ fNSContext = nsContext;
+ }
+
+ public boolean needFacetChecking() {
+ return fExternal.needFacetChecking();
+ }
+
+ public boolean needExtraChecking() {
+ return fExternal.needExtraChecking();
+ }
+ public boolean needToNormalize() {
+ return fExternal.needToNormalize();
+ }
+ // schema validation is predicated upon namespaces
+ public boolean useNamespaces() {
+ return true;
+ }
+
+ public boolean isEntityDeclared (String name) {
+ return fExternal.isEntityDeclared(name);
+ }
+
+ public boolean isEntityUnparsed (String name) {
+ return fExternal.isEntityUnparsed(name);
+ }
+
+ public boolean isIdDeclared (String name) {
+ return fExternal.isIdDeclared(name);
+ }
+
+ public void addId(String name) {
+ fExternal.addId(name);
+ }
+
+ public void addIdRef(String name) {
+ fExternal.addIdRef(name);
+ }
+
+ public String getSymbol (String symbol) {
+ return fExternal.getSymbol(symbol);
+ }
+
+ public String getURI(String prefix) {
+ if (fNSContext == null) {
+ return fExternal.getURI(prefix);
+ }
+ else {
+ return fNSContext.getURI(prefix);
+ }
+ }
+
+ public Locale getLocale() {
+ return fExternal.getLocale();
+ }
+ }
+
+ public void reset(){
+
+ // if it's immutable, can't be reset:
+ if (fIsImmutable) return;
+ fItemType = null;
+ fMemberTypes = null;
+
+ fTypeName = null;
+ fTargetNamespace = null;
+ fFinalSet = 0;
+ fBase = null;
+ fVariety = -1;
+ fValidationDV = -1;
+
+ fFacetsDefined = 0;
+ fFixedFacet = 0;
+
+ //for constraining facets
+ fWhiteSpace = 0;
+ fLength = -1;
+ fMinLength = -1;
+ fMaxLength = -1;
+ fTotalDigits = -1;
+ fFractionDigits = -1;
+ fPattern = null;
+ fPatternStr = null;
+ fEnumeration = null;
+ fEnumerationType = null;
fEnumerationItemType = null;
- fLexicalPattern = null;
- fLexicalEnumeration = null;
- fMaxInclusive = null;
- fMaxExclusive = null;
- fMinExclusive = null;
- fMinInclusive = null;
- lengthAnnotation = null;
- minLengthAnnotation = null;
- maxLengthAnnotation = null;
- whiteSpaceAnnotation = null;
- totalDigitsAnnotation = null;
- fractionDigitsAnnotation = null;
- patternAnnotations = null;
- enumerationAnnotations = null;
- maxInclusiveAnnotation = null;
- maxExclusiveAnnotation = null;
- minInclusiveAnnotation = null;
- minExclusiveAnnotation = null;
-
- fPatternType = SPECIAL_PATTERN_NONE;
- fAnnotations = null;
- fFacets = null;
-
- // REVISIT: reset for fundamental facets
- }
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return this.fTargetNamespace+"," +this.fTypeName;
- }
-
- /**
- * A list of constraining facets if it exists, otherwise an empty
- * XSObjectList
. Note: This method must not be used to
- * retrieve values for enumeration
and pattern
- * facets.
- */
- public XSObjectList getFacets() {
- if (fFacets == null &&
- (fFacetsDefined != 0 || fValidationDV == DV_INTEGER)) {
-
- XSFacetImpl[] facets = new XSFacetImpl[10];
- int count = 0;
- if ((fFacetsDefined & FACET_WHITESPACE) != 0) {
- facets[count] =
- new XSFacetImpl(
- FACET_WHITESPACE,
- WS_FACET_STRING[fWhiteSpace],
- (fFixedFacet & FACET_WHITESPACE) != 0,
- whiteSpaceAnnotation);
- count++;
- }
- if (fLength != -1) {
- facets[count] =
- new XSFacetImpl(
- FACET_LENGTH,
- Integer.toString(fLength),
- (fFixedFacet & FACET_LENGTH) != 0,
- lengthAnnotation);
- count++;
- }
- if (fMinLength != -1) {
- facets[count] =
- new XSFacetImpl(
- FACET_MINLENGTH,
- Integer.toString(fMinLength),
- (fFixedFacet & FACET_MINLENGTH) != 0,
- minLengthAnnotation);
- count++;
- }
- if (fMaxLength != -1) {
- facets[count] =
- new XSFacetImpl(
- FACET_MAXLENGTH,
- Integer.toString(fMaxLength),
- (fFixedFacet & FACET_MAXLENGTH) != 0,
- maxLengthAnnotation);
- count++;
- }
- if (fTotalDigits != -1) {
- facets[count] =
- new XSFacetImpl(
- FACET_TOTALDIGITS,
- Integer.toString(fTotalDigits),
- (fFixedFacet & FACET_TOTALDIGITS) != 0,
- totalDigitsAnnotation);
- count++;
- }
- if (fValidationDV == DV_INTEGER) {
- facets[count] =
- new XSFacetImpl(
- FACET_FRACTIONDIGITS,
- "0",
- true,
- null);
- count++;
- }
- if (fFractionDigits != -1) {
- facets[count] =
- new XSFacetImpl(
- FACET_FRACTIONDIGITS,
- Integer.toString(fFractionDigits),
- (fFixedFacet & FACET_FRACTIONDIGITS) != 0,
- fractionDigitsAnnotation);
- count++;
- }
- if (fMaxInclusive != null) {
- facets[count] =
- new XSFacetImpl(
- FACET_MAXINCLUSIVE,
- fMaxInclusive.toString(),
- (fFixedFacet & FACET_MAXINCLUSIVE) != 0,
- maxInclusiveAnnotation);
- count++;
- }
- if (fMaxExclusive != null) {
- facets[count] =
- new XSFacetImpl(
- FACET_MAXEXCLUSIVE,
- fMaxExclusive.toString(),
- (fFixedFacet & FACET_MAXEXCLUSIVE) != 0,
- maxExclusiveAnnotation);
- count++;
- }
- if (fMinExclusive != null) {
- facets[count] =
- new XSFacetImpl(
- FACET_MINEXCLUSIVE,
- fMinExclusive.toString(),
- (fFixedFacet & FACET_MINEXCLUSIVE) != 0,
- minExclusiveAnnotation);
- count++;
- }
- if (fMinInclusive != null) {
- facets[count] =
- new XSFacetImpl(
- FACET_MININCLUSIVE,
- fMinInclusive.toString(),
- (fFixedFacet & FACET_MININCLUSIVE) != 0,
- minInclusiveAnnotation);
- count++;
- }
- fFacets = new XSObjectListImpl(facets, count);
- }
- return (fFacets != null) ? fFacets : XSObjectListImpl.EMPTY_LIST;
- }
-
- /**
- * A list of enumeration and pattern constraining facets if it exists,
- * otherwise an empty XSObjectList
.
- */
- public XSObjectList getMultiValueFacets() {
- if (fMultiValueFacets == null &&
- ((fFacetsDefined & FACET_ENUMERATION) != 0 ||
- (fFacetsDefined & FACET_PATTERN) != 0 ||
- fPatternType != SPECIAL_PATTERN_NONE ||
- fValidationDV == DV_INTEGER)) {
-
- XSMVFacetImpl[] facets = new XSMVFacetImpl[2];
- int count = 0;
- if ((fFacetsDefined & FACET_PATTERN) != 0 ||
- fPatternType != SPECIAL_PATTERN_NONE ||
- fValidationDV == DV_INTEGER) {
- facets[count] =
- new XSMVFacetImpl(
- FACET_PATTERN,
- this.getLexicalPattern(),
- patternAnnotations);
- count++;
- }
- if (fEnumeration != null) {
- facets[count] =
- new XSMVFacetImpl(
- FACET_ENUMERATION,
- this.getLexicalEnumeration(),
- enumerationAnnotations);
- count++;
- }
- fMultiValueFacets = new XSObjectListImpl(facets, count);
- }
- return (fMultiValueFacets != null) ?
- fMultiValueFacets : XSObjectListImpl.EMPTY_LIST;
- }
-
+ fLexicalPattern = null;
+ fLexicalEnumeration = null;
+ fMaxInclusive = null;
+ fMaxExclusive = null;
+ fMinExclusive = null;
+ fMinInclusive = null;
+ lengthAnnotation = null;
+ minLengthAnnotation = null;
+ maxLengthAnnotation = null;
+ whiteSpaceAnnotation = null;
+ totalDigitsAnnotation = null;
+ fractionDigitsAnnotation = null;
+ patternAnnotations = null;
+ enumerationAnnotations = null;
+ maxInclusiveAnnotation = null;
+ maxExclusiveAnnotation = null;
+ minInclusiveAnnotation = null;
+ minExclusiveAnnotation = null;
+
+ fPatternType = SPECIAL_PATTERN_NONE;
+ fAnnotations = null;
+ fFacets = null;
+
+ // REVISIT: reset for fundamental facets
+ }
+
+ /**
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return fNamespaceItem;
+ }
+
+ public void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.fTargetNamespace+"," +this.fTypeName;
+ }
+
+ /**
+ * A list of constraining facets if it exists, otherwise an empty
+ * XSObjectList
. Note: This method must not be used to
+ * retrieve values for enumeration
and pattern
+ * facets.
+ */
+ public XSObjectList getFacets() {
+ if (fFacets == null &&
+ (fFacetsDefined != 0 || fValidationDV == DV_INTEGER)) {
+
+ XSFacetImpl[] facets = new XSFacetImpl[10];
+ int count = 0;
+ if ((fFacetsDefined & FACET_WHITESPACE) != 0 &&
+ fValidationDV != DV_ANYSIMPLETYPE &&
+ fValidationDV != DV_ANYATOMICTYPE) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_WHITESPACE,
+ WS_FACET_STRING[fWhiteSpace],
+ (fFixedFacet & FACET_WHITESPACE) != 0,
+ whiteSpaceAnnotation);
+ count++;
+ }
+ if (fLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_LENGTH,
+ Integer.toString(fLength),
+ (fFixedFacet & FACET_LENGTH) != 0,
+ lengthAnnotation);
+ count++;
+ }
+ if (fMinLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MINLENGTH,
+ Integer.toString(fMinLength),
+ (fFixedFacet & FACET_MINLENGTH) != 0,
+ minLengthAnnotation);
+ count++;
+ }
+ if (fMaxLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXLENGTH,
+ Integer.toString(fMaxLength),
+ (fFixedFacet & FACET_MAXLENGTH) != 0,
+ maxLengthAnnotation);
+ count++;
+ }
+ if (fTotalDigits != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_TOTALDIGITS,
+ Integer.toString(fTotalDigits),
+ (fFixedFacet & FACET_TOTALDIGITS) != 0,
+ totalDigitsAnnotation);
+ count++;
+ }
+ if (fValidationDV == DV_INTEGER) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_FRACTIONDIGITS,
+ "0",
+ true,
+ fractionDigitsAnnotation);
+ count++;
+ }
+ else if (fFractionDigits != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_FRACTIONDIGITS,
+ Integer.toString(fFractionDigits),
+ (fFixedFacet & FACET_FRACTIONDIGITS) != 0,
+ fractionDigitsAnnotation);
+ count++;
+ }
+ if (fMaxInclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXINCLUSIVE,
+ fMaxInclusive.toString(),
+ (fFixedFacet & FACET_MAXINCLUSIVE) != 0,
+ maxInclusiveAnnotation);
+ count++;
+ }
+ if (fMaxExclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXEXCLUSIVE,
+ fMaxExclusive.toString(),
+ (fFixedFacet & FACET_MAXEXCLUSIVE) != 0,
+ maxExclusiveAnnotation);
+ count++;
+ }
+ if (fMinExclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MINEXCLUSIVE,
+ fMinExclusive.toString(),
+ (fFixedFacet & FACET_MINEXCLUSIVE) != 0,
+ minExclusiveAnnotation);
+ count++;
+ }
+ if (fMinInclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MININCLUSIVE,
+ fMinInclusive.toString(),
+ (fFixedFacet & FACET_MININCLUSIVE) != 0,
+ minInclusiveAnnotation);
+ count++;
+ }
+ fFacets = (count > 0) ? new XSObjectListImpl(facets, count) : XSObjectListImpl.EMPTY_LIST;
+ }
+ return (fFacets != null) ? fFacets : XSObjectListImpl.EMPTY_LIST;
+ }
+
+ /**
+ * A list of enumeration and pattern constraining facets if it exists,
+ * otherwise an empty XSObjectList
.
+ */
+ public XSObjectList getMultiValueFacets() {
+ if (fMultiValueFacets == null &&
+ ((fFacetsDefined & FACET_ENUMERATION) != 0 ||
+ (fFacetsDefined & FACET_PATTERN) != 0 ||
+ fPatternType != SPECIAL_PATTERN_NONE ||
+ fValidationDV == DV_INTEGER)) {
+
+ XSMVFacetImpl[] facets = new XSMVFacetImpl[2];
+ int count = 0;
+ if ((fFacetsDefined & FACET_PATTERN) != 0 ||
+ fPatternType != SPECIAL_PATTERN_NONE ||
+ fValidationDV == DV_INTEGER) {
+ facets[count] =
+ new XSMVFacetImpl(
+ FACET_PATTERN,
+ this.getLexicalPattern(),
+ patternAnnotations);
+ count++;
+ }
+ if (fEnumeration != null) {
+ facets[count] =
+ new XSMVFacetImpl(
+ FACET_ENUMERATION,
+ this.getLexicalEnumeration(),
+ enumerationAnnotations);
+ count++;
+ }
+ fMultiValueFacets = new XSObjectListImpl(facets, count);
+ }
+ return (fMultiValueFacets != null) ?
+ fMultiValueFacets : XSObjectListImpl.EMPTY_LIST;
+ }
+
public Object getMinInclusiveValue() {
return fMinInclusive;
}
-
+
public Object getMinExclusiveValue() {
return fMinExclusive;
}
-
+
public Object getMaxInclusiveValue() {
return fMaxInclusive;
}
-
+
public Object getMaxExclusiveValue() {
return fMaxExclusive;
}
-
+
public void setAnonymous(boolean anon) {
fAnonymous = anon;
}
-
- private static final class XSFacetImpl implements XSFacet {
- final short kind;
- final String value;
- final boolean fixed;
- final XSAnnotation annotation;
-
- public XSFacetImpl(short kind, String value, boolean fixed, XSAnnotation annotation) {
- this.kind = kind;
- this.value = value;
- this.fixed = fixed;
- this.annotation = annotation;
- }
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getAnnotation()
- */
- public XSAnnotation getAnnotation() {
- return annotation;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getFacetKind()
- */
- public short getFacetKind() {
- return kind;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getLexicalFacetValue()
- */
- public String getLexicalFacetValue() {
- return value;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSFacet#isFixed()
- */
- public boolean getFixed() {
- return fixed;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getName()
- */
- public String getName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespace()
- */
- public String getNamespace() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getType()
- */
- public short getType() {
- return XSConstants.FACET;
- }
-
- }
-
- private static final class XSMVFacetImpl implements XSMultiValueFacet {
- final short kind;
- XSObjectList annotations;
- StringList values;
-
- public XSMVFacetImpl(short kind, StringList values, XSObjectList annotations) {
- this.kind = kind;
- this.values = values;
- this.annotations = annotations;
- }
-
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getFacetKind()
- */
- public short getFacetKind() {
- return kind;
- }
-
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSMultiValueFacet#getAnnotations()
- */
- public XSObjectList getAnnotations() {
- return annotations;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSMultiValueFacet#getLexicalFacetValues()
- */
- public StringList getLexicalFacetValues() {
- return values;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getName()
- */
- public String getName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespace()
- */
- public String getNamespace() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getType()
- */
- public short getType() {
- return XSConstants.MULTIVALUE_FACET;
- }
- }
+
+ private static final class XSFacetImpl implements XSFacet {
+ final short kind;
+ final String value;
+ final boolean fixed;
+ final XSObjectList annotations;
+
+ public XSFacetImpl(short kind, String value, boolean fixed, XSAnnotation annotation) {
+ this.kind = kind;
+ this.value = value;
+ this.fixed = fixed;
+
+ if (annotation != null) {
+ this.annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)this.annotations).addXSObject(annotation);
+ }
+ else {
+ this.annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getAnnotation()
+ */
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ return (XSAnnotation) annotations.item(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getAnnotations()
+ */
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return annotations;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getFacetKind()
+ */
+ public short getFacetKind() {
+ return kind;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getLexicalFacetValue()
+ */
+ public String getLexicalFacetValue() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#isFixed()
+ */
+ public boolean getFixed() {
+ return fixed;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getName()
+ */
+ public String getName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespace()
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ // REVISIT: implement
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getType()
+ */
+ public short getType() {
+ return XSConstants.FACET;
+ }
+
+ }
+
+ private static final class XSMVFacetImpl implements XSMultiValueFacet {
+ final short kind;
+ final XSObjectList annotations;
+ final StringList values;
+
+ public XSMVFacetImpl(short kind, StringList values, XSObjectList annotations) {
+ this.kind = kind;
+ this.values = values;
+ this.annotations = (annotations != null) ? annotations : XSObjectListImpl.EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSFacet#getFacetKind()
+ */
+ public short getFacetKind() {
+ return kind;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSMultiValueFacet#getAnnotations()
+ */
+ public XSObjectList getAnnotations() {
+ return annotations;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSMultiValueFacet#getLexicalFacetValues()
+ */
+ public StringList getLexicalFacetValues() {
+ return values;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getName()
+ */
+ public String getName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespace()
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ // REVISIT: implement
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.org.apache.xerces.internal.xs.XSObject#getType()
+ */
+ public short getType() {
+ return XSConstants.MULTIVALUE_FACET;
+ }
+ }
+
+ private static abstract class AbstractObjectList extends AbstractList implements ObjectList {
+ public Object get(int index) {
+ if (index >= 0 && index < getLength()) {
+ return item(index);
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+ public int size() {
+ return getLength();
+ }
+ }
public String getTypeNamespace() {
return getNamespace();
@@ -3252,7 +3372,7 @@
public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) {
return isDOMDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod);
}
-
+
private short convertToPrimitiveKind(short valueType) {
/** Primitive datatypes. */
if (valueType <= XSConstants.NOTATION_DT) {
@@ -3269,6 +3389,6 @@
/** Other types. */
return valueType;
}
-
+
} // class XSSimpleTypeDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,220 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.dv.xs;
+
+import com.sun.org.apache.xerces.internal.impl.dv.DatatypeException;
+import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeFacetException;
+import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
+import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
+import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
+import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
+import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.xs.StringList;
+import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
+import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
+
+/**
+ * Base class for XSSimpleType wrapper implementations.
+ *
+ * @xerces.internal
+ *
+ * @version $Id: XSSimpleTypeDelegate.java,v 1.3 2010-11-01 04:39:47 joehw Exp $
+ */
+public class XSSimpleTypeDelegate
+ implements XSSimpleType {
+
+ protected final XSSimpleType type;
+
+ public XSSimpleTypeDelegate(XSSimpleType type) {
+ if (type == null) {
+ throw new NullPointerException();
+ }
+ this.type = type;
+ }
+
+ public XSSimpleType getWrappedXSSimpleType() {
+ return type;
+ }
+
+ public XSObjectList getAnnotations() {
+ return type.getAnnotations();
+ }
+
+ public boolean getBounded() {
+ return type.getBounded();
+ }
+
+ public short getBuiltInKind() {
+ return type.getBuiltInKind();
+ }
+
+ public short getDefinedFacets() {
+ return type.getDefinedFacets();
+ }
+
+ public XSObjectList getFacets() {
+ return type.getFacets();
+ }
+
+ public boolean getFinite() {
+ return type.getFinite();
+ }
+
+ public short getFixedFacets() {
+ return type.getFixedFacets();
+ }
+
+ public XSSimpleTypeDefinition getItemType() {
+ return type.getItemType();
+ }
+
+ public StringList getLexicalEnumeration() {
+ return type.getLexicalEnumeration();
+ }
+
+ public String getLexicalFacetValue(short facetName) {
+ return type.getLexicalFacetValue(facetName);
+ }
+
+ public StringList getLexicalPattern() {
+ return type.getLexicalPattern();
+ }
+
+ public XSObjectList getMemberTypes() {
+ return type.getMemberTypes();
+ }
+
+ public XSObjectList getMultiValueFacets() {
+ return type.getMultiValueFacets();
+ }
+
+ public boolean getNumeric() {
+ return type.getNumeric();
+ }
+
+ public short getOrdered() {
+ return type.getOrdered();
+ }
+
+ public XSSimpleTypeDefinition getPrimitiveType() {
+ return type.getPrimitiveType();
+ }
+
+ public short getVariety() {
+ return type.getVariety();
+ }
+
+ public boolean isDefinedFacet(short facetName) {
+ return type.isDefinedFacet(facetName);
+ }
+
+ public boolean isFixedFacet(short facetName) {
+ return type.isFixedFacet(facetName);
+ }
+
+ public boolean derivedFrom(String namespace, String name, short derivationMethod) {
+ return type.derivedFrom(namespace, name, derivationMethod);
+ }
+
+ public boolean derivedFromType(XSTypeDefinition ancestorType, short derivationMethod) {
+ return type.derivedFromType(ancestorType, derivationMethod);
+ }
+
+ public boolean getAnonymous() {
+ return type.getAnonymous();
+ }
+
+ public XSTypeDefinition getBaseType() {
+ return type.getBaseType();
+ }
+
+ public short getFinal() {
+ return type.getFinal();
+ }
+
+ public short getTypeCategory() {
+ return type.getTypeCategory();
+ }
+
+ public boolean isFinal(short restriction) {
+ return type.isFinal(restriction);
+ }
+
+ public String getName() {
+ return type.getName();
+ }
+
+ public String getNamespace() {
+ return type.getNamespace();
+ }
+
+ public XSNamespaceItem getNamespaceItem() {
+ return type.getNamespaceItem();
+ }
+
+ public short getType() {
+ return type.getType();
+ }
+
+ public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
+ throws InvalidDatatypeFacetException {
+ type.applyFacets(facets, presentFacet, fixedFacet, context);
+ }
+
+ public short getPrimitiveKind() {
+ return type.getPrimitiveKind();
+ }
+
+ public short getWhitespace() throws DatatypeException {
+ return type.getWhitespace();
+ }
+
+ public boolean isEqual(Object value1, Object value2) {
+ return type.isEqual(value1, value2);
+ }
+
+ public boolean isIDType() {
+ return type.isIDType();
+ }
+
+ public void validate(ValidationContext context, ValidatedInfo validatedInfo)
+ throws InvalidDatatypeValueException {
+ type.validate(context, validatedInfo);
+ }
+
+ public Object validate(String content, ValidationContext context, ValidatedInfo validatedInfo)
+ throws InvalidDatatypeValueException {
+ return type.validate(content, context, validatedInfo);
+ }
+
+ public Object validate(Object content, ValidationContext context, ValidatedInfo validatedInfo)
+ throws InvalidDatatypeValueException {
+ return type.validate(content, context, validatedInfo);
+ }
+
+ public String toString() {
+ return type.toString();
+ }
+}
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,11 +29,12 @@
/**
* Validator for <gYear> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: YearDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class YearDV extends AbstractDateTimeDV {
@@ -70,6 +71,15 @@
start = 1;
}
int sign = findUTCSign(str, start, len);
+
+ final int length = ((sign == -1) ? len : sign) - start;
+ if (length < 4) {
+ throw new RuntimeException("Year must have 'CCYY' format");
+ }
+ else if (length > 4 && str.charAt(start) == '0') {
+ throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
+ }
+
if (sign == -1) {
date.year=parseIntYear(str, len);
}
@@ -109,7 +119,11 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(date.unNormYear, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(date.unNormYear, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
}
}
+
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,11 +29,12 @@
/**
* Validator for <gYearMonth> datatype (W3C Schema Datatypes)
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani
* @author Gopal Sharma, SUN Microsystem Inc.
*
+ * @version $Id: YearMonthDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
*/
public class YearMonthDV extends AbstractDateTimeDV{
@@ -92,7 +93,11 @@
}
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
- return factory.newXMLGregorianCalendar(date.unNormYear, date.unNormMonth, DatatypeConstants.FIELD_UNDEFINED
- , DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
+ return datatypeFactory.newXMLGregorianCalendar(date.unNormYear, date.unNormMonth, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED,
+ date.hasTimeZone() ? date.timezoneHr * 60 + date.timezoneMin : DatatypeConstants.FIELD_UNDEFINED);
}
}
+
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java Wed Sep 28 17:36:24 2011 +0100
@@ -30,10 +30,11 @@
/**
* Used to validate the type
*
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Ankit Pasricha, IBM
- *
+ *
+ * @version $Id: YearMonthDurationDV.java,v 1.6 2010-11-01 04:39:47 joehw Exp $
*/
class YearMonthDurationDV extends DurationDV {
@@ -52,7 +53,7 @@
if ( date.year<0 || date.month<0) {
sign = -1;
}
- return factory.newDuration(sign == 1,
+ return datatypeFactory.newDuration(sign == 1,
date.year != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.year):null,
date.month != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.month):null,
null,
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties Wed Sep 28 17:36:24 2011 +0100
@@ -1,6 +1,7 @@
# This file contains error and warning messages related to XML Schema
# The messages are arranged in key and value tuples in a ListResourceBundle.
#
+# @version $Id: XMLSchemaMessages.properties,v 1.7 2010-10-08 19:08:31 joehw Exp $
BadMessageKey = The error message corresponding to the message key can not be found.
FormatFailed = An internal error occurred while formatting the following message:\n
@@ -98,11 +99,13 @@
src-ct.2.1 = src-ct.2.1: Complex Type Definition Representation Error for type ''{0}''. When is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. ''{1}'' satisfies none of these conditions.
src-ct.2.2 = src-ct.2.2: Complex Type Definition Representation Error for type ''{0}''. When a complexType with simpleContent restricts a complexType with mixed content and emptiable particle, then there must be a among the children of .
src-ct.4 = src-ct.4: Complex Type Definition Representation Error for type ''{0}''. The intersection of wildcards is not expressible.
+ src-ct.5 = src-ct.5: Complex Type Definition Representation Error for type ''{0}''. The union of wildcards is not expressible.
src-element.1 = src-element.1: The properties ''default'' and ''fixed'' cannot both be present in element declaration ''{0}''. Use only one of them.
src-element.2.1 = src-element.2.1: : One of 'ref' or 'name' must be present in a local element declaration.
src-element.2.2 = src-element.2.2: Since ''{0}'' contains the ''ref'' attribute, its content must match (annotation?). However, ''{1}'' was found.
src-element.3 = src-element.3: Element ''{0}'' has both a ''type'' attribute and a ''anonymous type'' child. Only one of these is allowed for an element.
src-import.1.1 = src-import.1.1: The namespace attribute ''{0}'' of an element information item must not be the same as the targetNamespace of the schema it exists in.
+ src-import.1.2 = src-import.1.2: If the namespace attribute is not present on an element information item then the enclosing schema must have a targetNamespace.
src-import.2 = src-import.2: The root element of document ''{0}'' has to have the namespace name ''http://www.w3.org/2001/XMLSchema'' and the local name ''schema''.
src-import.3.1 = src-import.3.1: The namespace attribute, ''{0}'', of an element information item must be identical to the targetNamespace attribute, ''{1}'', of the imported document.
src-import.3.2 = src-import.3.2: An element information item that had no namespace attribute was found, so the imported document cannot have a targetNamespace attribute. However, the targetNamespace ''{1}'' was found in the imported document.
@@ -186,11 +189,12 @@
e-props-correct.6 = e-props-correct.6: Circular substitution group detected for element ''{0}''.
fractionDigits-valid-restriction = fractionDigits-valid-restriction: In the definition of {2}, the value ''{0}'' for the facet ''fractionDigits'' is invalid, because it must be <= the value for ''fractionDigits'' which was set to ''{1}'' in one of the ancestor types.
fractionDigits-totalDigits = fractionDigits-totalDigits: In the definition of {2}, the value ''{0}'' for the facet ''fractionDigits'' is invalid, because the value must be <= the value for ''totalDigits'' which is ''{1}''.
- length-minLength-maxLength.a = length-minLength-maxLength.a: It is an error to specify both length and either of minLength or maxLength. However, {0} has length = ''{1}'', minLength = ''{2}'' and maxLength = ''{3}''.
- length-minLength-maxLength.b = length-minLength-maxLength.b: It is an error to specify both length and either of minLength or maxLength. However, {0} has length = ''{1}'' and minLength = ''{2}''.
- length-minLength-maxLength.c = length-minLength-maxLength.c: It is an error to specify both length and either of minLength or maxLength. However, {0} has length = ''{1}'' and maxLength = ''{2}''.
- length-minLength-maxLength.d = length-minLength-maxLength.d: For type {0}, it is an error for the value of length ''{1}'' to be less than the value of minLength ''{2}''.
- length-minLength-maxLength.e = length-minLength-maxLength.e: For type {0}, it is an error for the value of length ''{1}'' to be greater than the value of maxLength ''{2}''.
+ length-minLength-maxLength.1.1 = length-minLength-maxLength.1.1: For type {0}, it is an error for the value of length ''{1}'' to be less than the value of minLength ''{2}''.
+ length-minLength-maxLength.1.2.a = length-minLength-maxLength.1.2.a: For type {0}, it is an error for the base to not have a minLength facet if the current restriction has the minLength facet and the current restriction or base has the length facet.
+ length-minLength-maxLength.1.2.b = length-minLength-maxLength.1.2.b: For type {0}, it is an error for the current minLength ''{1}'' to not equal the base minLength ''{2}''.
+ length-minLength-maxLength.2.1 = length-minLength-maxLength.2.1: For type {0}, it is an error for the value of length ''{1}'' to be greater than the value of maxLength ''{2}''.
+ length-minLength-maxLength.2.2.a = length-minLength-maxLength.2.2.a: For type {0}, it is an error for the base to not have a maxLength facet if the current restriction has the maxLength facet and the current restriction or base has the length facet.
+ length-minLength-maxLength.2.2.b = length-minLength-maxLength.2.2.b: For type {0}, it is an error for the current maxLength ''{1}'' to not equal the base maxLength ''{2}''.
length-valid-restriction = length-valid-restriction: Error for type ''{2}''. The value of length = ''{0}'' must be = the value of that of the base type ''{1}''.
maxExclusive-valid-restriction.1 = maxExclusive-valid-restriction.1: Error for type ''{2}''. The maxExclusive value =''{0}'' must be <= maxExclusive of the base type ''{1}''.
maxExclusive-valid-restriction.2 = maxExclusive-valid-restriction.2: Error for type ''{2}''. The maxExclusive value =''{0}'' must be <= maxInclusive of the base type ''{1}''.
@@ -285,4 +289,3 @@
TargetNamespace.2 = TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of ''{1}''.
UndeclaredEntity = UndeclaredEntity: Entity ''{0}'' is not declared.
UndeclaredPrefix = UndeclaredPrefix: Cannot resolve ''{0}'' as a QName: the prefix ''{1}'' is not declared.
-null
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java Wed Sep 28 17:36:24 2011 +0100
@@ -29,7 +29,7 @@
* @xerces.internal
*
* @author TAMURA Kent <kent@trl.ibm.co.jp>
- * @version $Id: ParserForXMLSchema.java,v 1.7 2010/07/27 05:02:34 joehw Exp $
+ * @version $Id: ParserForXMLSchema.java,v 1.9 2010-11-12 18:09:45 joehw Exp $
*/
class ParserForXMLSchema extends RegexParser {
@@ -497,6 +497,6 @@
+"\uac00\ud7a3";
private static final String DIGITS =
"\u0030\u0039\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF"
- +"\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9"
- +"\u0F20\u0F29";
+ +"\u0B66\u0B6F\u0BE6\u0BF2\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9"
+ +"\u0F20\u0F29\u0F2A\u0F33\u1040\u1049\u1369\u137C\u17E0\u17E9\u1810\u1819\uFF10\uFF19";
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,21 +20,24 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import java.lang.ref.SoftReference;
import java.util.Vector;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
+import com.sun.org.apache.xerces.internal.impl.xs.util.ObjectListImpl;
import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;
import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMap4Types;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
-import com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration;
import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
@@ -55,6 +58,8 @@
import com.sun.org.apache.xerces.internal.xs.XSParticle;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
import com.sun.org.apache.xerces.internal.xs.XSWildcard;
+import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
+import org.xml.sax.SAXException;
/**
* This class is to hold all schema component declaration that are declared
@@ -65,11 +70,12 @@
* useful to distinguish grammar objects from other kinds of object
* when they exist in pools or caches.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
+ * @version $Id: SchemaGrammar.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class SchemaGrammar implements XSGrammar, XSNamespaceItem {
@@ -86,6 +92,21 @@
SymbolHash fGlobalIDConstraintDecls;
SymbolHash fGlobalTypeDecls;
+ // extended global decls: map from schema location + decl name to decl object
+ // key is location,name
+ SymbolHash fGlobalAttrDeclsExt;
+ SymbolHash fGlobalAttrGrpDeclsExt;
+ SymbolHash fGlobalElemDeclsExt;
+ SymbolHash fGlobalGroupDeclsExt;
+ SymbolHash fGlobalNotationDeclsExt;
+ SymbolHash fGlobalIDConstraintDeclsExt;
+ SymbolHash fGlobalTypeDeclsExt;
+
+ // A global map of all global element declarations - used for substitution group computation
+ // (handy when sharing components by reference, since we might end up with duplicate components
+ // that are not added to either of the global element declarations above)
+ SymbolHash fAllGlobalElemDecls;
+
// the XMLGrammarDescription member
XSDDescription fGrammarDescription = null;
@@ -98,8 +119,11 @@
// symbol table for constructing parsers (annotation support)
private SymbolTable fSymbolTable = null;
// parsers for annotation support
- private SAXParser fSAXParser = null;
- private DOMParser fDOMParser = null;
+ private SoftReference fSAXParser = null;
+ private SoftReference fDOMParser = null;
+
+ // is this grammar immutable? (fully constructed and not changeable)
+ private boolean fIsImmutable = false;
//
// Constructors
@@ -113,7 +137,7 @@
*
* @param targetNamespace
* @param grammarDesc the XMLGrammarDescription corresponding to this objec
- * at the least a systemId should always be known.
+ * at the least a systemId should always be known.
* @param symbolTable needed for annotation support
*/
public SchemaGrammar(String targetNamespace, XSDDescription grammarDesc,
@@ -132,6 +156,18 @@
fGlobalNotationDecls = new SymbolHash();
fGlobalIDConstraintDecls = new SymbolHash();
+ // Extended tables
+ fGlobalAttrDeclsExt = new SymbolHash();
+ fGlobalAttrGrpDeclsExt = new SymbolHash();
+ fGlobalElemDeclsExt = new SymbolHash();
+ fGlobalGroupDeclsExt = new SymbolHash();
+ fGlobalNotationDeclsExt = new SymbolHash();
+ fGlobalIDConstraintDeclsExt = new SymbolHash();
+ fGlobalTypeDeclsExt = new SymbolHash();
+
+ // All global elements table
+ fAllGlobalElemDecls = new SymbolHash();
+
// if we are parsing S4S, put built-in types in first
// they might get overwritten by the types from S4S, but that's
// considered what the application wants to do.
@@ -141,6 +177,82 @@
fGlobalTypeDecls = new SymbolHash();
} // (String, XSDDescription)
+ // Clone an existing schema grammar
+ public SchemaGrammar(SchemaGrammar grammar) {
+ fTargetNamespace = grammar.fTargetNamespace;
+ fGrammarDescription = grammar.fGrammarDescription.makeClone();
+ //fGrammarDescription.fContextType |= XSDDescription.CONTEXT_COLLISION; // REVISIT
+ fSymbolTable = grammar.fSymbolTable; // REVISIT
+
+ fGlobalAttrDecls = grammar.fGlobalAttrDecls.makeClone();
+ fGlobalAttrGrpDecls = grammar.fGlobalAttrGrpDecls.makeClone();
+ fGlobalElemDecls = grammar.fGlobalElemDecls.makeClone();
+ fGlobalGroupDecls = grammar.fGlobalGroupDecls.makeClone();
+ fGlobalNotationDecls = grammar.fGlobalNotationDecls.makeClone();
+ fGlobalIDConstraintDecls = grammar.fGlobalIDConstraintDecls.makeClone();
+ fGlobalTypeDecls = grammar.fGlobalTypeDecls.makeClone();
+
+ // Extended tables
+ fGlobalAttrDeclsExt = grammar.fGlobalAttrDeclsExt.makeClone();
+ fGlobalAttrGrpDeclsExt = grammar.fGlobalAttrGrpDeclsExt.makeClone();
+ fGlobalElemDeclsExt = grammar.fGlobalElemDeclsExt.makeClone();
+ fGlobalGroupDeclsExt = grammar.fGlobalGroupDeclsExt.makeClone();
+ fGlobalNotationDeclsExt = grammar.fGlobalNotationDeclsExt.makeClone();
+ fGlobalIDConstraintDeclsExt = grammar.fGlobalIDConstraintDeclsExt.makeClone();
+ fGlobalTypeDeclsExt = grammar.fGlobalTypeDeclsExt.makeClone();
+
+ // All global elements table
+ fAllGlobalElemDecls = grammar.fAllGlobalElemDecls.makeClone();
+
+ // Annotations associated with the "root" schema of this targetNamespace
+ fNumAnnotations = grammar.fNumAnnotations;
+ if (fNumAnnotations > 0) {
+ fAnnotations = new XSAnnotationImpl[grammar.fAnnotations.length];
+ System.arraycopy(grammar.fAnnotations, 0, fAnnotations, 0, fNumAnnotations);
+ }
+
+ // All substitution group information declared in this namespace
+ fSubGroupCount = grammar.fSubGroupCount;
+ if (fSubGroupCount > 0) {
+ fSubGroups = new XSElementDecl[grammar.fSubGroups.length];
+ System.arraycopy(grammar.fSubGroups, 0, fSubGroups, 0, fSubGroupCount);
+ }
+
+ // Array to store complex type decls for constraint checking
+ fCTCount = grammar.fCTCount;
+ if (fCTCount > 0) {
+ fComplexTypeDecls = new XSComplexTypeDecl[grammar.fComplexTypeDecls.length];
+ fCTLocators = new SimpleLocator[grammar.fCTLocators.length];
+ System.arraycopy(grammar.fComplexTypeDecls, 0, fComplexTypeDecls, 0, fCTCount);
+ System.arraycopy(grammar.fCTLocators, 0, fCTLocators, 0, fCTCount);
+ }
+
+ // Groups being redefined by restriction
+ fRGCount = grammar.fRGCount;
+ if (fRGCount > 0) {
+ fRedefinedGroupDecls = new XSGroupDecl[grammar.fRedefinedGroupDecls.length];
+ fRGLocators = new SimpleLocator[grammar.fRGLocators.length];
+ System.arraycopy(grammar.fRedefinedGroupDecls, 0, fRedefinedGroupDecls, 0, fRGCount);
+ System.arraycopy(grammar.fRGLocators, 0, fRGLocators, 0, fRGCount);
+ }
+
+ // List of imported grammars
+ if (grammar.fImported != null) {
+ fImported = new Vector();
+ for (int i=0; i(String, XSDDescription)
+
// number of built-in XSTypes we need to create for base and full
// datatype set
private static final int BASICSET_COUNT = 29;
@@ -152,13 +264,22 @@
// this class makes sure the static, built-in schema grammars
// are immutable.
public static class BuiltinSchemaGrammar extends SchemaGrammar {
+
+ private static final String EXTENDED_SCHEMA_FACTORY_CLASS = "com.sun.org.apache.xerces.internal.impl.dv.xs.ExtendedSchemaDVFactoryImpl";
+
/**
* Special constructor to create the grammars for the schema namespaces
*
* @param grammar
*/
- public BuiltinSchemaGrammar(int grammar) {
- SchemaDVFactory schemaFactory = SchemaDVFactory.getInstance();
+ public BuiltinSchemaGrammar(int grammar, short schemaVersion) {
+ SchemaDVFactory schemaFactory;
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ schemaFactory = SchemaDVFactory.getInstance();
+ }
+ else {
+ schemaFactory = SchemaDVFactory.getInstance(EXTENDED_SCHEMA_FACTORY_CLASS);
+ }
if (grammar == GRAMMAR_XS) {
// target namespace
@@ -177,8 +298,33 @@
fGlobalNotationDecls = new SymbolHash(1);
fGlobalIDConstraintDecls = new SymbolHash(1);
+ // no extended global decls
+ fGlobalAttrDeclsExt = new SymbolHash(1);
+ fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+ fGlobalElemDeclsExt = new SymbolHash(1);
+ fGlobalGroupDeclsExt = new SymbolHash(1);
+ fGlobalNotationDeclsExt = new SymbolHash(1);
+ fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+ fGlobalTypeDeclsExt = new SymbolHash(1);
+
+ // all global element decls table
+ fAllGlobalElemDecls = new SymbolHash(1);
+
// get all built-in types
fGlobalTypeDecls = schemaFactory.getBuiltInTypes();
+
+ // assign the built-in schema grammar as the XSNamespaceItem
+ // for each of the built-in simple type definitions.
+ int length = fGlobalTypeDecls.getLength();
+ XSTypeDefinition [] typeDefinitions = new XSTypeDefinition[length];
+ fGlobalTypeDecls.getValues(typeDefinitions, 0);
+ for (int i = 0; i < length; ++i) {
+ XSTypeDefinition xtd = typeDefinitions[i];
+ if (xtd instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) xtd).setNamespaceItem(this);
+ }
+ }
+
// add anyType
fGlobalTypeDecls.put(fAnyType.getName(), fAnyType);
}
@@ -198,6 +344,18 @@
fGlobalIDConstraintDecls = new SymbolHash(1);
fGlobalTypeDecls = new SymbolHash(1);
+ // no extended global decls
+ fGlobalAttrDeclsExt = new SymbolHash(1);
+ fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+ fGlobalElemDeclsExt = new SymbolHash(1);
+ fGlobalGroupDeclsExt = new SymbolHash(1);
+ fGlobalNotationDeclsExt = new SymbolHash(1);
+ fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+ fGlobalTypeDeclsExt = new SymbolHash(1);
+
+ // no all global element decls
+ fAllGlobalElemDecls = new SymbolHash(1);
+
// 4 attributes, so initialize the size as 4*2 = 8
fGlobalAttrDecls = new SymbolHash(8);
String name = null;
@@ -222,7 +380,10 @@
// xsi:schemaLocation
name = SchemaSymbols.XSI_SCHEMALOCATION;
tns = SchemaSymbols.URI_XSI;
- type = schemaFactory.createTypeList(null, SchemaSymbols.URI_XSI, (short)0, anyURI, null);
+ type = schemaFactory.createTypeList("#AnonType_schemaLocation", SchemaSymbols.URI_XSI, (short)0, anyURI, null);
+ if (type instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl)type).setAnonymous(true);
+ }
fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
// xsi:noNamespaceSchemaLocation
@@ -247,21 +408,54 @@
public void addGlobalAttributeDecl(XSAttributeDecl decl) {
// ignore
}
+ public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
+ // ignore
+ }
public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
// ignore
}
+ public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+ // ignore
+ }
public void addGlobalElementDecl(XSElementDecl decl) {
// ignore
}
+ public void addGlobalElementDecl(XSElementDecl decl, String location) {
+ // ignore
+ }
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ // ignore
+ }
public void addGlobalGroupDecl(XSGroupDecl decl) {
// ignore
}
+ public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+ // ignore
+ }
public void addGlobalNotationDecl(XSNotationDecl decl) {
// ignore
}
+ public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+ // ignore
+ }
public void addGlobalTypeDecl(XSTypeDefinition decl) {
// ignore
}
+ public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+ // ignore
+ }
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
+ // ignore
+ }
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+ // ignore
+ }
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
+ // ignore
+ }
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+ // ignore
+ }
public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
// ignore
}
@@ -291,10 +485,15 @@
public static final class Schema4Annotations extends SchemaGrammar {
/**
+ * Singleton instance.
+ */
+ public static final Schema4Annotations INSTANCE = new Schema4Annotations();
+
+ /**
* Special constructor to create a schema
* capable of validating annotations.
*/
- public Schema4Annotations() {
+ private Schema4Annotations() {
// target namespace
fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
@@ -313,6 +512,18 @@
fGlobalNotationDecls = new SymbolHash(1);
fGlobalIDConstraintDecls = new SymbolHash(1);
+ // no extended global decls
+ fGlobalAttrDeclsExt = new SymbolHash(1);
+ fGlobalAttrGrpDeclsExt = new SymbolHash(1);
+ fGlobalElemDeclsExt = new SymbolHash(6);
+ fGlobalGroupDeclsExt = new SymbolHash(1);
+ fGlobalNotationDeclsExt = new SymbolHash(1);
+ fGlobalIDConstraintDeclsExt = new SymbolHash(1);
+ fGlobalTypeDeclsExt = new SymbolHash(1);
+
+ // all global element declarations
+ fAllGlobalElemDecls = new SymbolHash(6);
+
// get all built-in types
fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls;
@@ -326,6 +537,14 @@
fGlobalElemDecls.put(documentationDecl.fName, documentationDecl);
fGlobalElemDecls.put(appinfoDecl.fName, appinfoDecl);
+ fGlobalElemDeclsExt.put(","+annotationDecl.fName, annotationDecl);
+ fGlobalElemDeclsExt.put(","+documentationDecl.fName, documentationDecl);
+ fGlobalElemDeclsExt.put(","+appinfoDecl.fName, appinfoDecl);
+
+ fAllGlobalElemDecls.put(annotationDecl, annotationDecl);
+ fAllGlobalElemDecls.put(documentationDecl, documentationDecl);
+ fAllGlobalElemDecls.put(appinfoDecl, appinfoDecl);
+
// create complex type declarations for , and
XSComplexTypeDecl annotationType = new XSComplexTypeDecl();
XSComplexTypeDecl documentationType = new XSComplexTypeDecl();
@@ -440,21 +659,54 @@
public void addGlobalAttributeDecl(XSAttributeDecl decl) {
// ignore
}
+ public void addGlobalAttributeDecl(XSAttributeGroupDecl decl, String location) {
+ // ignore
+ }
public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
// ignore
}
+ public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+ // ignore
+ }
public void addGlobalElementDecl(XSElementDecl decl) {
// ignore
}
+ public void addGlobalElementDecl(XSElementDecl decl, String location) {
+ // ignore
+ }
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ // ignore
+ }
public void addGlobalGroupDecl(XSGroupDecl decl) {
// ignore
}
+ public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+ // ignore
+ }
public void addGlobalNotationDecl(XSNotationDecl decl) {
// ignore
}
+ public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+ // ignore
+ }
public void addGlobalTypeDecl(XSTypeDefinition decl) {
// ignore
}
+ public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+ // ignore
+ }
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
+ // ignore
+ }
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+ // ignore
+ }
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
+ // ignore
+ }
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+ // ignore
+ }
public void addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator) {
// ignore
}
@@ -567,6 +819,14 @@
*/
public void addGlobalAttributeDecl(XSAttributeDecl decl) {
fGlobalAttrDecls.put(decl.fName, decl);
+ decl.setNamespaceItem(this);
+ }
+
+ public void addGlobalAttributeDecl(XSAttributeDecl decl, String location) {
+ fGlobalAttrDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
+ }
}
/**
@@ -574,20 +834,41 @@
*/
public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl) {
fGlobalAttrGrpDecls.put(decl.fName, decl);
+ decl.setNamespaceItem(this);
+ }
+
+ public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, String location) {
+ fGlobalAttrGrpDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
+ }
}
/**
* register one global element
*/
+ public void addGlobalElementDeclAll(XSElementDecl decl) {
+ if (fAllGlobalElemDecls.get(decl) == null) {
+ fAllGlobalElemDecls.put(decl, decl);
+ // if there is a substitution group affiliation, store in an array,
+ // for further constraint checking: UPA, PD, EDC
+ if (decl.fSubGroup != null) {
+ if (fSubGroupCount == fSubGroups.length)
+ fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
+ fSubGroups[fSubGroupCount++] = decl;
+ }
+ }
+ }
+
public void addGlobalElementDecl(XSElementDecl decl) {
fGlobalElemDecls.put(decl.fName, decl);
+ decl.setNamespaceItem(this);
+ }
- // if there is a substitution group affiliation, store in an array,
- // for further constraint checking: UPA, PD, EDC
- if (decl.fSubGroup != null) {
- if (fSubGroupCount == fSubGroups.length)
- fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
- fSubGroups[fSubGroupCount++] = decl;
+ public void addGlobalElementDecl(XSElementDecl decl, String location) {
+ fGlobalElemDeclsExt.put(((location != null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
}
}
@@ -596,6 +877,14 @@
*/
public void addGlobalGroupDecl(XSGroupDecl decl) {
fGlobalGroupDecls.put(decl.fName, decl);
+ decl.setNamespaceItem(this);
+ }
+
+ public void addGlobalGroupDecl(XSGroupDecl decl, String location) {
+ fGlobalGroupDeclsExt.put(((location!=null) ? location : "") + "," + decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
+ }
}
/**
@@ -603,6 +892,14 @@
*/
public void addGlobalNotationDecl(XSNotationDecl decl) {
fGlobalNotationDecls.put(decl.fName, decl);
+ decl.setNamespaceItem(this);
+ }
+
+ public void addGlobalNotationDecl(XSNotationDecl decl, String location) {
+ fGlobalNotationDeclsExt.put(((location!=null) ? location : "") + "," +decl.fName, decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
+ }
}
/**
@@ -610,6 +907,56 @@
*/
public void addGlobalTypeDecl(XSTypeDefinition decl) {
fGlobalTypeDecls.put(decl.getName(), decl);
+ if (decl instanceof XSComplexTypeDecl) {
+ ((XSComplexTypeDecl) decl).setNamespaceItem(this);
+ }
+ else if (decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+ }
+ }
+
+ public void addGlobalTypeDecl(XSTypeDefinition decl, String location) {
+ fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null) {
+ if (decl instanceof XSComplexTypeDecl) {
+ ((XSComplexTypeDecl) decl).setNamespaceItem(this);
+ }
+ else if (decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+ }
+ }
+ }
+
+ /**
+ * register one global complex type
+ */
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl) {
+ fGlobalTypeDecls.put(decl.getName(), decl);
+ decl.setNamespaceItem(this);
+ }
+
+ public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl, String location) {
+ fGlobalTypeDeclsExt.put(((location!=null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null) {
+ decl.setNamespaceItem(this);
+ }
+ }
+
+ /**
+ * register one global simple type
+ */
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl) {
+ fGlobalTypeDecls.put(decl.getName(), decl);
+ if (decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+ }
+ }
+
+ public void addGlobalSimpleTypeDecl(XSSimpleType decl, String location) {
+ fGlobalTypeDeclsExt.put(((location != null) ? location : "") + "," + decl.getName(), decl);
+ if (decl.getNamespaceItem() == null && decl instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl) decl).setNamespaceItem(this);
+ }
}
/**
@@ -620,6 +967,10 @@
fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl);
}
+ public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, String location) {
+ fGlobalIDConstraintDeclsExt.put(((location != null) ? location : "") + "," + decl.getIdentityConstraintName(), decl);
+ }
+
/**
* get one global attribute
*/
@@ -627,6 +978,10 @@
return(XSAttributeDecl)fGlobalAttrDecls.get(declName);
}
+ public final XSAttributeDecl getGlobalAttributeDecl(String declName, String location) {
+ return(XSAttributeDecl)fGlobalAttrDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one global attribute group
*/
@@ -634,6 +989,10 @@
return(XSAttributeGroupDecl)fGlobalAttrGrpDecls.get(declName);
}
+ public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(String declName, String location) {
+ return(XSAttributeGroupDecl)fGlobalAttrGrpDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one global element
*/
@@ -641,6 +1000,10 @@
return(XSElementDecl)fGlobalElemDecls.get(declName);
}
+ public final XSElementDecl getGlobalElementDecl(String declName, String location) {
+ return(XSElementDecl)fGlobalElemDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one global group
*/
@@ -648,6 +1011,10 @@
return(XSGroupDecl)fGlobalGroupDecls.get(declName);
}
+ public final XSGroupDecl getGlobalGroupDecl(String declName, String location) {
+ return(XSGroupDecl)fGlobalGroupDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one global notation
*/
@@ -655,6 +1022,10 @@
return(XSNotationDecl)fGlobalNotationDecls.get(declName);
}
+ public final XSNotationDecl getGlobalNotationDecl(String declName, String location) {
+ return(XSNotationDecl)fGlobalNotationDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one global type
*/
@@ -662,6 +1033,10 @@
return(XSTypeDefinition)fGlobalTypeDecls.get(declName);
}
+ public final XSTypeDefinition getGlobalTypeDecl(String declName, String location) {
+ return(XSTypeDefinition)fGlobalTypeDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one identity constraint
*/
@@ -669,6 +1044,10 @@
return(IdentityConstraint)fGlobalIDConstraintDecls.get(declName);
}
+ public final IdentityConstraint getIDConstraintDecl(String declName, String location) {
+ return(IdentityConstraint)fGlobalIDConstraintDeclsExt.get(((location != null) ? location : "") + "," + declName);
+ }
+
/**
* get one identity constraint
*/
@@ -834,7 +1213,7 @@
}
public XSObjectList getAttributeUses() {
- return new XSObjectListImpl(null, 0);
+ return XSObjectListImpl.EMPTY_LIST;
}
public XSAttributeGroupDecl getAttrGrp() {
@@ -877,7 +1256,11 @@
}
public XSObjectList getAnnotations() {
- return null;
+ return XSObjectListImpl.EMPTY_LIST;
+ }
+
+ public XSNamespaceItem getNamespaceItem() {
+ return SG_SchemaNS;
}
}
private static class BuiltinAttrDecl extends XSAttributeDecl {
@@ -898,20 +1281,34 @@
public void reset () {
// also ignore this call.
}
+
public XSAnnotation getAnnotation() {
return null;
}
+
+ public XSNamespaceItem getNamespaceItem() {
+ return SG_XSI;
+ }
+
} // class BuiltinAttrDecl
// the grammars to hold components of the schema namespace
- public final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS);
-
- public final static Schema4Annotations SG_Schema4Annotations = new Schema4Annotations();
+ public final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0);
+ private final static BuiltinSchemaGrammar SG_SchemaNSExtended = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0_EXTENDED);
public final static XSSimpleType fAnySimpleType = (XSSimpleType)SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
// the grammars to hold components of the schema-instance namespace
- public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI);
+ public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI, Constants.SCHEMA_VERSION_1_0);
+
+ public static SchemaGrammar getS4SGrammar(short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ return SG_SchemaNS;
+ }
+ else {
+ return SG_SchemaNSExtended;
+ }
+ }
static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
@@ -962,6 +1359,7 @@
// store a certain kind of components from all namespaces
private XSNamedMap[] fComponents = null;
+ private ObjectList[] fComponentsExt = null;
// store the documents and their locations contributing to this namespace
// REVISIT: use StringList and XSObjectList for there fields.
@@ -977,6 +1375,15 @@
fLocations.addElement(location);
}
+ public synchronized void removeDocument(int index) {
+ if (fDocuments != null &&
+ index >= 0 &&
+ index < fDocuments.size()) {
+ fDocuments.removeElementAt(index);
+ fLocations.removeElementAt(index);
+ }
+ }
+
/**
* [schema namespace]
* @see [schema namespace]
@@ -988,31 +1395,48 @@
// annotation support
synchronized DOMParser getDOMParser() {
- if (fDOMParser != null) return fDOMParser;
+ if (fDOMParser != null) {
+ DOMParser parser = (DOMParser) fDOMParser.get();
+ if (parser != null) {
+ return parser;
+ }
+ }
// REVISIT: when schema handles XML 1.1, will need to
// revisit this (and the practice of not prepending an XML decl to the annotation string
- IntegratedParserConfiguration config = new IntegratedParserConfiguration(fSymbolTable);
+ XML11Configuration config = new XML11Configuration(fSymbolTable);
// note that this should never produce errors or require
// entity resolution, so just a barebones configuration with
// a couple of feature set will do fine
config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false);
- fDOMParser = new DOMParser(config);
- return fDOMParser;
+
+ DOMParser parser = new DOMParser(config);
+ try {
+ parser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.DEFER_NODE_EXPANSION_FEATURE, false);
+ }
+ catch (SAXException exc) {}
+ fDOMParser = new SoftReference(parser);
+ return parser;
}
synchronized SAXParser getSAXParser() {
- if (fSAXParser != null) return fSAXParser;
+ if (fSAXParser != null) {
+ SAXParser parser = (SAXParser) fSAXParser.get();
+ if (parser != null) {
+ return parser;
+ }
+ }
// REVISIT: when schema handles XML 1.1, will need to
// revisit this (and the practice of not prepending an XML decl to the annotation string
- IntegratedParserConfiguration config = new IntegratedParserConfiguration(fSymbolTable);
+ XML11Configuration config = new XML11Configuration(fSymbolTable);
// note that this should never produce errors or require
// entity resolution, so just a barebones configuration with
// a couple of feature set will do fine
config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false);
- fSAXParser = new SAXParser(config);
- return fSAXParser;
+ SAXParser parser = new SAXParser(config);
+ fSAXParser = new SoftReference(parser);
+ return parser;
}
/**
@@ -1077,6 +1501,53 @@
return fComponents[objectType];
}
+ public synchronized ObjectList getComponentsExt(short objectType) {
+ if (objectType <= 0 || objectType > MAX_COMP_IDX ||
+ !GLOBAL_COMP[objectType]) {
+ return ObjectListImpl.EMPTY_LIST;
+ }
+
+ if (fComponentsExt == null)
+ fComponentsExt = new ObjectList[MAX_COMP_IDX+1];
+
+ // get the hashtable for this type of components
+ if (fComponentsExt[objectType] == null) {
+ SymbolHash table = null;
+ switch (objectType) {
+ case XSConstants.TYPE_DEFINITION:
+ case XSTypeDefinition.COMPLEX_TYPE:
+ case XSTypeDefinition.SIMPLE_TYPE:
+ table = fGlobalTypeDeclsExt;
+ break;
+ case XSConstants.ATTRIBUTE_DECLARATION:
+ table = fGlobalAttrDeclsExt;
+ break;
+ case XSConstants.ELEMENT_DECLARATION:
+ table = fGlobalElemDeclsExt;
+ break;
+ case XSConstants.ATTRIBUTE_GROUP:
+ table = fGlobalAttrGrpDeclsExt;
+ break;
+ case XSConstants.MODEL_GROUP_DEFINITION:
+ table = fGlobalGroupDeclsExt;
+ break;
+ case XSConstants.NOTATION_DECLARATION:
+ table = fGlobalNotationDeclsExt;
+ break;
+ }
+
+ Object[] entries = table.getEntries();
+ fComponentsExt[objectType] = new ObjectListImpl(entries, entries.length);
+ }
+
+ return fComponentsExt[objectType];
+ }
+
+ public synchronized void resetComponents() {
+ fComponents = null;
+ fComponentsExt = null;
+ }
+
/**
* Convenience method. Returns a top-level simple or complex type
* definition.
@@ -1182,18 +1653,23 @@
}
/**
- * @see com.sun.org.apache.xerces.internal.xs.XSNamespaceItem#getAnnotations()
+ * @see org.apache.xerces.xs.XSNamespaceItem#getAnnotations()
*/
public XSObjectList getAnnotations() {
+ if (fNumAnnotations == 0) {
+ return XSObjectListImpl.EMPTY_LIST;
+ }
return new XSObjectListImpl(fAnnotations, fNumAnnotations);
}
public void addAnnotation(XSAnnotationImpl annotation) {
- if(annotation == null)
+ if (annotation == null) {
return;
- if(fAnnotations == null) {
+ }
+ if (fAnnotations == null) {
fAnnotations = new XSAnnotationImpl[2];
- } else if(fNumAnnotations == fAnnotations.length) {
+ }
+ else if (fNumAnnotations == fAnnotations.length) {
XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations);
fAnnotations = newArray;
@@ -1201,4 +1677,12 @@
fAnnotations[fNumAnnotations++] = annotation;
}
+ public void setImmutable(boolean isImmutable) {
+ fIsImmutable = isImmutable;
+ }
+
+ public boolean isImmutable() {
+ return fIsImmutable;
+ }
+
} // class SchemaGrammar
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java Wed Sep 28 17:36:24 2011 +0100
@@ -39,7 +39,10 @@
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+import com.sun.org.apache.xerces.internal.impl.dv.DVFactoryException;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
+import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
+import com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl;
import com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder;
import com.sun.org.apache.xerces.internal.impl.xs.models.CMNodeFactory;
import com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler;
@@ -89,7 +92,7 @@
* @xerces.internal
*
* @author Neil Graham, IBM
- * @version $Id: XMLSchemaLoader.java,v 1.8 2010/07/23 02:09:29 joehw Exp $
+ * @version $Id: XMLSchemaLoader.java,v 1.10 2010-11-01 04:39:55 joehw Exp $
*/
public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent,
@@ -134,8 +137,20 @@
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;
protected static final String PARSER_SETTINGS =
- Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
-
+ Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
+
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
+ /** Property identifier: Schema DV Factory */
+ protected static final String SCHEMA_DV_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
+
// recognized features:
private static final String[] RECOGNIZED_FEATURES = {
SCHEMA_FULL_CHECKING,
@@ -146,7 +161,9 @@
DISALLOW_DOCTYPE,
GENERATE_SYNTHETIC_ANNOTATIONS,
VALIDATE_ANNOTATIONS,
- HONOUR_ALL_SCHEMALOCATIONS
+ HONOUR_ALL_SCHEMALOCATIONS,
+ NAMESPACE_GROWTH,
+ TOLERATE_DUPLICATES
};
// property identifiers
@@ -205,7 +222,8 @@
SCHEMA_NONS_LOCATION,
JAXP_SCHEMA_SOURCE,
SECURITY_MANAGER,
- LOCALE
+ LOCALE,
+ SCHEMA_DV_FACTORY
};
// Data
@@ -957,6 +975,18 @@
// get the error reporter
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
+
+ // Determine schema dv factory to use
+ SchemaDVFactory dvFactory = null;
+ try {
+ dvFactory = (SchemaDVFactory)componentManager.getProperty(SCHEMA_DV_FACTORY);
+ } catch (XMLConfigurationException e) {
+ }
+ if (dvFactory == null) {
+ dvFactory = SchemaDVFactory.getInstance();
+ }
+ fSchemaHandler.setDVFactory(dvFactory);
+
boolean psvi = true;
try {
@@ -969,6 +999,10 @@
fDeclPool.reset();
fCMBuilder.setDeclPool(fDeclPool);
fSchemaHandler.setDeclPool(fDeclPool);
+ if (dvFactory instanceof SchemaDVFactoryImpl) {
+ fDeclPool.setDVFactory((SchemaDVFactoryImpl)dvFactory);
+ ((SchemaDVFactoryImpl)dvFactory).setDeclPool(fDeclPool);
+ }
} else {
fCMBuilder.setDeclPool(null);
fSchemaHandler.setDeclPool(null);
@@ -1066,9 +1100,6 @@
*/
public XSModel loadInputList(LSInputList is) {
int length = is.getLength();
- if (length == 0) {
- return null;
- }
SchemaGrammar[] gs = new SchemaGrammar[length];
for (int i = 0; i < length; i++) {
try {
@@ -1100,9 +1131,6 @@
*/
public XSModel loadURIList(StringList uriList) {
int length = uriList.getLength();
- if (length == 0) {
- return null;
- }
SchemaGrammar[] gs = new SchemaGrammar[length];
for (int i = 0; i < length; i++) {
try {
@@ -1138,7 +1166,9 @@
name.equals(ALLOW_JAVA_ENCODINGS) ||
name.equals(STANDARD_URI_CONFORMANT_FEATURE) ||
name.equals(GENERATE_SYNTHETIC_ANNOTATIONS) ||
- name.equals(HONOUR_ALL_SCHEMALOCATIONS)) {
+ name.equals(HONOUR_ALL_SCHEMALOCATIONS) ||
+ name.equals(NAMESPACE_GROWTH) ||
+ name.equals(TOLERATE_DUPLICATES)) {
return true;
}
@@ -1153,7 +1183,8 @@
name.equals(XMLGRAMMAR_POOL) ||
name.equals(SCHEMA_LOCATION) ||
name.equals(SCHEMA_NONS_LOCATION) ||
- name.equals(JAXP_SCHEMA_SOURCE)) {
+ name.equals(JAXP_SCHEMA_SOURCE) ||
+ name.equals(SCHEMA_DV_FACTORY)) {
return true;
}
return false;
@@ -1214,6 +1245,8 @@
v.add(VALIDATE_ANNOTATIONS);
v.add(GENERATE_SYNTHETIC_ANNOTATIONS);
v.add(HONOUR_ALL_SCHEMALOCATIONS);
+ v.add(NAMESPACE_GROWTH);
+ v.add(TOLERATE_DUPLICATES);
fRecognizedParameters = new DOMStringListImpl(v);
}
return fRecognizedParameters;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,15 +21,18 @@
package com.sun.org.apache.xerces.internal.impl.xs;
import java.io.IOException;
-import java.util.Enumeration;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Stack;
import java.util.Vector;
import java.util.ArrayList;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.RevalidationHandler;
+import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
import com.sun.org.apache.xerces.internal.impl.dv.DatatypeException;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
@@ -54,6 +57,7 @@
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
@@ -75,6 +79,7 @@
import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
import com.sun.org.apache.xerces.internal.xs.ShortList;
+import com.sun.org.apache.xerces.internal.xs.StringList;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
@@ -104,7 +109,7 @@
* @author Elena Litani IBM
* @author Andy Clark IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
- * @version $Id: XMLSchemaValidator.java,v 1.14 2010/08/10 00:17:49 joehw Exp $
+ * @version $Id: XMLSchemaValidator.java,v 1.16 2010-11-01 04:39:55 joehw Exp $
*/
public class XMLSchemaValidator
implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler {
@@ -174,7 +179,15 @@
protected static final String PARSER_SETTINGS =
Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
-
+
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
protected static final String REPORT_WHITESPACE =
Constants.SUN_SCHEMA_FEATURE_PREFIX + Constants.SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE;
@@ -218,6 +231,10 @@
protected static final String JAXP_SCHEMA_LANGUAGE =
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;
+ /** Property identifier: Schema DV Factory */
+ protected static final String SCHEMA_DV_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -233,7 +250,10 @@
GENERATE_SYNTHETIC_ANNOTATIONS,
VALIDATE_ANNOTATIONS,
HONOUR_ALL_SCHEMALOCATIONS,
- USE_GRAMMAR_POOL_ONLY};
+ USE_GRAMMAR_POOL_ONLY,
+ NAMESPACE_GROWTH,
+ TOLERATE_DUPLICATES
+ };
/** Feature defaults. */
private static final Boolean[] FEATURE_DEFAULTS = { null,
@@ -252,7 +272,10 @@
null,
null,
null,
- null};
+ null,
+ null,
+ null
+ };
/** Recognized properties. */
private static final String[] RECOGNIZED_PROPERTIES =
@@ -265,11 +288,12 @@
SCHEMA_NONS_LOCATION,
JAXP_SCHEMA_SOURCE,
JAXP_SCHEMA_LANGUAGE,
+ SCHEMA_DV_FACTORY,
};
/** Property defaults. */
private static final Object[] PROPERTY_DEFAULTS =
- { null, null, null, null, null, null, null, null, };
+ { null, null, null, null, null, null, null, null, null, null, null};
// this is the number of valuestores of each kind
// we expect an element to have. It's almost
@@ -277,6 +301,9 @@
protected static final int ID_CONSTRAINT_NUM = 1;
//
+ private static final Hashtable EMPTY_TABLE = new Hashtable();
+
+ //
// Data
//
@@ -310,6 +337,9 @@
protected boolean fIdConstraint = false;
protected boolean fUseGrammarPoolOnly = false;
+ // Namespace growth feature
+ protected boolean fNamespaceGrowth = false;
+
/** Schema type: None, DTD, Schema */
private String fSchemaType = null;
@@ -459,6 +489,8 @@
/** Schema Grammar Description passed, to give a chance to application to supply the Grammar */
protected final XSDDescription fXSDDescription = new XSDDescription();
protected final Hashtable fLocationPairs = new Hashtable();
+ protected final Hashtable fExpandedLocationPairs = new Hashtable();
+ protected final ArrayList fUnparsedLocations = new ArrayList();
// handlers
@@ -1261,6 +1293,7 @@
fIdConstraint = false;
//reset XSDDescription
fLocationPairs.clear();
+ fExpandedLocationPairs.clear();
// cleanup id table
fValidationState.resetIDTables();
@@ -1324,6 +1357,12 @@
}
try {
+ fNamespaceGrowth = componentManager.getFeature(NAMESPACE_GROWTH);
+ } catch (XMLConfigurationException e) {
+ fNamespaceGrowth = false;
+ }
+
+ try {
fDynamicValidation = componentManager.getFeature(DYNAMIC_VALIDATION);
} catch (XMLConfigurationException e) {
fDynamicValidation = false;
@@ -2235,6 +2274,10 @@
grammars = fGrammarBucket.getGrammars();
// return the final set of grammars validator ended up with
if (fGrammarPool != null) {
+ // Set grammars as immutable
+ for (int k=0; k < grammars.length; k++) {
+ grammars[k].setImmutable(true);
+ }
fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, grammars);
}
augs = endElementPSVI(true, grammars, augs);
@@ -2391,34 +2434,16 @@
SchemaGrammar grammar = null;
//get the grammar from local pool...
grammar = fGrammarBucket.getGrammar(namespace);
+
if (grammar == null) {
- fXSDDescription.reset();
- fXSDDescription.fContextType = contextType;
fXSDDescription.setNamespace(namespace);
- fXSDDescription.fEnclosedElementName = enclosingElement;
- fXSDDescription.fTriggeringComponent = triggeringComponet;
- fXSDDescription.fAttributes = attributes;
- if (fLocator != null) {
- fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
- }
-
- String[] temp = null;
- Object locationArray =
- fLocationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
- if (locationArray != null)
- temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
- if (temp != null && temp.length != 0) {
- fXSDDescription.fLocationHints = new String[temp.length];
- System.arraycopy(temp, 0, fXSDDescription.fLocationHints, 0, temp.length);
- }
-
// give a chance to application to be able to retreive the grammar.
if (fGrammarPool != null) {
grammar = (SchemaGrammar) fGrammarPool.retrieveGrammar(fXSDDescription);
if (grammar != null) {
// put this grammar into the bucket, along with grammars
// imported by it (directly or indirectly)
- if (!fGrammarBucket.putGrammar(grammar, true)) {
+ if (!fGrammarBucket.putGrammar(grammar, true, fNamespaceGrowth)) {
// REVISIT: a conflict between new grammar(s) and grammars
// in the bucket. What to do? A warning? An exception?
fXSIErrorReporter.fErrorReporter.reportError(
@@ -2430,15 +2455,56 @@
}
}
}
- if (grammar == null && !fUseGrammarPoolOnly) {
+ }
+ if ((grammar == null && !fUseGrammarPoolOnly) || fNamespaceGrowth) {
+ fXSDDescription.reset();
+ fXSDDescription.fContextType = contextType;
+ fXSDDescription.setNamespace(namespace);
+ fXSDDescription.fEnclosedElementName = enclosingElement;
+ fXSDDescription.fTriggeringComponent = triggeringComponet;
+ fXSDDescription.fAttributes = attributes;
+ if (fLocator != null) {
+ fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
+ }
+
+ Hashtable locationPairs = fLocationPairs;
+ Object locationArray =
+ locationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
+ if (locationArray != null) {
+ String[] temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
+ if (temp.length != 0) {
+ setLocationHints(fXSDDescription, temp, grammar);
+ }
+ }
+
+ if (grammar == null || fXSDDescription.fLocationHints != null) {
+ boolean toParseSchema = true;
+ if (grammar != null) {
+ // use location hints instead
+ locationPairs = EMPTY_TABLE;
+ }
+
// try to parse the grammar using location hints from that namespace..
try {
XMLInputSource xis =
XMLSchemaLoader.resolveDocument(
fXSDDescription,
- fLocationPairs,
+ locationPairs,
fEntityResolver);
- grammar = fSchemaLoader.loadSchema(fXSDDescription, xis, fLocationPairs);
+ if (grammar != null && fNamespaceGrowth) {
+ try {
+ // if we are dealing with a different schema location, then include the new schema
+ // into the existing grammar
+ if (grammar.getDocumentLocations().contains(XMLEntityManager.expandSystemId(xis.getSystemId(), xis.getBaseSystemId(), false))) {
+ toParseSchema = false;
+ }
+ }
+ catch (MalformedURIException e) {
+ }
+ }
+ if (toParseSchema) {
+ grammar = fSchemaLoader.loadSchema(fXSDDescription, xis, fLocationPairs);
+ }
} catch (IOException ex) {
final String [] locationHints = fXSDDescription.getLocationHints();
fXSIErrorReporter.fErrorReporter.reportError(
@@ -2453,6 +2519,44 @@
return grammar;
} //findSchemaGrammar
+ private void setLocationHints(XSDDescription desc, String[] locations, SchemaGrammar grammar) {
+ int length = locations.length;
+ if (grammar == null) {
+ fXSDDescription.fLocationHints = new String[length];
+ System.arraycopy(locations, 0, fXSDDescription.fLocationHints, 0, length);
+ }
+ else {
+ setLocationHints(desc, locations, grammar.getDocumentLocations());
+ }
+ }
+
+ private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
+ int length = locations.length;
+ String[] hints = new String[length];
+ int counter = 0;
+
+ for (int i=0; i 0) {
+ if (counter == length) {
+ fXSDDescription.fLocationHints = hints;
+ }
+ else {
+ fXSDDescription.fLocationHints = new String[counter];
+ System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
+ }
+ }
+ }
+
XSTypeDefinition getAndCheckXsiType(QName element, String xsiType, XMLAttributes attributes) {
// This method also deals with clause 1.2.1.2 of the constraint
@@ -2531,7 +2635,7 @@
// 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
// 3.2.2 There must be no fixed {value constraint}.
else {
- String value = xsiNil.trim();
+ String value = XMLChar.trim(xsiNil);
if (value.equals(SchemaSymbols.ATTVAL_TRUE)
|| value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
if (fCurrentElemDecl != null
@@ -3999,21 +4103,25 @@
* top of fGlobalMapStack into fGlobalIDConstraintMap.
*/
public void endElement() {
- if (fGlobalMapStack.isEmpty())
+ if (fGlobalMapStack.isEmpty()) {
return; // must be an invalid doc!
+ }
Hashtable oldMap = (Hashtable) fGlobalMapStack.pop();
// return if there is no element
- if (oldMap == null)
+ if (oldMap == null) {
return;
-
- Enumeration keys = oldMap.keys();
- while (keys.hasMoreElements()) {
- IdentityConstraint id = (IdentityConstraint) keys.nextElement();
- ValueStoreBase oldVal = (ValueStoreBase) oldMap.get(id);
+ }
+
+ Iterator entries = oldMap.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ IdentityConstraint id = (IdentityConstraint) entry.getKey();
+ ValueStoreBase oldVal = (ValueStoreBase) entry.getValue();
if (oldVal != null) {
ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
- if (currVal == null)
+ if (currVal == null) {
fGlobalIDConstraintMap.put(id, oldVal);
+ }
else if (currVal != oldVal) {
currVal.append(oldVal);
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAnnotationImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAnnotationImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAnnotationImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -19,25 +19,26 @@
*/
package com.sun.org.apache.xerces.internal.impl.xs;
+import java.io.IOException;
+import java.io.StringReader;
+
+import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
+import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
-import com.sun.org.apache.xerces.internal.parsers.SAXParser;
-import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
-import org.w3c.dom.Node;
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
-import java.io.StringReader;
-import java.io.IOException;
-
+import org.xml.sax.SAXException;
/**
* This is an implementation of the XSAnnotation schema component.
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*/
public class XSAnnotationImpl implements XSAnnotation {
@@ -134,34 +135,52 @@
parser.setContentHandler(handler);
try {
parser.parse(aSource);
- } catch (SAXException e) {
+ }
+ catch (SAXException e) {
// this should never happen!
// REVISIT: what to do with this?; should really not
// eat it...
- } catch (IOException i) {
+ }
+ catch (IOException i) {
// ditto with above
}
+ // Release the reference to the user's ContentHandler.
+ parser.setContentHandler(null);
}
// this creates the new Annotation element as the first child
// of the Node
- private synchronized void writeToDOM(Node target, short type){
- Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT)?target.getOwnerDocument():(Document)target;
+ private synchronized void writeToDOM(Node target, short type) {
+ Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
+ target.getOwnerDocument() : (Document)target;
DOMParser parser = fGrammar.getDOMParser();
StringReader aReader = new StringReader(fData);
InputSource aSource = new InputSource(aReader);
try {
parser.parse(aSource);
- } catch (SAXException e) {
+ }
+ catch (SAXException e) {
// this should never happen!
// REVISIT: what to do with this?; should really not
// eat it...
- } catch (IOException i) {
+ }
+ catch (IOException i) {
// ditto with above
}
Document aDocument = parser.getDocument();
+ parser.dropDocumentReferences();
Element annotation = aDocument.getDocumentElement();
- Node newElem = futureOwner.importNode(annotation, true);
+ Node newElem = null;
+ if (futureOwner instanceof CoreDocumentImpl) {
+ newElem = futureOwner.adoptNode(annotation);
+ // adoptNode will return null when the DOM implementations are not compatible.
+ if (newElem == null) {
+ newElem = futureOwner.importNode(annotation, true);
+ }
+ }
+ else {
+ newElem = futureOwner.importNode(annotation, true);
+ }
target.insertBefore(newElem, target.getFirstChild());
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,18 +20,28 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
-import com.sun.org.apache.xerces.internal.xs.*;
-import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xs.ShortList;
+import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
+import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
+import com.sun.org.apache.xerces.internal.xs.XSComplexTypeDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
+import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
/**
* The XML representation for an attribute declaration
* schema component is an element information item
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
+ * @version $Id: XSAttributeDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSAttributeDecl implements XSAttributeDeclaration {
@@ -46,21 +56,25 @@
String fTargetNamespace = null;
// the simple type of the attribute
XSSimpleType fType = null;
+ public QName fUnresolvedTypeName = null;
// value constraint type: default, fixed or !specified
short fConstraintType = XSConstants.VC_NONE;
// scope
short fScope = XSConstants.SCOPE_ABSENT;
// enclosing complex type, when the scope is local
XSComplexTypeDecl fEnclosingCT = null;
- // optional annotation
- XSAnnotationImpl fAnnotation = null;
+ // optional annotations
+ XSObjectList fAnnotations = null;
// value constraint value
ValidatedInfo fDefault = null;
+ // The namespace schema information item corresponding to the target namespace
+ // of the attribute declaration, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
public void setValues(String name, String targetNamespace,
XSSimpleType simpleType, short constraintType, short scope,
ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT,
- XSAnnotationImpl annotation) {
+ XSObjectList annotations) {
fName = name;
fTargetNamespace = targetNamespace;
fType = simpleType;
@@ -68,17 +82,18 @@
fScope = scope;
fDefault = valInfo;
fEnclosingCT = enclosingCT;
- fAnnotation = annotation;
+ fAnnotations = annotations;
}
public void reset(){
fName = null;
fTargetNamespace = null;
fType = null;
+ fUnresolvedTypeName = null;
fConstraintType = XSConstants.VC_NONE;
fScope = XSConstants.SCOPE_ABSENT;
fDefault = null;
- fAnnotation = null;
+ fAnnotations = null;
}
/**
@@ -154,18 +169,29 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
+ }
+
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
public ValidatedInfo getValInfo() {
return fDefault;
}
+
/**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
*/
public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
+ return fNamespaceItem;
+ }
+
+ void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
}
public Object getActualVC() {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,6 +21,7 @@
package com.sun.org.apache.xerces.internal.impl.xs;
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
import com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition;
import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
@@ -28,17 +29,17 @@
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSWildcard;
-import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
/**
* The XML representation for an attribute group declaration
* schema component is a global element information item
- *
- * @xerces.internal
+ *
+ * @xerces.internal
*
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
+ * @version $Id: XSAttributeGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSAttributeGroupDecl implements XSAttributeGroupDefinition {
@@ -57,36 +58,50 @@
public String fIDAttrName = null;
// optional annotation
- public XSAnnotationImpl fAnnotation;
+ public XSObjectList fAnnotations;
protected XSObjectListImpl fAttrUses = null;
+ // The namespace schema information item corresponding to the target namespace
+ // of the attribute group definition, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
+
// add an attribute use
// if the type is derived from ID, but there is already another attribute
// use of type ID, then return the name of the other attribute use;
// otherwise, return null
public String addAttributeUse(XSAttributeUseImpl attrUse) {
+ // if this attribute use is prohibited, then don't check whether it's
+ // of type ID
+ if (attrUse.fUse != SchemaSymbols.USE_PROHIBITED) {
+ if (attrUse.fAttrDecl.fType.isIDType()) {
+ // if there is already an attribute use of type ID,
+ // return its name (and don't add it to the list, to avoid
+ // interruption to instance validation.
+ if (fIDAttrName == null)
+ fIDAttrName = attrUse.fAttrDecl.fName;
+ else
+ return fIDAttrName;
+ }
+ }
+
if (fAttrUseNum == fAttributeUses.length) {
fAttributeUses = resize(fAttributeUses, fAttrUseNum*2);
}
fAttributeUses[fAttrUseNum++] = attrUse;
- // if this attribute use is prohibited, then don't check whether it's
- // of type ID
- if (attrUse.fUse == SchemaSymbols.USE_PROHIBITED)
- return null;
-
- if (attrUse.fAttrDecl.fType.isIDType()) {
- // if there is already an attribute use of type ID, return it' sname
- if (fIDAttrName == null)
- fIDAttrName = attrUse.fAttrDecl.fName;
- else
- return fIDAttrName;
- }
return null;
}
+ public void replaceAttributeUse(XSAttributeUse oldUse, XSAttributeUseImpl newUse) {
+ for (int i=0; i 0) {
- OUTER: for (int i = 0; i < fAttrUseNum; i++) {
- if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED)
- continue;
- for (int j = 1; j <= pCount; j++) {
- if (fAttributeUses[i].fAttrDecl.fName == pUses[fAttrUseNum-pCount].fAttrDecl.fName &&
- fAttributeUses[i].fAttrDecl.fTargetNamespace == pUses[fAttrUseNum-pCount].fAttrDecl.fTargetNamespace) {
- continue OUTER;
- }
- }
- pUses[newCount++] = fAttributeUses[i];
+ return null;
+ }
+
+ public void removeProhibitedAttrs() {
+ if (fAttrUseNum == 0) return;
+ // Remove all prohibited attributes.
+ int count = 0;
+ XSAttributeUseImpl[] uses = new XSAttributeUseImpl[fAttrUseNum];
+ for (int i = 0; i < fAttrUseNum; i++) {
+ if (fAttributeUses[i].fUse != SchemaSymbols.USE_PROHIBITED) {
+ uses[count++] = fAttributeUses[i];
}
- fAttributeUses = pUses;
- fAttrUseNum = newCount;
}
+ fAttributeUses = uses;
+ fAttrUseNum = count;
+
+ // Do not remove attributes that have the same name as the prohibited
+ // ones, because they are specified at the same level. Prohibited
+ // attributes are only to remove attributes from the base type in a
+ // restriction.
+// int newCount = 0;
+// if (pCount > 0) {
+// OUTER: for (int i = 0; i < fAttrUseNum; i++) {
+// if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED)
+// continue;
+// for (int j = 1; j <= pCount; j++) {
+// if (fAttributeUses[i].fAttrDecl.fName == pUses[fAttrUseNum-pCount].fAttrDecl.fName &&
+// fAttributeUses[i].fAttrDecl.fTargetNamespace == pUses[fAttrUseNum-pCount].fAttrDecl.fTargetNamespace) {
+// continue OUTER;
+// }
+// }
+// pUses[newCount++] = fAttributeUses[i];
+// }
+// fAttributeUses = pUses;
+// fAttrUseNum = newCount;
+// }
}
/**
@@ -162,7 +191,7 @@
if (baseAttrUse.getRequired() && !attrUse.getRequired()) {
errorArgs = new Object[]{typeName, attrDecl.fName,
- attrUse.fUse == SchemaSymbols.USE_OPTIONAL ? SchemaSymbols.ATTVAL_OPTIONAL : SchemaSymbols.ATTVAL_PROHIBITED,
+ attrUse.fUse == SchemaSymbols.USE_OPTIONAL ? SchemaSymbols.ATTVAL_OPTIONAL : SchemaSymbols.ATTVAL_PROHIBITED,
"derivation-ok-restriction.2.1.1"};
return errorArgs;
}
@@ -180,9 +209,9 @@
if (! XSConstraints.checkSimpleDerivationOk(attrDecl.fType,
baseAttrDecl.fType,
baseAttrDecl.fType.getFinal()) ) {
- errorArgs = new Object[]{typeName, attrDecl.fName, attrDecl.fType.getName(),
- baseAttrDecl.fType.getName(), "derivation-ok-restriction.2.1.2"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, attrDecl.fName, attrDecl.fType.getName(),
+ baseAttrDecl.fType.getName(), "derivation-ok-restriction.2.1.2"};
+ return errorArgs;
}
@@ -197,9 +226,9 @@
if (baseConsType == XSConstants.VC_FIXED) {
if (thisConstType != XSConstants.VC_FIXED) {
- errorArgs = new Object[]{typeName, attrDecl.fName,
- "derivation-ok-restriction.2.1.3.a"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, attrDecl.fName,
+ "derivation-ok-restriction.2.1.3.a"};
+ return errorArgs;
} else {
// check the values are the same.
ValidatedInfo baseFixedValue=(baseAttrUse.fDefault!=null ?
@@ -207,9 +236,9 @@
ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ?
attrUse.fDefault: attrDecl.fDefault);
if (!baseFixedValue.actualValue.equals(thisFixedValue.actualValue)) {
- errorArgs = new Object[]{typeName, attrDecl.fName, thisFixedValue.stringValue(),
- baseFixedValue.stringValue(), "derivation-ok-restriction.2.1.3.b"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, attrDecl.fName, thisFixedValue.stringValue(),
+ baseFixedValue.stringValue(), "derivation-ok-restriction.2.1.3.b"};
+ return errorArgs;
}
}
@@ -222,15 +251,15 @@
// derivation-ok-restriction. Constraint 2.2
//
if (baseGroup.fAttributeWC == null) {
- errorArgs = new Object[]{typeName, attrDecl.fName,
- "derivation-ok-restriction.2.2.a"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, attrDecl.fName,
+ "derivation-ok-restriction.2.2.a"};
+ return errorArgs;
}
else if (!baseGroup.fAttributeWC.allowNamespace(attrDecl.fTargetNamespace)) {
- errorArgs = new Object[]{typeName, attrDecl.fName,
+ errorArgs = new Object[]{typeName, attrDecl.fName,
attrDecl.fTargetNamespace==null?"":attrDecl.fTargetNamespace,
- "derivation-ok-restriction.2.2.b"};
- return errorArgs;
+ "derivation-ok-restriction.2.2.b"};
+ return errorArgs;
}
}
}
@@ -249,9 +278,9 @@
baseAttrDecl = baseAttrUse.fAttrDecl;
// Look for a match in this group
if (getAttributeUse(baseAttrDecl.fTargetNamespace,baseAttrDecl.fName) == null) {
- errorArgs = new Object[]{typeName, baseAttrUse.fAttrDecl.fName,
- "derivation-ok-restriction.3"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, baseAttrUse.fAttrDecl.fName,
+ "derivation-ok-restriction.3"};
+ return errorArgs;
}
}
}
@@ -263,19 +292,19 @@
//
if (fAttributeWC != null) {
if (baseGroup.fAttributeWC == null) {
- errorArgs = new Object[]{typeName, "derivation-ok-restriction.4.1"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, "derivation-ok-restriction.4.1"};
+ return errorArgs;
}
if (! fAttributeWC.isSubsetOf(baseGroup.fAttributeWC)) {
- errorArgs = new Object[]{typeName, "derivation-ok-restriction.4.2"};
- return errorArgs;
+ errorArgs = new Object[]{typeName, "derivation-ok-restriction.4.2"};
+ return errorArgs;
}
if (fAttributeWC.weakerProcessContents(baseGroup.fAttributeWC)) {
- errorArgs = new Object[]{typeName,
- fAttributeWC.getProcessContentsAsString(),
- baseGroup.fAttributeWC.getProcessContentsAsString(),
- "derivation-ok-restriction.4.3"};
- return errorArgs;
+ errorArgs = new Object[]{typeName,
+ fAttributeWC.getProcessContentsAsString(),
+ baseGroup.fAttributeWC.getProcessContentsAsString(),
+ "derivation-ok-restriction.4.3"};
+ return errorArgs;
}
}
@@ -299,7 +328,7 @@
}
fAttrUseNum = 0;
fAttributeWC = null;
- fAnnotation = null;
+ fAnnotations = null;
fIDAttrName = null;
}
@@ -349,15 +378,25 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
+ }
+
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- //REVISIT: implement
- return null;
- }
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return fNamespaceItem;
+ }
+
+ void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
+ }
} // class XSAttributeGroupDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,19 +21,22 @@
package com.sun.org.apache.xerces.internal.impl.xs;
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.xs.ShortList;
import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* The XML representation for an attribute use
* schema component is a local element information item
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
+ * @version $Id: XSAttributeUseImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSAttributeUseImpl implements XSAttributeUse {
@@ -45,12 +48,15 @@
public short fConstraintType = XSConstants.VC_NONE;
// value constraint value
public ValidatedInfo fDefault = null;
+ // optional annotation
+ public XSObjectList fAnnotations = null;
public void reset(){
fDefault = null;
fAttrDecl = null;
fUse = SchemaSymbols.USE_OPTIONAL;
fConstraintType = XSConstants.VC_NONE;
+ fAnnotations = null;
}
/**
@@ -109,12 +115,11 @@
// REVISIT: SCAPI: what's the proper representation
return getConstraintType() == XSConstants.VC_NONE ?
null :
- ((fDefault != null && fDefault.actualValue != null) ?
- fDefault.actualValue.toString() : null);
+ fDefault.stringValue();
}
/**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
*/
public XSNamespaceItem getNamespaceItem() {
return null;
@@ -138,4 +143,11 @@
fDefault.itemValueTypes;
}
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
+ }
+
} // class XSAttributeUseImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -36,7 +36,7 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSComplexTypeDecl.java,v 1.6 2010/04/23 01:42:43 joehw Exp $
+ * @version $Id: XSComplexTypeDecl.java,v 1.8 2010-11-01 04:39:55 joehw Exp $
*/
public class XSComplexTypeDecl implements XSComplexTypeDefinition, TypeInfo {
@@ -77,24 +77,31 @@
// if there is a particle, the content model corresponding to that particle
volatile XSCMValidator fCMValidator = null;
+ // the content model that's sufficient for computing UPA
+ XSCMValidator fUPACMValidator = null;
+
// list of annotations affiliated with this type
XSObjectListImpl fAnnotations = null;
+ // The namespace schema information item corresponding to the target namespace
+ // of the complex type definition, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
+
// DOM Level 3 TypeInfo Derivation Method constants
static final int DERIVATION_ANY = 0;
static final int DERIVATION_RESTRICTION = 1;
static final int DERIVATION_EXTENSION = 2;
static final int DERIVATION_UNION = 4;
static final int DERIVATION_LIST = 8;
-
+
public XSComplexTypeDecl() {
// do-nothing constructor for now.
}
public void setValues(String name, String targetNamespace,
- XSTypeDefinition baseType, short derivedBy, short schemaFinal,
+ XSTypeDefinition baseType, short derivedBy, short schemaFinal,
short block, short contentType,
- boolean isAbstract, XSAttributeGroupDecl attrGrp,
+ boolean isAbstract, XSAttributeGroupDecl attrGrp,
XSSimpleType simpleType, XSParticleDecl particle,
XSObjectListImpl annotations) {
fTargetNamespace = targetNamespace;
@@ -179,18 +186,19 @@
String contentType[] = {"EMPTY", "SIMPLE", "ELEMENT", "MIXED"};
String derivedBy[] = {"EMPTY", "EXTENSION", "RESTRICTION"};
- str.append("Complex type name='" + fTargetNamespace + "," + getTypeName() + "', ");
- if (fBaseType != null)
- str.append(" base type name='" + fBaseType.getName() + "', ");
-
- str.append(" content type='" + contentType[fContentType] + "', ");
- str.append(" isAbstract='" + getAbstract() + "', ");
- str.append(" hasTypeId='" + containsTypeID() + "', ");
- str.append(" final='" + fFinal + "', ");
- str.append(" block='" + fBlock + "', ");
- if (fParticle != null)
- str.append(" particle='" + fParticle.toString() + "', ");
- str.append(" derivedBy='" + derivedBy[fDerivedBy] + "'. ");
+ str.append("Complex type name='").append(fTargetNamespace).append(',').append(getTypeName()).append("', ");
+ if (fBaseType != null) {
+ str.append(" base type name='").append(fBaseType.getName()).append("', ");
+ }
+ str.append(" content type='").append(contentType[fContentType]).append("', ");
+ str.append(" isAbstract='").append(getAbstract()).append("', ");
+ str.append(" hasTypeId='").append(containsTypeID()).append("', ");
+ str.append(" final='").append(fFinal).append("', ");
+ str.append(" block='").append(fBlock).append("', ");
+ if (fParticle != null) {
+ str.append(" particle='").append(fParticle.toString()).append("', ");
+ }
+ str.append(" derivedBy='").append(derivedBy[fDerivedBy]).append("'. ");
}
@@ -241,14 +249,14 @@
* Checks if a type is derived from another given the the name, namespace
* and derivation method. See:
* http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
+ *
* @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
* The name of the ancestor type declaration
- * @param derivation
+ * @param derivationMethod
* The derivation method
- *
+ *
* @return boolean True if the ancestor type is derived from the reference
* type by the specifiied derivation method.
*/
@@ -257,16 +265,16 @@
// ancestor is null, retur false
if (ancestorName == null)
return false;
-
+
// ancestor is anyType, return true
if (ancestorNS != null
&& ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
&& ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
- && (derivationMethod == DERIVATION_RESTRICTION
+ && (derivationMethod == DERIVATION_RESTRICTION
&& derivationMethod == DERIVATION_EXTENSION)) {
return true;
}
-
+
// restriction
if ((derivationMethod & DERIVATION_RESTRICTION) != 0) {
if (isDerivedByRestriction(ancestorNS, ancestorName,
@@ -274,7 +282,7 @@
return true;
}
}
-
+
// extension
if ((derivationMethod & DERIVATION_EXTENSION) != 0) {
if (isDerivedByExtension(ancestorNS, ancestorName,
@@ -282,7 +290,7 @@
return true;
}
}
-
+
// list or union
if ((((derivationMethod & DERIVATION_LIST) != 0) || ((derivationMethod & DERIVATION_UNION) != 0))
&& ((derivationMethod & DERIVATION_RESTRICTION) == 0)
@@ -293,10 +301,10 @@
ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
}
- if(!(fName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
+ if(!(fName.equals(SchemaSymbols.ATTVAL_ANYTYPE)
&& fTargetNamespace.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA))){
if (fBaseType != null && fBaseType instanceof XSSimpleTypeDecl) {
-
+
return ((XSSimpleTypeDecl) fBaseType).isDOMDerivedFrom(ancestorNS,
ancestorName, derivationMethod);
} else if (fBaseType != null
@@ -306,25 +314,25 @@
}
}
}
-
+
// If the value of the parameter is 0 i.e. no bit (corresponding to
- // restriction, list, extension or union) is set to 1 for the
- // derivationMethod parameter.
+ // restriction, list, extension or union) is set to 1 for the
+ // derivationMethod parameter.
if (((derivationMethod & DERIVATION_EXTENSION) == 0)
&& (((derivationMethod & DERIVATION_RESTRICTION) == 0)
- && ((derivationMethod & DERIVATION_LIST) == 0)
+ && ((derivationMethod & DERIVATION_LIST) == 0)
&& ((derivationMethod & DERIVATION_UNION) == 0))) {
return isDerivedByAny(ancestorNS, ancestorName, derivationMethod, this);
}
return false;
}
-
+
/**
* Checks if a type is derived from another by any combination of
* restriction, list ir union. See:
* http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
+ *
* @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
@@ -333,7 +341,7 @@
* A short indication the method of derivation
* @param type
* The reference type definition
- *
+ *
* @return boolean True if the type is derived by any method for the
* reference type
*/
@@ -342,15 +350,15 @@
XSTypeDefinition oldType = null;
boolean derivedFrom = false;
while (type != null && type != oldType) {
-
+
// If the ancestor type is reached or is the same as this type.
if ((ancestorName.equals(type.getName()))
- && ((ancestorNS == null && type.getNamespace() == null)
+ && ((ancestorNS == null && type.getNamespace() == null)
|| (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
derivedFrom = true;
break;
}
-
+
// Check if this type is derived from the base by restriction or
// extension
if (isDerivedByRestriction(ancestorNS, ancestorName,
@@ -363,14 +371,14 @@
oldType = type;
type = type.getBaseType();
}
-
+
return derivedFrom;
}
-
+
/**
* Checks if a type is derived from another by restriction. See:
* http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
+ *
* @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
@@ -379,32 +387,32 @@
* A short indication the method of derivation *
* @param type
* The reference type definition
- *
+ *
* @return boolean True if the type is derived by restriciton for the
* reference type
*/
private boolean isDerivedByRestriction(String ancestorNS,
String ancestorName, int derivationMethod, XSTypeDefinition type) {
-
+
XSTypeDefinition oldType = null;
while (type != null && type != oldType) {
-
+
// ancestor is anySimpleType, return false
if (ancestorNS != null
&& ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
&& ancestorName.equals(SchemaSymbols.ATTVAL_ANYSIMPLETYPE)) {
return false;
}
-
+
// if the name and namespace of this type is the same as the
// ancestor return true
if ((ancestorName.equals(type.getName()))
- && (ancestorNS != null && ancestorNS.equals(type.getNamespace()))
+ && (ancestorNS != null && ancestorNS.equals(type.getNamespace()))
|| ((type.getNamespace() == null && ancestorNS == null))) {
-
+
return true;
}
-
+
// If the base type is a complexType with simpleContent
if (type instanceof XSSimpleTypeDecl) {
if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
@@ -423,16 +431,16 @@
}
oldType = type;
type = type.getBaseType();
-
+
}
-
+
return false;
}
-
+
/**
* Checks if a type is derived from another by extension. See:
* http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
+ *
* @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
@@ -441,13 +449,13 @@
* A short indication the method of derivation
* @param type
* The reference type definition
- *
+ *
* @return boolean True if the type is derived by extension for the
* reference type
*/
private boolean isDerivedByExtension(String ancestorNS,
String ancestorName, int derivationMethod, XSTypeDefinition type) {
-
+
boolean extension = false;
XSTypeDefinition oldType = null;
while (type != null && type != oldType) {
@@ -459,21 +467,21 @@
&& SchemaSymbols.ATTVAL_ANYTYPE.equals(type.getName())) {
break;
}
-
+
if ((ancestorName.equals(type.getName()))
- && ((ancestorNS == null && type.getNamespace() == null)
+ && ((ancestorNS == null && type.getNamespace() == null)
|| (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) {
// returns true if atleast one derivation step was extension
return extension;
}
-
+
// If the base type is a complexType with simpleContent
if (type instanceof XSSimpleTypeDecl) {
if (ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
&& ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
ancestorName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
}
-
+
// derivationMethod extension will always return false for a
// simpleType,
// we treat it like a restriction
@@ -487,7 +495,7 @@
& ((XSSimpleTypeDecl) type).isDOMDerivedFrom(
ancestorNS, ancestorName, derivationMethod);
}
-
+
} else {
// If the base type is a complex type
// At least one derivation step upto the ancestor type should be
@@ -499,12 +507,12 @@
oldType = type;
type = type.getBaseType();
}
-
+
return false;
}
-
-
-
+
+
+
public void reset(){
fName = null;
fTargetNamespace = null;
@@ -521,9 +529,10 @@
fXSSimpleType = null;
fParticle = null;
fCMValidator = null;
+ fUPACMValidator = null;
if(fAnnotations != null) {
// help out the garbage collector
- fAnnotations.clear();
+ fAnnotations.clearXSObjectList();
}
fAnnotations = null;
}
@@ -672,19 +681,22 @@
* Optional. Annotation.
*/
public XSObjectList getAnnotations() {
- return fAnnotations;
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
-
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
+
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return fNamespaceItem;
+ }
+
+ void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
+ }
/* (non-Javadoc)
- * @see com.sun.org.apache.xerces.internal.xs.XSComplexTypeDefinition#getAttributeUse(java.lang.String, java.lang.String)
+ * @see org.apache.xerces.xs.XSComplexTypeDefinition#getAttributeUse(java.lang.String, java.lang.String)
*/
public XSAttributeUse getAttributeUse(String namespace, String name) {
return fAttrGrp.getAttributeUse(namespace, name);
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,33 +20,94 @@
package com.sun.org.apache.xerces.internal.impl.xs;
-import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Vector;
+
+import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
+import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
import com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder;
import com.sun.org.apache.xerces.internal.impl.xs.models.XSCMValidator;
import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
-import com.sun.org.apache.xerces.internal.util.SymbolHash;
-import java.util.Vector;
/**
* Constaints shared by traversers and validator
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSConstraints.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSConstraints {
+ // IHR: Visited on 2006-11-17
+ // Added a boolean return value to particleValidRestriction (it was a void function)
+ // to help the checkRecurseLax to know when expansion has happened and no order is required
+ // (IHR@xbrl.org) (Ignacio@Hernandez-Ros.com)
+
static final int OCCURRENCE_UNKNOWN = SchemaSymbols.OCCURRENCE_UNBOUNDED-1;
static final XSSimpleType STRING_TYPE = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
+ private static XSParticleDecl fEmptyParticle = null;
+ public static XSParticleDecl getEmptySequence() {
+ if (fEmptyParticle == null) {
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
+ group.fParticleCount = 0;
+ group.fParticles = null;
+ group.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
+ particle.fValue = group;
+ particle.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ fEmptyParticle = particle;
+ }
+ return fEmptyParticle;
+ }
+
+ private static final Comparator ELEMENT_PARTICLE_COMPARATOR = new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ XSParticleDecl pDecl1 = (XSParticleDecl) o1;
+ XSParticleDecl pDecl2 = (XSParticleDecl) o2;
+ XSElementDecl decl1 = (XSElementDecl) pDecl1.fValue;
+ XSElementDecl decl2 = (XSElementDecl) pDecl2.fValue;
+
+ String namespace1 = decl1.getNamespace();
+ String namespace2 = decl2.getNamespace();
+ String name1 = decl1.getName();
+ String name2 = decl2.getName();
+
+ boolean sameNamespace = (namespace1 == namespace2);
+ int namespaceComparison = 0;
+
+ if (!sameNamespace) {
+ if (namespace1 != null) {
+ if (namespace2 != null){
+ namespaceComparison = namespace1.compareTo(namespace2);
+ }
+ else {
+ namespaceComparison = 1;
+ }
+ }
+ else {
+ namespaceComparison = -1;
+ }
+ }
+ //This assumes that the names are never null.
+ return namespaceComparison != 0 ? namespaceComparison : name1.compareTo(name2);
+ }
+ };
+
/**
* check whether derived is valid derived from base, given a subset
* of {restriction, extension}.B
@@ -74,8 +135,9 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)derived,
- (XSSimpleType)base, block);
- } else {
+ (XSSimpleType)base, block);
+ }
+ else {
return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
}
}
@@ -102,7 +164,7 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)derived,
- (XSSimpleType)base, block);
+ (XSSimpleType)base, block);
}
/**
@@ -129,7 +191,7 @@
// 2 All of the following must be true:
// 2.1 restriction is not in the subset, or in the {final} of its own {base type definition};
if ((block & XSConstants.DERIVATION_RESTRICTION) != 0 ||
- (derived.getBaseType().getFinal() & XSConstants.DERIVATION_RESTRICTION) != 0) {
+ (derived.getBaseType().getFinal() & XSConstants.DERIVATION_RESTRICTION) != 0) {
return false;
}
@@ -141,14 +203,14 @@
// 2.2.2 D's base type definition is not the simple ur-type definition and is validly derived from B given the subset, as defined by this constraint.
if (directBase != SchemaGrammar.fAnySimpleType &&
- checkSimpleDerivation(directBase, base, block)) {
+ checkSimpleDerivation(directBase, base, block)) {
return true;
}
// 2.2.3 D's {variety} is list or union and B is the simple ur-type definition.
if ((derived.getVariety() == XSSimpleType.VARIETY_LIST ||
- derived.getVariety() == XSSimpleType.VARIETY_UNION) &&
- base == SchemaGrammar.fAnySimpleType) {
+ derived.getVariety() == XSSimpleType.VARIETY_UNION) &&
+ base == SchemaGrammar.fAnySimpleType) {
return true;
}
@@ -189,7 +251,7 @@
// 2.3 All of the following must be true:
// 2.3.1 D's {base type definition} must not be the ur-type definition.
if (directBase == SchemaGrammar.fAnyType ||
- directBase == SchemaGrammar.fAnySimpleType) {
+ directBase == SchemaGrammar.fAnySimpleType) {
return false;
}
@@ -210,7 +272,7 @@
return false;
}
return checkSimpleDerivation((XSSimpleType)directBase,
- (XSSimpleType)base, block);
+ (XSSimpleType)base, block);
}
return false;
@@ -273,15 +335,15 @@
}
static void reportSchemaError(XMLErrorReporter errorReporter,
- SimpleLocator loc,
- String key, Object[] args) {
+ SimpleLocator loc,
+ String key, Object[] args) {
if (loc != null) {
errorReporter.reportError(loc, XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, XMLErrorReporter.SEVERITY_ERROR);
+ key, args, XMLErrorReporter.SEVERITY_ERROR);
}
else {
errorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, XMLErrorReporter.SEVERITY_ERROR);
+ key, args, XMLErrorReporter.SEVERITY_ERROR);
}
}
@@ -292,9 +354,9 @@
* Element Declrations Consistent.
*/
public static void fullSchemaChecking(XSGrammarBucket grammarBucket,
- SubstitutionGroupHandler SGHandler,
- CMBuilder cmBuilder,
- XMLErrorReporter errorReporter) {
+ SubstitutionGroupHandler SGHandler,
+ CMBuilder cmBuilder,
+ XMLErrorReporter errorReporter) {
// get all grammars, and put all substitution group information
// in the substitution group handler
SchemaGrammar[] grammars = grammarBucket.getGrammars();
@@ -316,25 +378,31 @@
XSModelGroupImpl derivedMG = derivedGrp.fModelGroup;
XSGroupDecl baseGrp = redefinedGroups[i++];
XSModelGroupImpl baseMG = baseGrp.fModelGroup;
+ fakeDerived.fValue = derivedMG;
+ fakeBase.fValue = baseMG;
if(baseMG == null) {
if(derivedMG != null) { // can't be a restriction!
reportSchemaError(errorReporter, rgLocators[i/2-1],
- "src-redefine.6.2.2",
- new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
+ }
+ } else if (derivedMG == null) {
+ if (!fakeBase.emptiable()) {
+ reportSchemaError(errorReporter, rgLocators[i/2-1],
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, "rcase-Recurse.2"});
}
} else {
- fakeDerived.fValue = derivedMG;
- fakeBase.fValue = baseMG;
try {
particleValidRestriction(fakeDerived, SGHandler, fakeBase, SGHandler);
} catch (XMLSchemaException e) {
String key = e.getKey();
reportSchemaError(errorReporter, rgLocators[i/2-1],
- key,
- e.getArgs());
+ key,
+ e.getArgs());
reportSchemaError(errorReporter, rgLocators[i/2-1],
- "src-redefine.6.2.2",
- new Object[]{derivedGrp.fName, key});
+ "src-redefine.6.2.2",
+ new Object[]{derivedGrp.fName, key});
}
}
}
@@ -355,7 +423,7 @@
// i: grammar; j: type; k: error
// for all grammars
SymbolHash elemTable = new SymbolHash();
- for (int i = grammars.length-1, j, k; i >= 0; i--) {
+ for (int i = grammars.length-1, j; i >= 0; i--) {
// get whether to skip EDC, and types need to be checked
keepType = 0;
fullChecked = grammars[i].fFullChecked;
@@ -366,58 +434,58 @@
// if we've already full-checked this grammar, then
// skip the EDC constraint
if (!fullChecked) {
- // 1. Element Decl Consistent
- if (types[j].fParticle!=null) {
- elemTable.clear();
- try {
- checkElementDeclsConsistent(types[j], types[j].fParticle,
- elemTable, SGHandler);
+ // 1. Element Decl Consistent
+ if (types[j].fParticle!=null) {
+ elemTable.clear();
+ try {
+ checkElementDeclsConsistent(types[j], types[j].fParticle,
+ elemTable, SGHandler);
+ }
+ catch (XMLSchemaException e) {
+ reportSchemaError(errorReporter, ctLocators[j],
+ e.getKey(),
+ e.getArgs());
+ }
}
- catch (XMLSchemaException e) {
- reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
- }
- }
}
// 2. Particle Derivation
if (types[j].fBaseType != null &&
- types[j].fBaseType != SchemaGrammar.fAnyType &&
- types[j].fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
- (types[j].fBaseType instanceof XSComplexTypeDecl)) {
+ types[j].fBaseType != SchemaGrammar.fAnyType &&
+ types[j].fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
+ (types[j].fBaseType instanceof XSComplexTypeDecl)) {
- XSParticleDecl derivedParticle=types[j].fParticle;
- XSParticleDecl baseParticle=
- ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle;
- if (derivedParticle==null) {
- if (baseParticle!=null && !baseParticle.emptiable()) {
- reportSchemaError(errorReporter,ctLocators[j],
- "derivation-ok-restriction.5.3.2",
- new Object[]{types[j].fName, types[j].fBaseType.getName()});
- }
- }
- else if (baseParticle!=null) {
- try {
- particleValidRestriction(types[j].fParticle,
- SGHandler,
- ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle,
- SGHandler);
- } catch (XMLSchemaException e) {
- reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
- reportSchemaError(errorReporter, ctLocators[j],
- "derivation-ok-restriction.5.4.2",
- new Object[]{types[j].fName});
- }
- }
- else {
- reportSchemaError(errorReporter, ctLocators[j],
- "derivation-ok-restriction.5.4.2",
- new Object[]{types[j].fName});
- }
+ XSParticleDecl derivedParticle=types[j].fParticle;
+ XSParticleDecl baseParticle=
+ ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle;
+ if (derivedParticle==null) {
+ if (baseParticle!=null && !baseParticle.emptiable()) {
+ reportSchemaError(errorReporter,ctLocators[j],
+ "derivation-ok-restriction.5.3.2",
+ new Object[]{types[j].fName, types[j].fBaseType.getName()});
+ }
+ }
+ else if (baseParticle!=null) {
+ try {
+ particleValidRestriction(types[j].fParticle,
+ SGHandler,
+ ((XSComplexTypeDecl)(types[j].fBaseType)).fParticle,
+ SGHandler);
+ } catch (XMLSchemaException e) {
+ reportSchemaError(errorReporter, ctLocators[j],
+ e.getKey(),
+ e.getArgs());
+ reportSchemaError(errorReporter, ctLocators[j],
+ "derivation-ok-restriction.5.4.2",
+ new Object[]{types[j].fName});
+ }
+ }
+ else {
+ reportSchemaError(errorReporter, ctLocators[j],
+ "derivation-ok-restriction.5.4.2",
+ new Object[]{types[j].fName});
+ }
}
// 3. UPA
// get the content model and check UPA
@@ -428,8 +496,8 @@
further = cm.checkUniqueParticleAttribution(SGHandler);
} catch (XMLSchemaException e) {
reportSchemaError(errorReporter, ctLocators[j],
- e.getKey(),
- e.getArgs());
+ e.getKey(),
+ e.getArgs());
}
}
// now report all errors
@@ -462,905 +530,920 @@
/*
Check that a given particle is a valid restriction of a base particle.
- */
+ */
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
- XSParticleDecl particle,
- SymbolHash elemDeclHash,
- SubstitutionGroupHandler sgHandler)
- throws XMLSchemaException {
+ XSParticleDecl particle,
+ SymbolHash elemDeclHash,
+ SubstitutionGroupHandler sgHandler)
+ throws XMLSchemaException {
- // check for elements in the tree with the same name and namespace
+ // check for elements in the tree with the same name and namespace
- int pType = particle.fType;
+ int pType = particle.fType;
- if (pType == XSParticleDecl.PARTICLE_WILDCARD)
- return;
+ if (pType == XSParticleDecl.PARTICLE_WILDCARD)
+ return;
- if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl elem = (XSElementDecl)(particle.fValue);
- findElemInTable(type, elem, elemDeclHash);
+ if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl elem = (XSElementDecl)(particle.fValue);
+ findElemInTable(type, elem, elemDeclHash);
- if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups.
- XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
- for (int i = 0; i < subGroup.length; i++) {
- findElemInTable(type, subGroup[i], elemDeclHash);
- }
- }
- return;
- }
+ if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups.
+ XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
+ for (int i = 0; i < subGroup.length; i++) {
+ findElemInTable(type, subGroup[i], elemDeclHash);
+ }
+ }
+ return;
+ }
- XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
+ XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
public static void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem,
- SymbolHash elemDeclHash)
- throws XMLSchemaException {
+ SymbolHash elemDeclHash)
+ throws XMLSchemaException {
// How can we avoid this concat? LM.
String name = elem.fName + "," + elem.fTargetNamespace;
XSElementDecl existingElem = null;
if ((existingElem = (XSElementDecl)(elemDeclHash.get(name))) == null) {
- // just add it in
- elemDeclHash.put(name, elem);
+ // just add it in
+ elemDeclHash.put(name, elem);
}
else {
- // If this is the same check element, we're O.K.
- if (elem == existingElem)
- return;
+ // If this is the same check element, we're O.K.
+ if (elem == existingElem)
+ return;
- if (elem.fType != existingElem.fType) {
- // Types are not the same
- throw new XMLSchemaException("cos-element-consistent",
- new Object[] {type.fName, elem.fName});
+ if (elem.fType != existingElem.fType) {
+ // Types are not the same
+ throw new XMLSchemaException("cos-element-consistent",
+ new Object[] {type.fName, elem.fName});
- }
+ }
}
}
- /*
- Check that a given particle is a valid restriction of a base particle.
- */
- private static void particleValidRestriction(XSParticleDecl dParticle,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl bParticle,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
- particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true);
+ // Check that a given particle is a valid restriction of a base particle.
+ //
+ // IHR: 2006/11/17
+ // Returns a boolean indicating if there has been expansion of substitution group
+ // in the bParticle.
+ // With this information the checkRecurseLax function knows when is
+ // to keep the order and when to ignore it.
+ private static boolean particleValidRestriction(XSParticleDecl dParticle,
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl bParticle,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
+ return particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true);
}
- private static void particleValidRestriction(XSParticleDecl dParticle,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl bParticle,
- SubstitutionGroupHandler bSGHandler,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
+ private static boolean particleValidRestriction(XSParticleDecl dParticle,
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl bParticle,
+ SubstitutionGroupHandler bSGHandler,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
+
+ Vector dChildren = null;
+ Vector bChildren = null;
+ int dMinEffectiveTotalRange=OCCURRENCE_UNKNOWN;
+ int dMaxEffectiveTotalRange=OCCURRENCE_UNKNOWN;
+
+ // By default there has been no expansion
+ boolean bExpansionHappened = false;
+
+ // Check for empty particles. If either base or derived particle is empty,
+ // (and the other isn't) it's an error.
+ if (dParticle.isEmpty() && !bParticle.emptiable()) {
+ throw new XMLSchemaException("cos-particle-restrict.a", null);
+ }
+ else if (!dParticle.isEmpty() && bParticle.isEmpty()) {
+ throw new XMLSchemaException("cos-particle-restrict.b", null);
+ }
+
+ //
+ // Do setup prior to invoking the Particle (Restriction) cases.
+ // This involves:
+ // - removing pointless occurrences for groups, and retrieving a vector of
+ // non-pointless children
+ // - turning top-level elements with substitution groups into CHOICE groups.
+ //
+
+ short dType = dParticle.fType;
+ //
+ // Handle pointless groups for the derived particle
+ //
+ if (dType == XSParticleDecl.PARTICLE_MODELGROUP) {
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
+
+ // Find a group, starting with this particle, with more than 1 child. There
+ // may be none, and the particle of interest trivially becomes an element or
+ // wildcard.
+ XSParticleDecl dtmp = getNonUnaryGroup(dParticle);
+ if (dtmp != dParticle) {
+ // Particle has been replaced. Retrieve new type info.
+ dParticle = dtmp;
+ dType = dParticle.fType;
+ if (dType == XSParticleDecl.PARTICLE_MODELGROUP)
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
+ }
+
+ // Fill in a vector with the children of the particle, removing any
+ // pointless model groups in the process.
+ dChildren = removePointlessChildren(dParticle);
+ }
+
+ int dMinOccurs = dParticle.fMinOccurs;
+ int dMaxOccurs = dParticle.fMaxOccurs;
+
+ //
+ // For elements which are the heads of substitution groups, treat as CHOICE
+ //
+ if (dSGHandler != null && dType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl dElement = (XSElementDecl)dParticle.fValue;
+
+ if (dElement.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups. Treat any element that has a
+ // subsitution group as a choice. Fill in the children vector with the
+ // members of the substitution group
+ XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement);
+ if (subGroup.length >0 ) {
+ // Now, set the type to be CHOICE. The "group" will have the same
+ // occurrence information as the original particle.
+ dType = XSModelGroupImpl.MODELGROUP_CHOICE;
+ dMinEffectiveTotalRange = dMinOccurs;
+ dMaxEffectiveTotalRange = dMaxOccurs;
+
+ // Fill in the vector of children
+ dChildren = new Vector(subGroup.length+1);
+ for (int i = 0; i < subGroup.length; i++) {
+ addElementToParticleVector(dChildren, subGroup[i]);
+ }
+ addElementToParticleVector(dChildren, dElement);
+ Collections.sort(dChildren, ELEMENT_PARTICLE_COMPARATOR);
+
+ // Set the handler to null, to indicate that we've finished handling
+ // substitution groups for this particle.
+ dSGHandler = null;
+ }
+ }
+ }
+
+ short bType = bParticle.fType;
+ //
+ // Handle pointless groups for the base particle
+ //
+ if (bType == XSParticleDecl.PARTICLE_MODELGROUP) {
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
+
+ // Find a group, starting with this particle, with more than 1 child. There
+ // may be none, and the particle of interest trivially becomes an element or
+ // wildcard.
+ XSParticleDecl btmp = getNonUnaryGroup(bParticle);
+ if (btmp != bParticle) {
+ // Particle has been replaced. Retrieve new type info.
+ bParticle = btmp;
+ bType = bParticle.fType;
+ if (bType == XSParticleDecl.PARTICLE_MODELGROUP)
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
+ }
+
+ // Fill in a vector with the children of the particle, removing any
+ // pointless model groups in the process.
+ bChildren = removePointlessChildren(bParticle);
+ }
+
+ int bMinOccurs = bParticle.fMinOccurs;
+ int bMaxOccurs = bParticle.fMaxOccurs;
+
+ if (bSGHandler != null && bType == XSParticleDecl.PARTICLE_ELEMENT) {
+ XSElementDecl bElement = (XSElementDecl)bParticle.fValue;
+
+ if (bElement.fScope == XSConstants.SCOPE_GLOBAL) {
+ // Check for subsitution groups. Treat any element that has a
+ // subsitution group as a choice. Fill in the children vector with the
+ // members of the substitution group
+ XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement);
+ if (bsubGroup.length >0 ) {
+ // Now, set the type to be CHOICE
+ bType = XSModelGroupImpl.MODELGROUP_CHOICE;
+
+ bChildren = new Vector(bsubGroup.length+1);
+ for (int i = 0; i < bsubGroup.length; i++) {
+ addElementToParticleVector(bChildren, bsubGroup[i]);
+ }
+ addElementToParticleVector(bChildren, bElement);
+ Collections.sort(bChildren, ELEMENT_PARTICLE_COMPARATOR);
+ // Set the handler to null, to indicate that we've finished handling
+ // substitution groups for this particle.
+ bSGHandler = null;
+
+ // if we are here expansion of bParticle happened
+ bExpansionHappened = true;
+ }
+ }
+ }
+
+ //
+ // O.K. - Figure out which particle derivation rule applies and call it
+ //
+ switch (dType) {
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ switch (bType) {
- Vector dChildren = null;
- Vector bChildren = null;
- int dMinEffectiveTotalRange=OCCURRENCE_UNKNOWN;
- int dMaxEffectiveTotalRange=OCCURRENCE_UNKNOWN;
+ // Elt:Elt NameAndTypeOK
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ checkNameAndTypeOK((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
+ (XSElementDecl)bParticle.fValue,bMinOccurs,bMaxOccurs);
+ return bExpansionHappened;
+ }
+
+ // Elt:Any NSCompat
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ checkNSCompat((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
+ (XSWildcardDecl)bParticle.fValue,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
+
+ // Elt:All RecurseAsIfGroup
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ // Treat the element as if it were in a group of the same type
+ // as the base Particle
+ dChildren = new Vector();
+ dChildren.addElement(dParticle);
+
+ checkRecurseLax(dChildren, 1, 1, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ // Treat the element as if it were in a group of the same type
+ // as the base Particle
+ dChildren = new Vector();
+ dChildren.addElement(dParticle);
+
+ checkRecurse(dChildren, 1, 1, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ switch (bType) {
+
+ // Any:Any NSSubset
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ checkNSSubset((XSWildcardDecl)dParticle.fValue, dMinOccurs, dMaxOccurs,
+ (XSWildcardDecl)bParticle.fValue, bMinOccurs, bMaxOccurs);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"any:choice,sequence,all,elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ switch (bType) {
+
+ // All:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
+
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"all:choice,sequence,elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ switch (bType) {
+
+ // Choice:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
+
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
+
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"choice:all,sequence,elt"});
+ }
+
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
- // Check for empty particles. If either base or derived particle is empty,
- // (and the other isn't) it's an error.
- if (dParticle.isEmpty() && !bParticle.emptiable()) {
- throw new XMLSchemaException("cos-particle-restrict.a", null);
- }
- else if (!dParticle.isEmpty() && bParticle.isEmpty()) {
- throw new XMLSchemaException("cos-particle-restrict.b", null);
- }
-
- //
- // Do setup prior to invoking the Particle (Restriction) cases.
- // This involves:
- // - removing pointless occurrences for groups, and retrieving a vector of
- // non-pointless children
- // - turning top-level elements with substitution groups into CHOICE groups.
- //
-
- short dType = dParticle.fType;
- //
- // Handle pointless groups for the derived particle
- //
- if (dType == XSParticleDecl.PARTICLE_MODELGROUP) {
- dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
-
- // Find a group, starting with this particle, with more than 1 child. There
- // may be none, and the particle of interest trivially becomes an element or
- // wildcard.
- XSParticleDecl dtmp = getNonUnaryGroup(dParticle);
- if (dtmp != dParticle) {
- // Particle has been replaced. Retrieve new type info.
- dParticle = dtmp;
- dType = dParticle.fType;
- if (dType == XSParticleDecl.PARTICLE_MODELGROUP)
- dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
- }
-
- // Fill in a vector with the children of the particle, removing any
- // pointless model groups in the process.
- dChildren = removePointlessChildren(dParticle);
- }
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ {
+ switch (bType) {
- int dMinOccurs = dParticle.fMinOccurs;
- int dMaxOccurs = dParticle.fMaxOccurs;
-
- //
- // For elements which are the heads of substitution groups, treat as CHOICE
- //
- if (dSGHandler != null && dType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl dElement = (XSElementDecl)dParticle.fValue;
-
- if (dElement.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups. Treat any element that has a
- // subsitution group as a choice. Fill in the children vector with the
- // members of the substitution group
- XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement);
- if (subGroup.length >0 ) {
- // Now, set the type to be CHOICE. The "group" will have the same
- // occurrence information as the original particle.
- dType = XSModelGroupImpl.MODELGROUP_CHOICE;
- dMinEffectiveTotalRange = dMinOccurs;
- dMaxEffectiveTotalRange = dMaxOccurs;
-
- // Fill in the vector of children
- dChildren = new Vector(subGroup.length+1);
- for (int i = 0; i < subGroup.length; i++) {
- addElementToParticleVector(dChildren, subGroup[i]);
- }
- addElementToParticleVector(dChildren, dElement);
-
- // Set the handler to null, to indicate that we've finished handling
- // substitution groups for this particle.
- dSGHandler = null;
- }
- }
- }
-
- short bType = bParticle.fType;
- //
- // Handle pointless groups for the base particle
- //
- if (bType == XSParticleDecl.PARTICLE_MODELGROUP) {
- bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
+ // Choice:Any NSRecurseCheckCardinality
+ case XSParticleDecl.PARTICLE_WILDCARD:
+ {
+ if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
+ if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
+ dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
- // Find a group, starting with this particle, with more than 1 child. There
- // may be none, and the particle of interest trivially becomes an element or
- // wildcard.
- XSParticleDecl btmp = getNonUnaryGroup(bParticle);
- if (btmp != bParticle) {
- // Particle has been replaced. Retrieve new type info.
- bParticle = btmp;
- bType = bParticle.fType;
- if (bType == XSParticleDecl.PARTICLE_MODELGROUP)
- bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
- }
-
- // Fill in a vector with the children of the particle, removing any
- // pointless model groups in the process.
- bChildren = removePointlessChildren(bParticle);
- }
-
- int bMinOccurs = bParticle.fMinOccurs;
- int bMaxOccurs = bParticle.fMaxOccurs;
-
- if (bSGHandler != null && bType == XSParticleDecl.PARTICLE_ELEMENT) {
- XSElementDecl bElement = (XSElementDecl)bParticle.fValue;
-
- if (bElement.fScope == XSConstants.SCOPE_GLOBAL) {
- // Check for subsitution groups. Treat any element that has a
- // subsitution group as a choice. Fill in the children vector with the
- // members of the substitution group
- XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement);
- if (bsubGroup.length >0 ) {
- // Now, set the type to be CHOICE
- bType = XSModelGroupImpl.MODELGROUP_CHOICE;
-
- bChildren = new Vector(bsubGroup.length+1);
- for (int i = 0; i < bsubGroup.length; i++) {
- addElementToParticleVector(bChildren, bsubGroup[i]);
- }
- addElementToParticleVector(bChildren, bElement);
- // Set the handler to null, to indicate that we've finished handling
- // substitution groups for this particle.
- bSGHandler = null;
- }
- }
- }
+ checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
+ dMaxEffectiveTotalRange,
+ dSGHandler,
+ bParticle,bMinOccurs,bMaxOccurs,
+ checkWCOccurrence);
+ return bExpansionHappened;
+ }
- //
- // O.K. - Figure out which particle derivation rule applies and call it
- //
- switch (dType) {
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- switch (bType) {
-
- // Elt:Elt NameAndTypeOK
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- checkNameAndTypeOK((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
- (XSElementDecl)bParticle.fValue,bMinOccurs,bMaxOccurs);
- return;
- }
-
- // Elt:Any NSCompat
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- checkNSCompat((XSElementDecl)dParticle.fValue,dMinOccurs,dMaxOccurs,
- (XSWildcardDecl)bParticle.fValue,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return;
- }
-
- // Elt:All RecurseAsIfGroup
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- // Treat the element as if it were in a group of the same type
- // as the base Particle
- dChildren = new Vector();
- dChildren.addElement(dParticle);
-
- checkRecurseLax(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- // Treat the element as if it were in a group of the same type
- // as the base Particle
- dChildren = new Vector();
- dChildren.addElement(dParticle);
-
- checkRecurse(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ {
+ checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- switch (bType) {
-
- // Any:Any NSSubset
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- checkNSSubset((XSWildcardDecl)dParticle.fValue, dMinOccurs, dMaxOccurs,
- (XSWildcardDecl)bParticle.fValue, bMinOccurs, bMaxOccurs);
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSModelGroupImpl.MODELGROUP_ALL:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"any:choice,sequence,all,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- switch (bType) {
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ {
+ checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
- // All:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
-
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"all:choice,sequence,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- switch (bType) {
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ {
+ int min1 = dMinOccurs * dChildren.size();
+ int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
+ dMaxOccurs : dMaxOccurs * dChildren.size();
+ checkMapAndSum(dChildren, min1, max1, dSGHandler,
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ return bExpansionHappened;
+ }
- // Choice:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"choice:all,sequence,elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
-
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- {
- switch (bType) {
+ case XSParticleDecl.PARTICLE_ELEMENT:
+ {
+ throw new XMLSchemaException("cos-particle-restrict.2",
+ new Object[]{"seq:elt"});
+ }
- // Choice:Any NSRecurseCheckCardinality
- case XSParticleDecl.PARTICLE_WILDCARD:
- {
- if (dMinEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMinEffectiveTotalRange = dParticle.minEffectiveTotalRange();
- if (dMaxEffectiveTotalRange == OCCURRENCE_UNKNOWN)
- dMaxEffectiveTotalRange = dParticle.maxEffectiveTotalRange();
-
- checkNSRecurseCheckCardinality(dChildren, dMinEffectiveTotalRange,
- dMaxEffectiveTotalRange,
- dSGHandler,
- bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
- return;
- }
-
- case XSModelGroupImpl.MODELGROUP_ALL:
- {
- checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
+ default:
+ {
+ throw new XMLSchemaException("Internal-Error",
+ new Object[]{"in particleValidRestriction"});
+ }
+ }
+ }
- case XSModelGroupImpl.MODELGROUP_SEQUENCE:
- {
- checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
+ }
- case XSModelGroupImpl.MODELGROUP_CHOICE:
- {
- int min1 = dMinOccurs * dChildren.size();
- int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
- dMaxOccurs : dMaxOccurs * dChildren.size();
- checkMapAndSum(dChildren, min1, max1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
- return;
- }
-
- case XSParticleDecl.PARTICLE_ELEMENT:
- {
- throw new XMLSchemaException("cos-particle-restrict.2",
- new Object[]{"seq:elt"});
- }
-
- default:
- {
- throw new XMLSchemaException("Internal-Error",
- new Object[]{"in particleValidRestriction"});
- }
- }
- }
-
- }
+ return bExpansionHappened;
}
private static void addElementToParticleVector (Vector v, XSElementDecl d) {
- XSParticleDecl p = new XSParticleDecl();
- p.fValue = d;
- p.fType = XSParticleDecl.PARTICLE_ELEMENT;
- v.addElement(p);
+ XSParticleDecl p = new XSParticleDecl();
+ p.fValue = d;
+ p.fType = XSParticleDecl.PARTICLE_ELEMENT;
+ v.addElement(p);
}
private static XSParticleDecl getNonUnaryGroup(XSParticleDecl p) {
- if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
- p.fType == XSParticleDecl.PARTICLE_WILDCARD)
- return p;
+ if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
+ p.fType == XSParticleDecl.PARTICLE_WILDCARD)
+ return p;
- if (p.fMinOccurs==1 && p.fMaxOccurs==1 &&
- p.fValue!=null && ((XSModelGroupImpl)p.fValue).fParticleCount == 1)
- return getNonUnaryGroup(((XSModelGroupImpl)p.fValue).fParticles[0]);
- else
- return p;
+ if (p.fMinOccurs==1 && p.fMaxOccurs==1 &&
+ p.fValue!=null && ((XSModelGroupImpl)p.fValue).fParticleCount == 1)
+ return getNonUnaryGroup(((XSModelGroupImpl)p.fValue).fParticles[0]);
+ else
+ return p;
}
private static Vector removePointlessChildren(XSParticleDecl p) {
+ if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
+ p.fType == XSParticleDecl.PARTICLE_WILDCARD)
+ return null;
- if (p.fType == XSParticleDecl.PARTICLE_ELEMENT ||
- p.fType == XSParticleDecl.PARTICLE_WILDCARD)
- return null;
+ Vector children = new Vector();
- Vector children = new Vector();
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ gatherChildren(group.fCompositor, group.fParticles[i], children);
- XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- gatherChildren(group.fCompositor, group.fParticles[i], children);
-
- return children;
+ return children;
}
private static void gatherChildren(int parentType, XSParticleDecl p, Vector children) {
- int min = p.fMinOccurs;
- int max = p.fMaxOccurs;
- int type = p.fType;
- if (type == XSParticleDecl.PARTICLE_MODELGROUP)
- type = ((XSModelGroupImpl)p.fValue).fCompositor;
+ int min = p.fMinOccurs;
+ int max = p.fMaxOccurs;
+ int type = p.fType;
+ if (type == XSParticleDecl.PARTICLE_MODELGROUP)
+ type = ((XSModelGroupImpl)p.fValue).fCompositor;
- if (type == XSParticleDecl.PARTICLE_ELEMENT ||
- type== XSParticleDecl.PARTICLE_WILDCARD) {
- children.addElement(p);
- return;
- }
+ if (type == XSParticleDecl.PARTICLE_ELEMENT ||
+ type== XSParticleDecl.PARTICLE_WILDCARD) {
+ children.addElement(p);
+ return;
+ }
- if (! (min==1 && max==1)) {
- children.addElement(p);
- }
- else if (parentType == type) {
- XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
- for (int i = 0; i < group.fParticleCount; i++)
- gatherChildren(type, group.fParticles[i], children);
- }
- else if (!p.isEmpty()) {
- children.addElement(p);
- }
+ if (! (min==1 && max==1)) {
+ children.addElement(p);
+ }
+ else if (parentType == type) {
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
+ for (int i = 0; i < group.fParticleCount; i++)
+ gatherChildren(type, group.fParticles[i], children);
+ }
+ else if (!p.isEmpty()) {
+ children.addElement(p);
+ }
}
private static void checkNameAndTypeOK(XSElementDecl dElement, int dMin, int dMax,
- XSElementDecl bElement, int bMin, int bMax)
- throws XMLSchemaException {
+ XSElementDecl bElement, int bMin, int bMax)
+ throws XMLSchemaException {
- //
- // Check that the names are the same
- //
- if (dElement.fName != bElement.fName ||
- dElement.fTargetNamespace != bElement.fTargetNamespace) {
- throw new XMLSchemaException(
- "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
- dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
- }
+ //
+ // Check that the names are the same
+ //
+ if (dElement.fName != bElement.fName ||
+ dElement.fTargetNamespace != bElement.fTargetNamespace) {
+ throw new XMLSchemaException(
+ "rcase-NameAndTypeOK.1",new Object[]{dElement.fName,
+ dElement.fTargetNamespace, bElement.fName, bElement.fTargetNamespace});
+ }
- //
- // Check nillable
- //
- if (!bElement.getNillable() && dElement.getNillable()) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.2",
- new Object[]{dElement.fName});
- }
+ //
+ // Check nillable
+ //
+ if (!bElement.getNillable() && dElement.getNillable()) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.2",
+ new Object[]{dElement.fName});
+ }
- //
- // Check occurrence range
- //
- if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.3",
- new Object[]{
- dElement.fName,
- Integer.toString(dMin),
- dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
- Integer.toString(bMin),
- bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
- }
+ //
+ // Check occurrence range
+ //
+ if (!checkOccurrenceRange(dMin, dMax, bMin, bMax)) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.3",
+ new Object[]{
+ dElement.fName,
+ Integer.toString(dMin),
+ dMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(dMax),
+ Integer.toString(bMin),
+ bMax==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(bMax)});
+ }
- //
- // Check for consistent fixed values
- //
- if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
- // derived one has to have a fixed value
- if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
- new Object[]{dElement.fName, bElement.fDefault.stringValue()});
- }
+ //
+ // Check for consistent fixed values
+ //
+ if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
+ // derived one has to have a fixed value
+ if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.4.a",
+ new Object[]{dElement.fName, bElement.fDefault.stringValue()});
+ }
- // get simple type
- boolean isSimple = false;
- if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
- ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
- isSimple = true;
- }
+ // get simple type
+ boolean isSimple = false;
+ if (dElement.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ||
+ ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
+ isSimple = true;
+ }
- // if there is no simple type, then compare based on string
- if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
- isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
- new Object[]{dElement.fName,
- dElement.fDefault.stringValue(),
- bElement.fDefault.stringValue()});
- }
- }
+ // if there is no simple type, then compare based on string
+ if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
+ isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.4.b",
+ new Object[]{dElement.fName,
+ dElement.fDefault.stringValue(),
+ bElement.fDefault.stringValue()});
+ }
+ }
- //
- // Check identity constraints
- //
- checkIDConstraintRestriction(dElement, bElement);
+ //
+ // Check identity constraints
+ //
+ checkIDConstraintRestriction(dElement, bElement);
- //
- // Check for disallowed substitutions
- //
- int blockSet1 = dElement.fBlock;
- int blockSet2 = bElement.fBlock;
- if (((blockSet1 & blockSet2)!=blockSet2) ||
- (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
- throw new XMLSchemaException("rcase-NameAndTypeOK.6",
- new Object[]{dElement.fName});
+ //
+ // Check for disallowed substitutions
+ //
+ int blockSet1 = dElement.fBlock;
+ int blockSet2 = bElement.fBlock;
+ if (((blockSet1 & blockSet2)!=blockSet2) ||
+ (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
+ throw new XMLSchemaException("rcase-NameAndTypeOK.6",
+ new Object[]{dElement.fName});
- //
- // Check that the derived element's type is derived from the base's.
- //
- if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
- (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
- throw new XMLSchemaException("rcase-NameAndTypeOK.7",
- new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
- }
+ //
+ // Check that the derived element's type is derived from the base's.
+ //
+ if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
+ (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
+ throw new XMLSchemaException("rcase-NameAndTypeOK.7",
+ new Object[]{dElement.fName, dElement.fType.getName(), bElement.fType.getName()});
+ }
}
private static void checkIDConstraintRestriction(XSElementDecl derivedElemDecl,
- XSElementDecl baseElemDecl)
- throws XMLSchemaException {
+ XSElementDecl baseElemDecl)
+ throws XMLSchemaException {
// TODO
} // checkIDConstraintRestriction
private static boolean checkOccurrenceRange(int min1, int max1, int min2, int max2) {
- if ((min1 >= min2) &&
- ((max2==SchemaSymbols.OCCURRENCE_UNBOUNDED) ||
- (max1!=SchemaSymbols.OCCURRENCE_UNBOUNDED && max1<=max2)))
- return true;
- else
- return false;
+ if ((min1 >= min2) &&
+ ((max2==SchemaSymbols.OCCURRENCE_UNBOUNDED) ||
+ (max1!=SchemaSymbols.OCCURRENCE_UNBOUNDED && max1<=max2)))
+ return true;
+ else
+ return false;
}
private static void checkNSCompat(XSElementDecl elem, int min1, int max1,
- XSWildcardDecl wildcard, int min2, int max2,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
+ XSWildcardDecl wildcard, int min2, int max2,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
- // check Occurrence ranges
- if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSCompat.2",
- new Object[]{
- elem.fName,
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
+ // check Occurrence ranges
+ if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSCompat.2",
+ new Object[]{
+ elem.fName,
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
- // check wildcard allows namespace of element
- if (!wildcard.allowNamespace(elem.fTargetNamespace)) {
- throw new XMLSchemaException("rcase-NSCompat.1",
- new Object[]{elem.fName,elem.fTargetNamespace});
- }
+ // check wildcard allows namespace of element
+ if (!wildcard.allowNamespace(elem.fTargetNamespace)) {
+ throw new XMLSchemaException("rcase-NSCompat.1",
+ new Object[]{elem.fName,elem.fTargetNamespace});
+ }
}
private static void checkNSSubset(XSWildcardDecl dWildcard, int min1, int max1,
- XSWildcardDecl bWildcard, int min2, int max2)
- throws XMLSchemaException {
+ XSWildcardDecl bWildcard, int min2, int max2)
+ throws XMLSchemaException {
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSSubset.2", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSSubset.2", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
- // check wildcard subset
- if (!dWildcard.isSubsetOf(bWildcard)) {
- throw new XMLSchemaException("rcase-NSSubset.1", null);
- }
+ // check wildcard subset
+ if (!dWildcard.isSubsetOf(bWildcard)) {
+ throw new XMLSchemaException("rcase-NSSubset.1", null);
+ }
- if (dWildcard.weakerProcessContents(bWildcard)) {
- throw new XMLSchemaException("rcase-NSSubset.3",
- new Object[]{dWildcard.getProcessContentsAsString(),
- bWildcard.getProcessContentsAsString()});
- }
+ if (dWildcard.weakerProcessContents(bWildcard)) {
+ throw new XMLSchemaException("rcase-NSSubset.3",
+ new Object[]{dWildcard.getProcessContentsAsString(),
+ bWildcard.getProcessContentsAsString()});
+ }
}
private static void checkNSRecurseCheckCardinality(Vector children, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- XSParticleDecl wildcard, int min2, int max2,
- boolean checkWCOccurrence)
- throws XMLSchemaException {
+ SubstitutionGroupHandler dSGHandler,
+ XSParticleDecl wildcard, int min2, int max2,
+ boolean checkWCOccurrence)
+ throws XMLSchemaException {
- // check Occurrence ranges
- if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.2", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
+ // check Occurrence ranges
+ if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.2", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
- // Check that each member of the group is a valid restriction of the wildcard
- int count = children.size();
- try {
- for (int i = 0; i < count; i++) {
- XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i);
- particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
+ // Check that each member of the group is a valid restriction of the wildcard
+ int count = children.size();
+ try {
+ for (int i = 0; i < count; i++) {
+ XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i);
+ particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
+ }
}
- }
- // REVISIT: should we really just ignore original cause of this error?
- // how can we report it?
- catch (XMLSchemaException e) {
- throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.1", null);
- }
+ // REVISIT: should we really just ignore original cause of this error?
+ // how can we report it?
+ catch (XMLSchemaException e) {
+ throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.1", null);
+ }
}
private static void checkRecurse(Vector dChildren, int min1, int max1,
- SubstitutionGroupHandler dSGHandler,
- Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
- throws XMLSchemaException {
+ SubstitutionGroupHandler dSGHandler,
+ Vector bChildren, int min2, int max2,
+ SubstitutionGroupHandler bSGHandler)
+ throws XMLSchemaException {
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-Recurse.1", new Object[]{
- Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-Recurse.1", new Object[]{
+ Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
- int count1= dChildren.size();
- int count2= bChildren.size();
+ int count1= dChildren.size();
+ int count2= bChildren.size();
- int current = 0;
- label: for (int i = 0; i
- //
- //
- //
- //
- //
- //
- //
- //
- //
+ // Here is an example of a valid restriction:
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
- // check Occurrence ranges
- if (!checkOccurrenceRange(min1,max1,min2,max2)) {
- throw new XMLSchemaException("rcase-MapAndSum.2",
- new Object[]{Integer.toString(min1),
- max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
- Integer.toString(min2),
- max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
- }
+ // check Occurrence ranges
+ if (!checkOccurrenceRange(min1,max1,min2,max2)) {
+ throw new XMLSchemaException("rcase-MapAndSum.2",
+ new Object[]{Integer.toString(min1),
+ max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1),
+ Integer.toString(min2),
+ max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)});
+ }
- int count1 = dChildren.size();
- int count2 = bChildren.size();
+ int count1 = dChildren.size();
+ int count2 = bChildren.size();
- label: for (int i = 0; i= 0; i--) {
if (subGroup[i].fName == element2.fName &&
- subGroup[i].fTargetNamespace == element2.fTargetNamespace) {
+ subGroup[i].fTargetNamespace == element2.fTargetNamespace) {
return true;
}
}
@@ -1379,7 +1462,7 @@
subGroup = sgHandler.getSubstitutionGroup(element2);
for (int i = subGroup.length-1; i >= 0; i--) {
if (subGroup[i].fName == element1.fName &&
- subGroup[i].fTargetNamespace == element1.fTargetNamespace) {
+ subGroup[i].fTargetNamespace == element1.fTargetNamespace) {
return true;
}
}
@@ -1390,8 +1473,8 @@
// to check whether an element overlaps with a wildcard,
// as defined in constraint UPA
public static boolean overlapUPA(XSElementDecl element,
- XSWildcardDecl wildcard,
- SubstitutionGroupHandler sgHandler) {
+ XSWildcardDecl wildcard,
+ SubstitutionGroupHandler sgHandler) {
// if the wildcard allows the element
if (wildcard.allowNamespace(element.fTargetNamespace))
return true;
@@ -1407,12 +1490,12 @@
}
public static boolean overlapUPA(XSWildcardDecl wildcard1,
- XSWildcardDecl wildcard2) {
+ XSWildcardDecl wildcard2) {
// if the intersection of the two wildcard is not empty list
XSWildcardDecl intersect = wildcard1.performIntersectionWith(wildcard2, wildcard1.fProcessContents);
if (intersect == null ||
- intersect.fType != XSWildcardDecl.NSCONSTRAINT_LIST ||
- intersect.fNamespaceList.length != 0) {
+ intersect.fType != XSWildcardDecl.NSCONSTRAINT_LIST ||
+ intersect.fNamespaceList.length != 0) {
return true;
}
@@ -1421,25 +1504,28 @@
// call one of the above methods according to the type of decls
public static boolean overlapUPA(Object decl1, Object decl2,
- SubstitutionGroupHandler sgHandler) {
+ SubstitutionGroupHandler sgHandler) {
if (decl1 instanceof XSElementDecl) {
if (decl2 instanceof XSElementDecl) {
return overlapUPA((XSElementDecl)decl1,
- (XSElementDecl)decl2,
- sgHandler);
- } else {
+ (XSElementDecl)decl2,
+ sgHandler);
+ }
+ else {
return overlapUPA((XSElementDecl)decl1,
- (XSWildcardDecl)decl2,
- sgHandler);
+ (XSWildcardDecl)decl2,
+ sgHandler);
}
- } else {
+ }
+ else {
if (decl2 instanceof XSElementDecl) {
return overlapUPA((XSElementDecl)decl2,
- (XSWildcardDecl)decl1,
- sgHandler);
- } else {
+ (XSWildcardDecl)decl1,
+ sgHandler);
+ }
+ else {
return overlapUPA((XSWildcardDecl)decl1,
- (XSWildcardDecl)decl2);
+ (XSWildcardDecl)decl2);
}
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl;
import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
/**
@@ -29,9 +30,10 @@
* declarations to the pool.
* Note: The cashing mechanism is not implemented yet.
*
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Elena Litani, IBM
+ * @version $Id: XSDeclarationPool.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public final class XSDeclarationPool {
/** Chunk shift (8). */
@@ -74,6 +76,11 @@
private XSAttributeUseImpl fAttributeUse[][] = new XSAttributeUseImpl[INITIAL_CHUNK_COUNT][];
private int fAttributeUseIndex = 0;
+ private SchemaDVFactoryImpl dvFactory;
+ public void setDVFactory(SchemaDVFactoryImpl dvFactory) {
+ this.dvFactory = dvFactory;
+ }
+
public final XSElementDecl getElementDecl(){
int chunk = fElementDeclIndex >> CHUNK_SHIFT;
int index = fElementDeclIndex & CHUNK_MASK;
@@ -134,7 +141,7 @@
int index = fSTDeclIndex & CHUNK_MASK;
ensureSTDeclCapacity(chunk);
if (fSTDecl[chunk][index] == null) {
- fSTDecl[chunk][index] = new XSSimpleTypeDecl();
+ fSTDecl[chunk][index] = dvFactory.newXSSimpleTypeDecl();
} else {
fSTDecl[chunk][index].reset();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -22,6 +22,9 @@
import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xs.ShortList;
import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
import com.sun.org.apache.xerces.internal.xs.XSComplexTypeDefinition;
@@ -29,17 +32,18 @@
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
import com.sun.org.apache.xerces.internal.xs.XSNamedMap;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
/**
* The XML representation for an element declaration
* schema component is an element information item
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
+ * @version $Id: XSElementDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSElementDecl implements XSElementDeclaration {
@@ -54,6 +58,7 @@
public String fTargetNamespace = null;
// type of the element
public XSTypeDefinition fType = null;
+ public QName fUnresolvedTypeName = null;
// misc flag of the element: nillable/abstract/fixed
short fMiscFlags = 0;
public short fScope = XSConstants.SCOPE_ABSENT;
@@ -64,7 +69,7 @@
// final set (substitution group exclusions) of the element
public short fFinal = XSConstants.DERIVATION_NONE;
// optional annotation
- public XSAnnotationImpl fAnnotation = null;
+ public XSObjectList fAnnotations = null;
// value constraint value
public ValidatedInfo fDefault = null;
// the substitution group affiliation of the element
@@ -73,6 +78,9 @@
static final int INITIAL_SIZE = 2;
int fIDCPos = 0;
IdentityConstraint[] fIDConstraints = new IdentityConstraint[INITIAL_SIZE];
+ // The namespace schema information item corresponding to the target namespace
+ // of the element declaration, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
private static final short CONSTRAINT_MASK = 3;
private static final short NILLABLE = 4;
@@ -167,15 +175,16 @@
* Reset current element declaration
*/
public void reset(){
-
+ fScope = XSConstants.SCOPE_ABSENT;
fName = null;
fTargetNamespace = null;
fType = null;
+ fUnresolvedTypeName = null;
fMiscFlags = 0;
fBlock = XSConstants.DERIVATION_NONE;
fFinal = XSConstants.DERIVATION_NONE;
fDefault = null;
- fAnnotation = null;
+ fAnnotations = null;
fSubGroup = null;
// reset identity constraints
for (int i=0;i= 0; j--) {
+ sg2 = (SchemaGrammar)gs.elementAt(j);
+ if (!grammars.contains(sg2))
+ grammars.addElement(sg2);
+ }
+ }
+ // we found one with the same target namespace, ignore it
+ else {
+ grammars.remove(sg1);
+ }
+ }
+
+ // now we have all imported grammars stored in the vector. add them
+ for (int i = grammars.size() - 1; i >= 0; i--) {
+ putGrammar((SchemaGrammar)grammars.elementAt(i));
+ }
+
+ return true;
+ }
+
+ /**
* get all grammars in the registry
*
* @return an array of SchemaGrammars.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,15 +20,23 @@
package com.sun.org.apache.xerces.internal.impl.xs;
-import com.sun.org.apache.xerces.internal.xs.*;
+
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSModelGroup;
+import com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* The XML representation for a group declaration
* schema component is a global element information item
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
+ * @version $Id: XSGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSGroupDecl implements XSModelGroupDefinition {
@@ -38,8 +46,11 @@
public String fTargetNamespace = null;
// model group of the group
public XSModelGroupImpl fModelGroup = null;
- // optional annotation
- public XSAnnotationImpl fAnnotation = null;
+ // optional annotations
+ public XSObjectList fAnnotations = null;
+ // The namespace schema information item corresponding to the target namespace
+ // of the model group definition, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
@@ -76,15 +87,25 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
+ }
+
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return fNamespaceItem;
+ }
+
+ void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
+ }
} // class XSGroupDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,7 +20,6 @@
package com.sun.org.apache.xerces.internal.impl.xs;
-import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSGrammarPool;
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
@@ -41,11 +40,12 @@
/**
* An implementation of XSLoader which wraps XMLSchemaLoader.
- *
+ *
* @xerces.internal
- *
+ *
* @author Michael Glavassevich, IBM
- *
+ *
+ * @version $Id: XSLoaderImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public final class XSLoaderImpl implements XSLoader, DOMConfiguration {
@@ -97,14 +97,11 @@
* Parses the content of XML Schema documents specified as the list of URI
* references. If the URI contains a fragment identifier, the behavior
* is not defined by this specification.
- * @param uri The list of URI locations.
+ * @param uriList The list of URI locations.
* @return An XSModel representing the schema documents.
*/
public XSModel loadURIList(StringList uriList) {
int length = uriList.getLength();
- if (length == 0) {
- return null;
- }
try {
fGrammarPool.clear();
for (int i = 0; i < length; ++i) {
@@ -127,9 +124,6 @@
*/
public XSModel loadInputList(LSInputList is) {
final int length = is.getLength();
- if (length == 0) {
- return null;
- }
try {
fGrammarPool.clear();
for (int i = 0; i < length; ++i) {
@@ -164,7 +158,7 @@
/**
* Parse an XML Schema document from a resource identified by a
* LSInput
.
- * @param is The DOMInputSource
from which the source
+ * @param is The LSInput
from which the source
* document is to be read.
* @return An XSModel representing this schema.
*/
@@ -180,28 +174,28 @@
}
/* (non-Javadoc)
- * @see DOMConfiguration#setParameter(String, Object)
+ * @see com.sun.org.apache.xerces.internal.dom3.DOMConfiguration#setParameter(java.lang.String, java.lang.Object)
*/
public void setParameter(String name, Object value) throws DOMException {
fSchemaLoader.setParameter(name, value);
}
/* (non-Javadoc)
- * @see DOMConfiguration#getParameter(String)
+ * @see com.sun.org.apache.xerces.internal.dom3.DOMConfiguration#getParameter(java.lang.String)
*/
public Object getParameter(String name) throws DOMException {
return fSchemaLoader.getParameter(name);
}
/* (non-Javadoc)
- * @see DOMConfiguration#canSetParameter(String, Object)
+ * @see com.sun.org.apache.xerces.internal.dom3.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object)
*/
public boolean canSetParameter(String name, Object value) {
return fSchemaLoader.canSetParameter(name, value);
}
/* (non-Javadoc)
- * @see DOMConfiguration#getParameterNames()
+ * @see com.sun.org.apache.xerces.internal.dom3.DOMConfiguration#getParameterNames()
*/
public DOMStringList getParameterNames() {
return fSchemaLoader.getParameterNames();
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,16 +20,21 @@
package com.sun.org.apache.xerces.internal.impl.xs;
-import com.sun.org.apache.xerces.internal.xs.*;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSModelGroup;
+import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* Store schema model group declaration.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSModelGroupImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSModelGroupImpl implements XSModelGroup {
@@ -48,8 +53,8 @@
public XSParticleDecl[] fParticles = null;
public int fParticleCount = 0;
- // this particle's optional annotation
- public XSAnnotationImpl fAnnotation;
+ // this particle's optional annotations
+ public XSObjectList fAnnotations = null;
// whether this model group contains nothing
public boolean isEmpty() {
@@ -142,7 +147,7 @@
*/
private String fDescription = null;
public String toString() {
- // REVISIT: Commented code may help to eliminate redundant parentheses (test first before committing)
+ // REVISIT: Commented code may help to eliminate redundant parentheses (test first before committing)
if (fDescription == null) {
StringBuffer buffer = new StringBuffer();
if (fCompositor == MODELGROUP_ALL)
@@ -170,7 +175,7 @@
fParticles = null;
fParticleCount = 0;
fDescription = null;
- fAnnotation = null;
+ fAnnotations = null;
}
/**
@@ -221,11 +226,18 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
}
/**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
+ }
+
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
*/
public XSNamespaceItem getNamespaceItem() {
return null;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,8 +20,20 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
import java.util.Vector;
+import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMap4Types;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
+import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xs.StringList;
import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
import com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition;
@@ -30,28 +42,24 @@
import com.sun.org.apache.xerces.internal.xs.XSModel;
import com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition;
import com.sun.org.apache.xerces.internal.xs.XSNamedMap;
+import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItemList;
import com.sun.org.apache.xerces.internal.xs.XSNotationDeclaration;
+import com.sun.org.apache.xerces.internal.xs.XSObject;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import com.sun.org.apache.xerces.internal.impl.xs.util.NSItemListImpl;
-import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
-import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMap4Types;
-import com.sun.org.apache.xerces.internal.impl.xs.util.XSNamedMapImpl;
-import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
-import com.sun.org.apache.xerces.internal.util.SymbolHash;
-import com.sun.org.apache.xerces.internal.util.XMLSymbols;
/**
* Implements XSModel: a read-only interface that represents an XML Schema,
* which could be components from different namespaces.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSModelImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
-public class XSModelImpl implements XSModel {
+public final class XSModelImpl extends AbstractList implements XSModel, XSNamespaceItemList {
// the max index / the max value of XSObject type
private static final short MAX_COMP_IDX = XSTypeDefinition.SIMPLE_TYPE;
@@ -75,26 +83,28 @@
};
// number of grammars/namespaces stored here
- private int fGrammarCount;
+ private final int fGrammarCount;
// all target namespaces
- private String[] fNamespaces;
+ private final String[] fNamespaces;
// all schema grammar objects (for each namespace)
- private SchemaGrammar[] fGrammarList;
+ private final SchemaGrammar[] fGrammarList;
// a map from namespace to schema grammar
- private SymbolHash fGrammarMap;
+ private final SymbolHash fGrammarMap;
// a map from element declaration to its substitution group
- private SymbolHash fSubGroupMap;
+ private final SymbolHash fSubGroupMap;
// store a certain kind of components from all namespaces
- private XSNamedMap[] fGlobalComponents;
+ private final XSNamedMap[] fGlobalComponents;
// store a certain kind of components from one namespace
- private XSNamedMap[][] fNSComponents;
+ private final XSNamedMap[][] fNSComponents;
+ // a string list of all the target namespaces.
+ private final StringList fNamespacesList;
// store all annotations
- private XSObjectListImpl fAnnotations = null;
+ private XSObjectList fAnnotations = null;
// whether there is any IDC in this XSModel
- private boolean fHasIDC = false;
+ private final boolean fHasIDC;
/**
* Construct an XSModelImpl, by storing some grammars and grammars imported
@@ -103,21 +113,29 @@
* @param grammars the array of schema grammars
*/
public XSModelImpl(SchemaGrammar[] grammars) {
+ this(grammars, Constants.SCHEMA_VERSION_1_0);
+ }
+
+ public XSModelImpl(SchemaGrammar[] grammars, short s4sVersion) {
// copy namespaces/grammars from the array to our arrays
int len = grammars.length;
- fNamespaces = new String[Math.max(len+1, 5)];
- fGrammarList = new SchemaGrammar[Math.max(len+1, 5)];
+ final int initialSize = Math.max(len+1, 5);
+ String[] namespaces = new String[initialSize];
+ SchemaGrammar[] grammarList = new SchemaGrammar[initialSize];
boolean hasS4S = false;
for (int i = 0; i < len; i++) {
- fNamespaces[i] = grammars[i].getTargetNamespace();
- fGrammarList[i] = grammars[i];
- if (fNamespaces[i] == SchemaSymbols.URI_SCHEMAFORSCHEMA)
+ final SchemaGrammar sg = grammars[i];
+ final String tns = sg.getTargetNamespace();
+ namespaces[i] = tns;
+ grammarList[i] = sg;
+ if (tns == SchemaSymbols.URI_SCHEMAFORSCHEMA) {
hasS4S = true;
+ }
}
// If a schema for the schema namespace isn't included, include it here.
if (!hasS4S) {
- fNamespaces[len] = SchemaSymbols.URI_SCHEMAFORSCHEMA;
- fGrammarList[len++] = SchemaGrammar.SG_SchemaNS;
+ namespaces[len] = SchemaSymbols.URI_SCHEMAFORSCHEMA;
+ grammarList[len++] = SchemaGrammar.getS4SGrammar(s4sVersion);
}
SchemaGrammar sg1, sg2;
@@ -126,68 +144,121 @@
// and recursively get all imported grammars, add them to our arrays
for (i = 0; i < len; i++) {
// get the grammar
- sg1 = fGrammarList[i];
+ sg1 = grammarList[i];
gs = sg1.getImportedGrammars();
// for each imported grammar
for (j = gs == null ? -1 : gs.size() - 1; j >= 0; j--) {
sg2 = (SchemaGrammar)gs.elementAt(j);
// check whether this grammar is already in the list
for (k = 0; k < len; k++) {
- if (sg2 == fGrammarList[k])
+ if (sg2 == grammarList[k]) {
break;
+ }
}
// if it's not, add it to the list
if (k == len) {
// ensure the capacity of the arrays
- if (len == fGrammarList.length) {
+ if (len == grammarList.length) {
String[] newSA = new String[len*2];
- System.arraycopy(fNamespaces, 0, newSA, 0, len);
- fNamespaces = newSA;
+ System.arraycopy(namespaces, 0, newSA, 0, len);
+ namespaces = newSA;
SchemaGrammar[] newGA = new SchemaGrammar[len*2];
- System.arraycopy(fGrammarList, 0, newGA, 0, len);
- fGrammarList = newGA;
+ System.arraycopy(grammarList, 0, newGA, 0, len);
+ grammarList = newGA;
}
- fNamespaces[len] = sg2.getTargetNamespace();
- fGrammarList[len] = sg2;
+ namespaces[len] = sg2.getTargetNamespace();
+ grammarList[len] = sg2;
len++;
}
}
}
+ fNamespaces = namespaces;
+ fGrammarList = grammarList;
+
+ boolean hasIDC = false;
// establish the mapping from namespace to grammars
fGrammarMap = new SymbolHash(len*2);
for (i = 0; i < len; i++) {
fGrammarMap.put(null2EmptyString(fNamespaces[i]), fGrammarList[i]);
// update the idc field
- if (fGrammarList[i].hasIDConstraints())
- fHasIDC = true;
+ if (fGrammarList[i].hasIDConstraints()) {
+ hasIDC = true;
+ }
}
+ fHasIDC = hasIDC;
fGrammarCount = len;
fGlobalComponents = new XSNamedMap[MAX_COMP_IDX+1];
fNSComponents = new XSNamedMap[len][MAX_COMP_IDX+1];
+ fNamespacesList = new StringListImpl(fNamespaces, fGrammarCount);
// build substitution groups
- buildSubGroups();
+ fSubGroupMap = buildSubGroups();
}
- private void buildSubGroups() {
+ private SymbolHash buildSubGroups_Org() {
SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
for (int i = 0 ; i < fGrammarCount; i++) {
sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
}
- XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
- int len = elements.getLength();
- fSubGroupMap = new SymbolHash(len*2);
+ final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
+ final int len = elements.getLength();
+ final SymbolHash subGroupMap = new SymbolHash(len*2);
+ XSElementDecl head;
+ XSElementDeclaration[] subGroup;
+ for (int i = 0; i < len; i++) {
+ head = (XSElementDecl)elements.item(i);
+ subGroup = sgHandler.getSubstitutionGroup(head);
+ subGroupMap.put(head, subGroup.length > 0 ?
+ new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
+ }
+ return subGroupMap;
+ }
+
+ private SymbolHash buildSubGroups() {
+ SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
+ for (int i = 0 ; i < fGrammarCount; i++) {
+ sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
+ }
+
+ final XSObjectListImpl elements = getGlobalElements();
+ final int len = elements.getLength();
+ final SymbolHash subGroupMap = new SymbolHash(len*2);
XSElementDecl head;
XSElementDeclaration[] subGroup;
for (int i = 0; i < len; i++) {
head = (XSElementDecl)elements.item(i);
subGroup = sgHandler.getSubstitutionGroup(head);
- fSubGroupMap.put(head, subGroup.length > 0 ?
+ subGroupMap.put(head, subGroup.length > 0 ?
new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
}
+ return subGroupMap;
+ }
+
+ private XSObjectListImpl getGlobalElements() {
+ final SymbolHash[] tables = new SymbolHash[fGrammarCount];
+ int length = 0;
+
+ for (int i = 0; i < fGrammarCount; i++) {
+ tables[i] = fGrammarList[i].fAllGlobalElemDecls;
+ length += tables[i].getLength();
+ }
+
+ if (length == 0) {
+ return XSObjectListImpl.EMPTY_LIST;
+ }
+
+ final XSObject[] components = new XSObject[length];
+
+ int start = 0;
+ for (int i = 0; i < fGrammarCount; i++) {
+ tables[i].getValues(components, start);
+ start += tables[i].getLength();
+ }
+
+ return new XSObjectListImpl(components, length);
}
/**
@@ -197,15 +268,19 @@
* null
if all components don't have a targetNamespace.
*/
public StringList getNamespaces() {
- // REVISIT: should the type of fNamespace be StringListImpl?
- return new StringListImpl(fNamespaces, fGrammarCount);
+ return fNamespacesList;
}
-
+ /**
+ * A set of namespace schema information information items (of type
+ * XSNamespaceItem
), one for each namespace name which
+ * appears as the target namespace of any schema component in the schema
+ * used for that assessment, and one for absent if any schema component
+ * in the schema had no target namespace. For more information see
+ * schema information.
+ */
public XSNamespaceItemList getNamespaceItems() {
-
- // REVISIT: should the type of fGrammarList be NSItemListImpl?
- return new NSItemListImpl(fGrammarList, fGrammarCount);
+ return this;
}
/**
@@ -291,18 +366,21 @@
int i = 0;
if (namespace != null) {
for (; i < fGrammarCount; ++i) {
- if (namespace.equals(fNamespaces[i]))
+ if (namespace.equals(fNamespaces[i])) {
break;
+ }
}
}
else {
for (; i < fGrammarCount; ++i) {
- if (fNamespaces[i] == null)
+ if (fNamespaces[i] == null) {
break;
+ }
}
}
- if (i == fGrammarCount)
+ if (i == fGrammarCount) {
return XSNamedMapImpl.EMPTY_MAP;
+ }
// get the hashtable for this type of components
if (fNSComponents[i][objectType] == null) {
@@ -355,12 +433,32 @@
public XSTypeDefinition getTypeDefinition(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSTypeDefinition)sg.fGlobalTypeDecls.get(name);
}
/**
+ * Convenience method. Returns a top-level simple or complex type
+ * definition.
+ * @param name The name of the definition.
+ * @param namespace The namespace of the definition, otherwise null.
+ * @param loc The schema location where the component was defined
+ * @return An XSTypeDefinition
or null if such definition
+ * does not exist.
+ */
+ public XSTypeDefinition getTypeDefinition(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalTypeDecl(name, loc);
+ }
+
+ /**
* Convenience method. Returns a top-level attribute declaration.
* @param name The name of the declaration.
* @param namespace The namespace of the definition, otherwise null.
@@ -370,12 +468,31 @@
public XSAttributeDeclaration getAttributeDeclaration(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSAttributeDeclaration)sg.fGlobalAttrDecls.get(name);
}
/**
+ * Convenience method. Returns a top-level attribute declaration.
+ * @param name The name of the declaration.
+ * @param namespace The namespace of the definition, otherwise null.
+ * @param loc The schema location where the component was defined
+ * @return A top-level attribute declaration or null if such declaration
+ * does not exist.
+ */
+ public XSAttributeDeclaration getAttributeDeclaration(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalAttributeDecl(name, loc);
+ }
+
+ /**
* Convenience method. Returns a top-level element declaration.
* @param name The name of the declaration.
* @param namespace The namespace of the definition, otherwise null.
@@ -385,12 +502,31 @@
public XSElementDeclaration getElementDeclaration(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSElementDeclaration)sg.fGlobalElemDecls.get(name);
}
/**
+ * Convenience method. Returns a top-level element declaration.
+ * @param name The name of the declaration.
+ * @param namespace The namespace of the definition, otherwise null.
+ * @param loc The schema location where the component was defined
+ * @return A top-level element declaration or null if such declaration
+ * does not exist.
+ */
+ public XSElementDeclaration getElementDeclaration(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalElementDecl(name, loc);
+ }
+
+ /**
* Convenience method. Returns a top-level attribute group definition.
* @param name The name of the definition.
* @param namespace The namespace of the definition, otherwise null.
@@ -400,12 +536,31 @@
public XSAttributeGroupDefinition getAttributeGroup(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSAttributeGroupDefinition)sg.fGlobalAttrGrpDecls.get(name);
}
/**
+ * Convenience method. Returns a top-level attribute group definition.
+ * @param name The name of the definition.
+ * @param namespace The namespace of the definition, otherwise null.
+ * @param loc The schema location where the component was defined
+ * @return A top-level attribute group definition or null if such
+ * definition does not exist.
+ */
+ public XSAttributeGroupDefinition getAttributeGroup(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalAttributeGroupDecl(name, loc);
+ }
+
+ /**
* Convenience method. Returns a top-level model group definition.
*
* @param name The name of the definition.
@@ -416,35 +571,72 @@
public XSModelGroupDefinition getModelGroupDefinition(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSModelGroupDefinition)sg.fGlobalGroupDecls.get(name);
}
+ /**
+ * Convenience method. Returns a top-level model group definition.
+ *
+ * @param name The name of the definition.
+ * @param namespace The namespace of the definition, otherwise null.
+ * @param loc The schema location where the component was defined
+ * @return A top-level model group definition definition or null if such
+ * definition does not exist.
+ */
+ public XSModelGroupDefinition getModelGroupDefinition(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalGroupDecl(name, loc);
+ }
+
/**
- * @see com.sun.org.apache.xerces.internal.xs.XSModel#getNotationDeclaration(String, String)
+ * @see org.apache.xerces.xs.XSModel#getNotationDeclaration(String, String)
*/
public XSNotationDeclaration getNotationDeclaration(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
- if (sg == null)
+ if (sg == null) {
return null;
+ }
return (XSNotationDeclaration)sg.fGlobalNotationDecls.get(name);
}
+ public XSNotationDeclaration getNotationDeclaration(String name,
+ String namespace,
+ String loc) {
+ SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(null2EmptyString(namespace));
+ if (sg == null) {
+ return null;
+ }
+ return sg.getGlobalNotationDecl(name, loc);
+ }
+
/**
- * {annotations} A set of annotations.
+ * [annotations]: a set of annotations if it exists, otherwise an empty
+ * XSObjectList
.
*/
public synchronized XSObjectList getAnnotations() {
- if(fAnnotations != null)
+ if (fAnnotations != null) {
return fAnnotations;
+ }
// do this in two passes to avoid inaccurate array size
int totalAnnotations = 0;
for (int i = 0; i < fGrammarCount; i++) {
totalAnnotations += fGrammarList[i].fNumAnnotations;
}
+ if (totalAnnotations == 0) {
+ fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ return fAnnotations;
+ }
XSAnnotationImpl [] annotations = new XSAnnotationImpl [totalAnnotations];
int currPos = 0;
for (int i = 0; i < fGrammarCount; i++) {
@@ -473,11 +665,145 @@
}
/**
- * REVISIT: to expose substitution group of a given element.
- * We need to add this to the XSModel interface.
+ * Convenience method. Returns a list containing the members of the
+ * substitution group for the given XSElementDeclaration
+ * or an empty XSObjectList
if the substitution group
+ * contains no members.
+ * @param head The substitution group head.
+ * @return A list containing the members of the substitution group
+ * for the given XSElementDeclaration
or an empty
+ * XSObjectList
if the substitution group contains
+ * no members.
*/
public XSObjectList getSubstitutionGroup(XSElementDeclaration head) {
return (XSObjectList)fSubGroupMap.get(head);
}
+ //
+ // XSNamespaceItemList methods
+ //
+
+ /**
+ * The number of XSNamespaceItem
s in the list. The range of
+ * valid child object indices is 0 to length-1
inclusive.
+ */
+ public int getLength() {
+ return fGrammarCount;
+ }
+
+ /**
+ * Returns the index
th item in the collection or
+ * null
if index
is greater than or equal to
+ * the number of objects in the list. The index starts at 0.
+ * @param index index into the collection.
+ * @return The XSNamespaceItem
at the index
th
+ * position in the XSNamespaceItemList
, or
+ * null
if the index specified is not valid.
+ */
+ public XSNamespaceItem item(int index) {
+ if (index < 0 || index >= fGrammarCount) {
+ return null;
+ }
+ return fGrammarList[index];
+ }
+
+ //
+ // java.util.List methods
+ //
+
+ public Object get(int index) {
+ if (index >= 0 && index < fGrammarCount) {
+ return fGrammarList[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public Iterator iterator() {
+ return listIterator0(0);
+ }
+
+ public ListIterator listIterator() {
+ return listIterator0(0);
+ }
+
+ public ListIterator listIterator(int index) {
+ if (index >= 0 && index < fGrammarCount) {
+ return listIterator0(index);
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ private ListIterator listIterator0(int index) {
+ return new XSNamespaceItemListIterator(index);
+ }
+
+ public Object[] toArray() {
+ Object[] a = new Object[fGrammarCount];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (a.length < fGrammarCount) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fGrammarCount);
+ }
+ toArray0(a);
+ if (a.length > fGrammarCount) {
+ a[fGrammarCount] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fGrammarCount > 0) {
+ System.arraycopy(fGrammarList, 0, a, 0, fGrammarCount);
+ }
+ }
+
+ private final class XSNamespaceItemListIterator implements ListIterator {
+ private int index;
+ public XSNamespaceItemListIterator(int index) {
+ this.index = index;
+ }
+ public boolean hasNext() {
+ return (index < fGrammarCount);
+ }
+ public Object next() {
+ if (index < fGrammarCount) {
+ return fGrammarList[index++];
+ }
+ throw new NoSuchElementException();
+ }
+ public boolean hasPrevious() {
+ return (index > 0);
+ }
+ public Object previous() {
+ if (index > 0) {
+ return fGrammarList[--index];
+ }
+ throw new NoSuchElementException();
+ }
+ public int nextIndex() {
+ return index;
+ }
+ public int previousIndex() {
+ return index - 1;
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ public void set(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ public void add(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
} // class XSModelImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,18 +20,21 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
import com.sun.org.apache.xerces.internal.xs.XSNotationDeclaration;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* The XML representation for a NOTATION declaration
* schema component is a global element information item
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Rahul Srivastava, Sun Microsystems Inc.
+ * @version $Id: XSNotationDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSNotationDecl implements XSNotationDeclaration {
@@ -45,7 +48,11 @@
public String fSystemId = null;
// optional annotation
- public XSAnnotationImpl fAnnotation = null;
+ public XSObjectList fAnnotations = null;
+
+ // The namespace schema information item corresponding to the target namespace
+ // of the notation declaration, if it is globally declared; or null otherwise.
+ private XSNamespaceItem fNamespaceItem = null;
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
@@ -90,14 +97,25 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
+ }
+
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- return null;
- }
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return fNamespaceItem;
+ }
+
+ void setNamespaceItem(XSNamespaceItem namespaceItem) {
+ fNamespaceItem = namespaceItem;
+ }
} // class XSNotationDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,18 +20,21 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSParticle;
import com.sun.org.apache.xerces.internal.xs.XSTerm;
/**
* Store schema particle declaration.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSParticleDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSParticleDecl implements XSParticle {
@@ -57,6 +60,8 @@
public int fMinOccurs = 1;
// maximum occurrence of this particle
public int fMaxOccurs = 1;
+ // optional annotation
+ public XSObjectList fAnnotations = null;
// clone this decl
public XSParticleDecl makeClone() {
@@ -66,6 +71,7 @@
particle.fMaxOccurs = fMaxOccurs;
particle.fDescription = fDescription;
particle.fValue = fValue;
+ particle.fAnnotations = fAnnotations;
return particle;
}
@@ -129,12 +135,12 @@
appendParticle(buffer);
if (!(fMinOccurs == 0 && fMaxOccurs == 0 ||
fMinOccurs == 1 && fMaxOccurs == 1)) {
- buffer.append("{" + fMinOccurs);
+ buffer.append('{').append(fMinOccurs);
if (fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
buffer.append("-UNBOUNDED");
else if (fMinOccurs != fMaxOccurs)
- buffer.append("-" + fMaxOccurs);
- buffer.append("}");
+ buffer.append('-').append(fMaxOccurs);
+ buffer.append('}');
}
fDescription = buffer.toString();
}
@@ -170,6 +176,7 @@
fMinOccurs = 1;
fMaxOccurs = 1;
fDescription = null;
+ fAnnotations = null;
}
/**
@@ -224,11 +231,18 @@
return fValue;
}
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- return null;
- }
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return null;
+ }
-} // class XSParticle
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
+ }
+
+} // class XSParticleDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,22 +20,25 @@
package com.sun.org.apache.xerces.internal.impl.xs;
+import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.xs.StringList;
import com.sun.org.apache.xerces.internal.xs.XSAnnotation;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
import com.sun.org.apache.xerces.internal.xs.XSWildcard;
-import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* The XML representation for a wildcard declaration
* schema component is an or element information item
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
+ * @version $Id: XSWildcardDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSWildcardDecl implements XSWildcard {
@@ -51,7 +54,7 @@
public String[] fNamespaceList;
// optional annotation
- public XSAnnotationImpl fAnnotation = null;
+ public XSObjectList fAnnotations = null;
// I'm trying to implement the following constraint exactly as what the
// spec describes. Sometimes it seems redundant, and sometimes there seems
@@ -504,7 +507,7 @@
}
break;
}
- buffer.append("]");
+ buffer.append(']');
fDescription = buffer.toString();
}
@@ -576,16 +579,21 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- return fAnnotation;
+ return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
}
+ /**
+ * Optional. Annotations.
+ */
+ public XSObjectList getAnnotations() {
+ return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
+ }
- /**
- * @see com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()
- */
- public XSNamespaceItem getNamespaceItem() {
- // REVISIT: implement
- return null;
- }
+ /**
+ * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ return null;
+ }
} // class XSWildcardDecl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java Wed Sep 28 17:36:24 2011 +0100
@@ -22,6 +22,7 @@
import com.sun.org.apache.xerces.internal.impl.xpath.XPathException;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
@@ -31,9 +32,10 @@
/**
* Schema identity constraint selector.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Andy Clark, IBM
+ * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $
*/
public class Selector {
@@ -42,10 +44,10 @@
//
/** XPath. */
- protected Selector.XPath fXPath;
+ protected final Selector.XPath fXPath;
/** Identity constraint. */
- protected IdentityConstraint fIdentityConstraint;
+ protected final IdentityConstraint fIdentityConstraint;
// the Identity constraint we're the matcher for. Only
// used for selectors!
@@ -104,6 +106,7 @@
* Schema identity constraint selector XPath expression.
*
* @author Andy Clark, IBM
+ * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $
*/
public static class XPath
extends com.sun.org.apache.xerces.internal.impl.xpath.XPath {
@@ -138,7 +141,7 @@
StringBuffer modifiedXPath = new StringBuffer(xpath.length()+5);
int unionIndex = -1;
do {
- if(!(xpath.trim().startsWith("/") ||xpath.trim().startsWith("."))) {
+ if(!(XMLChar.trim(xpath).startsWith("/") || XMLChar.trim(xpath).startsWith("."))) {
modifiedXPath.append("./");
}
unionIndex = xpath.indexOf('|');
@@ -167,10 +170,10 @@
//
/** Field activator. */
- protected FieldActivator fFieldActivator;
+ protected final FieldActivator fFieldActivator;
/** Initial depth in the document at which this matcher was created. */
- protected int fInitialDepth;
+ protected final int fInitialDepth;
/** Element depth. */
protected int fElementDepth;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java Wed Sep 28 17:36:24 2011 +0100
@@ -30,12 +30,12 @@
import java.util.ArrayList;
/**
- * XSAllCM implements XSCMValidator and handles
+ * XSAllCM implements XSCMValidator and handles <all>.
*
* @xerces.internal
*
* @author Pavani Mukthipudi, Sun Microsystems Inc.
- * @version $Id: XSAllCM.java,v 1.7 2009/07/28 15:18:11 spericas Exp $
+ * @version $Id: XSAllCM.java,v 1.10 2010-11-01 04:39:58 joehw Exp $
*/
public class XSAllCM implements XSCMValidator {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -61,19 +61,19 @@
package com.sun.org.apache.xerces.internal.impl.xs.opti;
-import org.w3c.dom.TypeInfo;
import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
-import org.w3c.dom.DOMException;
-
+import org.w3c.dom.Node;
+import org.w3c.dom.TypeInfo;
/**
* This class represents a single attribute.
*
* @author Rahul Srivastava, Sun Microsystems Inc.
*
+ * @version $Id: AttrImpl.java,v 1.5 2010-11-01 04:40:01 joehw Exp $
*/
public class AttrImpl extends NodeImpl
implements Attr {
@@ -102,12 +102,10 @@
this.value = value;
}
-
public String getName() {
return rawname;
}
-
public boolean getSpecified() {
return true;
}
@@ -116,11 +114,17 @@
return value;
}
+ public String getNodeValue() {
+ return getValue();
+ }
public Element getOwnerElement() {
return element;
}
+ public Document getOwnerDocument() {
+ return element.getOwnerDocument();
+ }
public void setValue(String value) throws DOMException {
this.value = value;
@@ -133,7 +137,7 @@
return false;
}
- /**
+ /**
* Method getSchemaTypeInfo.
* @return TypeInfo
*/
@@ -141,4 +145,8 @@
return null;
}
+ /** NON-DOM method for debugging convenience */
+ public String toString() {
+ return getName() + "=" + "\"" + getValue() + "\"";
+ }
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,11 +26,12 @@
import org.w3c.dom.Node;
/**
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: ElementImpl.java,v 1.7 2010-11-01 04:40:01 joehw Exp $
*/
public class ElementImpl extends DefaultElement {
@@ -43,6 +44,7 @@
int line;
int column;
int charOffset;
+ String fAnnotation;
String fSyntheticAnnotation;
public ElementImpl(int line, int column, int offset) {
@@ -187,7 +189,7 @@
public String getAttributeNS(String namespaceURI, String localName) {
for (int i=0; i");
- }
-
- // note that this will only be called within appinfo/documentation
- void processingInstruction(String target, String data) {
- fAnnotationBuffer.append("").append(target).append(" ").append(data).append("?>");
+ fAnnotationBuffer.append("");
}
// note that this will only be called within appinfo/documentation
- void characters(XMLString text ) {
+ void processingInstruction(String target, XMLString data) {
+ fAnnotationBuffer.append("").append(target);
+ if (data.length > 0) {
+ fAnnotationBuffer.append(' ').append(data.ch, data.offset, data.length);
+ }
+ fAnnotationBuffer.append("?>");
+ }
+
+ // note that this will only be called within appinfo/documentation
+ void characters(XMLString text) {
// escape characters if necessary
if (!inCDATA) {
- for (int i = text.offset; i < text.offset+text.length; ++i ) {
+ final StringBuffer annotationBuffer = fAnnotationBuffer;
+ for (int i = text.offset; i < text.offset+text.length; ++i) {
char ch = text.ch[i];
if (ch == '&') {
- fAnnotationBuffer.append("&");
+ annotationBuffer.append("&");
}
else if (ch == '<') {
- fAnnotationBuffer.append("<");
+ annotationBuffer.append("<");
}
// character sequence "]]>" cannot appear in content,
// therefore we should escape '>'.
else if (ch == '>') {
- fAnnotationBuffer.append(">");
+ annotationBuffer.append(">");
}
// If CR is part of the document's content, it
// must not be printed as a literal otherwise
// it would be normalized to LF when the document
// is reparsed.
else if (ch == '\r') {
- fAnnotationBuffer.append("
");
+ annotationBuffer.append("
");
}
else {
- fAnnotationBuffer.append(ch);
+ annotationBuffer.append(ch);
}
}
}
@@ -194,45 +204,33 @@
}
}
- void endAnnotationElement(QName elemName, boolean complete) {
- if(complete) {
- fAnnotationBuffer.append("\n").append(elemName.rawname).append(">");
- // note that this is always called after endElement on 's
- // child and before endElement on annotation.
- // hence, we must make this the child of the current
- // parent's only child.
- ElementImpl child = (ElementImpl)relations[currLoc][1];
-
- // check if array needs to be resized
- if (nextFreeLoc == relations.length) {
- resizeRelations();
- }
- int newRow = child.parentRow = nextFreeLoc++;
+ // note that this will only be called within appinfo/documentation
+ void charactersRaw(String text) {
+ fAnnotationBuffer.append(text);
+ }
- // now find the place to insert this node
- boolean foundPlace = false;
- int i = 1;
- for (; i");
+ annotation.fAnnotation = fAnnotationBuffer.toString();
+ // apparently, there is no sensible way of resetting these things
+ fAnnotationBuffer = null;
+ }
- if (!foundPlace) {
- resizeRelations(newRow);
- }
- relations[newRow][i] = new TextImpl(fAnnotationBuffer, this, newRow, i);
- // apparently, there is no sensible way of resetting
- // these things
- fAnnotationBuffer = null;
- } else //capturing character calls
- fAnnotationBuffer.append("").append(elemName.rawname).append(">");
+ void endAnnotationElement(QName elemName) {
+ endAnnotationElement(elemName.rawname);
+ }
+
+ void endAnnotationElement(String elemRawName) {
+ fAnnotationBuffer.append("").append(elemRawName).append(">");
}
void endSyntheticAnnotationElement(QName elemName, boolean complete) {
+ endSyntheticAnnotationElement(elemName.rawname, complete);
+ }
+
+ void endSyntheticAnnotationElement(String elemRawName, boolean complete) {
if(complete) {
- fAnnotationBuffer.append("\n").append(elemName.rawname).append(">");
+ fAnnotationBuffer.append("\n").append(elemRawName).append(">");
// note that this is always called after endElement on 's
// child and before endElement on annotation.
// hence, we must make this the child of the current
@@ -243,7 +241,7 @@
// these things
fAnnotationBuffer = null;
} else //capturing character calls
- fAnnotationBuffer.append("").append(elemName.rawname).append(">");
+ fAnnotationBuffer.append("").append(elemRawName).append(">");
}
void startAnnotationCDATA() {
@@ -349,25 +347,33 @@
return (ElementImpl)relations[0][1];
}
+ public DOMImplementation getImplementation() {
+ return SchemaDOMImplementation.getDOMImplementation();
+ }
+
// commence the serialization of an annotation
void startAnnotation(QName elemName, XMLAttributes attributes,
NamespaceContext namespaceContext) {
+ startAnnotation(elemName.rawname, attributes, namespaceContext);
+ }
+ void startAnnotation(String elemRawName, XMLAttributes attributes,
+ NamespaceContext namespaceContext) {
if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256);
- fAnnotationBuffer.append("<").append(elemName.rawname).append(" ");
+ fAnnotationBuffer.append("<").append(elemRawName).append(" ");
// attributes are a bit of a pain. To get this right, we have to keep track
// of the namespaces we've seen declared, then examine the namespace context
// for other namespaces so that we can also include them.
// optimized for simplicity and the case that not many
// namespaces are declared on this annotation...
- Vector namespaces = new Vector();
+ ArrayList namespaces = new ArrayList();
for (int i = 0; i < attributes.getLength(); ++i) {
String aValue = attributes.getValue(i);
String aPrefix = attributes.getPrefix(i);
String aQName = attributes.getQName(i);
// if it's xmlns:* or xmlns, must be a namespace decl
if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
- namespaces.addElement(aPrefix == XMLSymbols.PREFIX_XMLNS ?
+ namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ?
attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
}
fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");
@@ -394,7 +400,10 @@
fAnnotationBuffer.append(">\n");
}
void startAnnotationElement(QName elemName, XMLAttributes attributes) {
- fAnnotationBuffer.append("<").append(elemName.rawname);
+ startAnnotationElement(elemName.rawname, attributes);
+ }
+ void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
+ fAnnotationBuffer.append("<").append(elemRawName);
for(int i=0; inot parsed or presented
* to the application as anything other than text. The application is
* responsible for parsing the data.
- *
+ *
* @param target The target.
* @param data The data or null if none specified.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {
- if(fAnnotationDepth > -1) {
- schemaDOM.processingInstruction(target, data.toString());
+ if (fAnnotationDepth > -1) {
+ schemaDOM.processingInstruction(target, data);
}
}
-
+
/**
* Character content.
- *
+ *
* @param text The content.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -193,7 +195,8 @@
// the string we saw: starting from the first non-whitespace character.
String txt = new String(text.ch, i, text.length+text.offset-i);
// report an error
- fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ fErrorReporter.reportError(fLocator,
+ XSMessageFormatter.SCHEMA_DOMAIN,
"s4s-elt-character",
new Object[]{txt},
XMLErrorReporter.SEVERITY_ERROR);
@@ -209,23 +212,23 @@
else {
schemaDOM.characters(text);
}
-
+
}
-
-
+
+
/**
* The start of an element.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
-
+
fDepth++;
// while it is true that non-whitespace character data
// may only occur in appInfo or documentation
@@ -243,60 +246,67 @@
}
fAnnotationDepth = fDepth;
schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
- }
+ fCurrentAnnotationElement = schemaDOM.startElement(element, attributes,
+ fLocator.getLineNumber(),
+ fLocator.getColumnNumber(),
+ fLocator.getCharacterOffset());
+ return;
+ }
else if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
fSawAnnotation.push(false);
fHasNonSchemaAttributes.push(hasNonSchemaAttributes(element, attributes));
}
- } else if(fDepth == fAnnotationDepth+1) {
+ }
+ else if (fDepth == fAnnotationDepth + 1) {
fInnerAnnotationDepth = fDepth;
schemaDOM.startAnnotationElement(element, attributes);
- } else {
+ }
+ else {
schemaDOM.startAnnotationElement(element, attributes);
// avoid falling through; don't call startElement in this case
return;
}
- schemaDOM.startElement(element, attributes,
+ schemaDOM.startElement(element, attributes,
fLocator.getLineNumber(),
fLocator.getColumnNumber(),
fLocator.getCharacterOffset());
-
+
}
-
-
+
+
/**
* An empty element.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
-
- if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
- element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {
-
+
+ if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
+ element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {
+
schemaDOM.startElement(element, attributes,
fLocator.getLineNumber(),
fLocator.getColumnNumber(),
fLocator.getCharacterOffset());
-
+
attributes.removeAllAttributes();
String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
- QName annQName = new QName(schemaPrefix, SchemaSymbols.ELT_ANNOTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_ANNOTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
- schemaDOM.startAnnotation(annQName, attributes, fNamespaceContext);
- QName elemQName = new QName(schemaPrefix, SchemaSymbols.ELT_DOCUMENTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_DOCUMENTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
- schemaDOM.startAnnotationElement(elemQName, attributes);
- schemaDOM.characters(new XMLString("SYNTHETIC_ANNOTATION".toCharArray(), 0, 20 ));
- schemaDOM.endSyntheticAnnotationElement(elemQName, false);
- schemaDOM.endSyntheticAnnotationElement(annQName, true);
-
+ final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
+ schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
+ final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
+ schemaDOM.startAnnotationElement(elemRawName, attributes);
+ schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
+ schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
+ schemaDOM.endSyntheticAnnotationElement(annRawName, true);
+
schemaDOM.endElement();
-
+
return;
}
// the order of events that occurs here is:
@@ -316,51 +326,53 @@
element.localpart == SchemaSymbols.ELT_ANNOTATION) {
schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
}
- } else {
+ }
+ else {
schemaDOM.startAnnotationElement(element, attributes);
}
-
- schemaDOM.emptyElement(element, attributes,
+
+ ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
fLocator.getLineNumber(),
fLocator.getColumnNumber(),
fLocator.getCharacterOffset());
-
+
if (fAnnotationDepth == -1) {
// this is messed up, but a case to consider:
if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
element.localpart == SchemaSymbols.ELT_ANNOTATION) {
- schemaDOM.endAnnotationElement(element, true);
+ schemaDOM.endAnnotation(element, newElem);
}
- } else {
- schemaDOM.endAnnotationElement(element, false);
- }
+ }
+ else {
+ schemaDOM.endAnnotationElement(element);
+ }
}
-
-
+
+
/**
* The end of an element.
- *
+ *
* @param element The name of the element.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
public void endElement(QName element, Augmentations augs) throws XNIException {
-
+
// when we reach the endElement of xs:appinfo or xs:documentation,
// change fInnerAnnotationDepth to -1
if(fAnnotationDepth > -1) {
if (fInnerAnnotationDepth == fDepth) {
fInnerAnnotationDepth = -1;
- schemaDOM.endAnnotationElement(element, false);
+ schemaDOM.endAnnotationElement(element);
schemaDOM.endElement();
} else if (fAnnotationDepth == fDepth) {
fAnnotationDepth = -1;
- schemaDOM.endAnnotationElement(element, true);
+ schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
schemaDOM.endElement();
} else { // inside a child of annotation
- schemaDOM.endAnnotationElement(element, false);
+ schemaDOM.endAnnotationElement(element);
}
} else { // not in an annotation at all
if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
@@ -368,21 +380,21 @@
boolean sawann = fSawAnnotation.pop();
if (value && !sawann) {
String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
- QName annQName = new QName(schemaPrefix, SchemaSymbols.ELT_ANNOTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_ANNOTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
- schemaDOM.startAnnotation(annQName, fEmptyAttr, fNamespaceContext);
- QName elemQName = new QName(schemaPrefix, SchemaSymbols.ELT_DOCUMENTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_DOCUMENTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
- schemaDOM.startAnnotationElement(elemQName, fEmptyAttr);
- schemaDOM.characters(new XMLString("SYNTHETIC_ANNOTATION".toCharArray(), 0, 20 ));
- schemaDOM.endSyntheticAnnotationElement(elemQName, false);
- schemaDOM.endSyntheticAnnotationElement(annQName, true);
+ final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
+ schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
+ final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
+ schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
+ schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
+ schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
+ schemaDOM.endSyntheticAnnotationElement(annRawName, true);
}
}
schemaDOM.endElement();
}
fDepth--;
-
+
}
-
+
/**
* @param attributes
* @return
@@ -391,16 +403,16 @@
final int length = attributes.getLength();
for (int i = 0; i < length; ++i) {
String uri = attributes.getURI(i);
- if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
+ if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
uri != NamespaceContext.XMLNS_URI &&
- !(uri == NamespaceContext.XML_URI &&
+ !(uri == NamespaceContext.XML_URI &&
attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
return true;
}
}
return false;
}
-
+
/**
* Ignorable whitespace. For this method to be called, the document
* source must have some way of determining that the text containing
@@ -408,10 +420,10 @@
* example, the validator can determine if a length of whitespace
* characters in the document are ignorable based on the element
* content model.
- *
+ *
* @param text The ignorable whitespace.
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -421,12 +433,12 @@
schemaDOM.characters(text);
}
}
-
+
/**
* The start of a CDATA section.
- *
+ *
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -436,12 +448,12 @@
schemaDOM.startAnnotationCDATA();
}
}
-
+
/**
* The end of a CDATA section.
- *
+ *
* @param augs Additional information that may include infoset augmentations
- *
+ *
* @exception XNIException
* Thrown by handler to signal an error.
*/
@@ -451,19 +463,19 @@
schemaDOM.endAnnotationCDATA();
}
}
-
-
+
+
//
// other methods
//
-
+
/**
* Returns the DOM document object.
*/
public Document getDocument() {
return schemaDOM;
}
-
+
/**
* Delegates to SchemaParsingConfig.setFeature
* @param featureId
@@ -472,7 +484,7 @@
public void setFeature(String featureId, boolean state){
config.setFeature(featureId, state);
}
-
+
/**
* Delegates to SchemaParsingConfig.getFeature
* @param featureId
@@ -481,7 +493,7 @@
public boolean getFeature(String featureId){
return config.getFeature(featureId);
}
-
+
/**
* Delegates to SchemaParsingConfig.setProperty.
* @param propertyId
@@ -490,7 +502,7 @@
public void setProperty(String propertyId, Object value){
config.setProperty(propertyId, value);
}
-
+
/**
* Delegates to SchemaParsingConfig.getProperty.
* @param propertyId
@@ -499,7 +511,7 @@
public Object getProperty(String propertyId){
return config.getProperty(propertyId);
}
-
+
/**
* Delegates to SchemaParsingConfig.setEntityResolver.
* @param er XMLEntityResolver
@@ -507,34 +519,34 @@
public void setEntityResolver(XMLEntityResolver er) {
config.setEntityResolver(er);
}
-
+
/**
* Delegates parsing to SchemaParsingConfig
- *
+ *
* @param inputSource
* @throws IOException
*/
public void parse(XMLInputSource inputSource) throws IOException {
config.parse(inputSource);
}
-
+
/**
* Reset SchemaParsingConfig
*/
public void reset() {
((SchemaParsingConfig)config).reset();
}
-
+
/**
* ResetNodePool on SchemaParsingConfig
*/
public void resetNodePool() {
((SchemaParsingConfig)config).resetNodePool();
}
-
+
/**
* A simple boolean based stack.
- *
+ *
* @xerces.internal
*/
private static final class BooleanStack {
@@ -548,11 +560,11 @@
/** Stack data. */
private boolean[] fData;
-
+
//
// Constructor
//
-
+
public BooleanStack () {}
//
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java Wed Sep 28 17:36:24 2011 +0100
@@ -54,7 +54,7 @@
*
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: SchemaParsingConfig.java,v 1.6 2010/07/23 02:09:29 joehw Exp $
+ * @version $Id: SchemaParsingConfig.java,v 1.8 2010-11-01 04:40:01 joehw Exp $
*/
public class SchemaParsingConfig extends BasicParserConfiguration
implements XMLPullParserConfiguration {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,425 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.xs.traversers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser;
+import com.sun.org.apache.xerces.internal.util.JAXPNamespaceContextWrapper;
+import com.sun.org.apache.xerces.internal.util.StAXLocationWrapper;
+import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
+import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xni.XMLString;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import org.w3c.dom.Document;
+
+/**
+ * StAXSchemaParser reads StAX events, converts them into XNI events
+ * and passes them directly to the SchemaDOMParser.
+ *
+ * @xerces.internal
+ *
+ * @version $Id: StAXSchemaParser.java,v 1.2 2010-10-26 23:01:12 joehw Exp $
+ */
+final class StAXSchemaParser {
+
+ /** Chunk size (1024). */
+ private static final int CHUNK_SIZE = (1 << 10);
+
+ /** Chunk mask (CHUNK_SIZE - 1). */
+ private static final int CHUNK_MASK = CHUNK_SIZE - 1;
+
+ /** Array for holding character data. **/
+ private final char [] fCharBuffer = new char[CHUNK_SIZE];
+
+ /** Symbol table **/
+ private SymbolTable fSymbolTable;
+
+ /** SchemaDOMParser, events will be delegated to SchemaDOMParser to pass */
+ private SchemaDOMParser fSchemaDOMParser;
+
+ /** XML Locator wrapper for SAX. **/
+ private final StAXLocationWrapper fLocationWrapper = new StAXLocationWrapper();
+
+ /** The namespace context of this document: stores namespaces in scope */
+ private final JAXPNamespaceContextWrapper fNamespaceContext = new JAXPNamespaceContextWrapper(fSymbolTable);
+
+ /** Fields for start element, end element and characters. */
+ private final QName fElementQName = new QName();
+ private final QName fAttributeQName = new QName();
+ private final XMLAttributesImpl fAttributes = new XMLAttributesImpl();
+ private final XMLString fTempString = new XMLString();
+ private final ArrayList fDeclaredPrefixes = new ArrayList();
+ private final XMLStringBuffer fStringBuffer = new XMLStringBuffer();
+ private int fDepth;
+
+ public StAXSchemaParser() {
+ fNamespaceContext.setDeclaredPrefixes(fDeclaredPrefixes);
+ }
+
+ public void reset(SchemaDOMParser schemaDOMParser, SymbolTable symbolTable) {
+ fSchemaDOMParser = schemaDOMParser;
+ fSymbolTable = symbolTable;
+ fNamespaceContext.setSymbolTable(fSymbolTable);
+ fNamespaceContext.reset();
+ }
+
+ public Document getDocument() {
+ return fSchemaDOMParser.getDocument();
+ }
+
+ public void parse(XMLEventReader input) throws XMLStreamException, XNIException {
+ XMLEvent currentEvent = input.peek();
+ if (currentEvent != null) {
+ int eventType = currentEvent.getEventType();
+ if (eventType != XMLStreamConstants.START_DOCUMENT &&
+ eventType != XMLStreamConstants.START_ELEMENT) {
+ throw new XMLStreamException();
+ }
+ fLocationWrapper.setLocation(currentEvent.getLocation());
+ fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null);
+ loop: while (input.hasNext()) {
+ currentEvent = input.nextEvent();
+ eventType = currentEvent.getEventType();
+ switch (eventType) {
+ case XMLStreamConstants.START_ELEMENT:
+ ++fDepth;
+ StartElement start = currentEvent.asStartElement();
+ fillQName(fElementQName, start.getName());
+ fLocationWrapper.setLocation(start.getLocation());
+ fNamespaceContext.setNamespaceContext(start.getNamespaceContext());
+ fillXMLAttributes(start);
+ fillDeclaredPrefixes(start);
+ addNamespaceDeclarations();
+ fNamespaceContext.pushContext();
+ fSchemaDOMParser.startElement(fElementQName, fAttributes, null);
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ EndElement end = currentEvent.asEndElement();
+ fillQName(fElementQName, end.getName());
+ fillDeclaredPrefixes(end);
+ fLocationWrapper.setLocation(end.getLocation());
+ fSchemaDOMParser.endElement(fElementQName, null);
+ fNamespaceContext.popContext();
+ --fDepth;
+ if (fDepth <= 0) {
+ break loop;
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false);
+ break;
+ case XMLStreamConstants.SPACE:
+ sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true);
+ break;
+ case XMLStreamConstants.CDATA:
+ fSchemaDOMParser.startCDATA(null);
+ sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false);
+ fSchemaDOMParser.endCDATA(null);
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ ProcessingInstruction pi = (ProcessingInstruction)currentEvent;
+ fillProcessingInstruction(pi.getData());
+ fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null);
+ break;
+ case XMLStreamConstants.DTD:
+ /* There shouldn't be a DTD in the schema */
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ /* Not needed for schemas */
+ break;
+ case XMLStreamConstants.COMMENT:
+ /* No point in sending comments */
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ fDepth++;
+ /* We automatically call startDocument before the loop */
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ /* We automatically call endDocument after the loop */
+ break;
+ }
+ }
+ fLocationWrapper.setLocation(null);
+ fNamespaceContext.setNamespaceContext(null);
+ fSchemaDOMParser.endDocument(null);
+ }
+ }
+
+ public void parse(XMLStreamReader input) throws XMLStreamException, XNIException {
+ if (input.hasNext()) {
+ int eventType = input.getEventType();
+ if (eventType != XMLStreamConstants.START_DOCUMENT &&
+ eventType != XMLStreamConstants.START_ELEMENT) {
+ throw new XMLStreamException();
+ }
+ fLocationWrapper.setLocation(input.getLocation());
+ fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null);
+ boolean first = true;
+ loop: while (input.hasNext()) {
+ if (!first) {
+ eventType = input.next();
+ }
+ else {
+ first = false;
+ }
+ switch (eventType) {
+ case XMLStreamConstants.START_ELEMENT:
+ ++fDepth;
+ fLocationWrapper.setLocation(input.getLocation());
+ fNamespaceContext.setNamespaceContext(input.getNamespaceContext());
+ fillQName(fElementQName, input.getNamespaceURI(),
+ input.getLocalName(), input.getPrefix());
+ fillXMLAttributes(input);
+ fillDeclaredPrefixes(input);
+ addNamespaceDeclarations();
+ fNamespaceContext.pushContext();
+ fSchemaDOMParser.startElement(fElementQName, fAttributes, null);
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ fLocationWrapper.setLocation(input.getLocation());
+ fNamespaceContext.setNamespaceContext(input.getNamespaceContext());
+ fillQName(fElementQName, input.getNamespaceURI(),
+ input.getLocalName(), input.getPrefix());
+ fillDeclaredPrefixes(input);
+ fSchemaDOMParser.endElement(fElementQName, null);
+ fNamespaceContext.popContext();
+ --fDepth;
+ if (fDepth <= 0) {
+ break loop;
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ fTempString.setValues(input.getTextCharacters(),
+ input.getTextStart(), input.getTextLength());
+ fSchemaDOMParser.characters(fTempString, null);
+ break;
+ case XMLStreamConstants.SPACE:
+ fTempString.setValues(input.getTextCharacters(),
+ input.getTextStart(), input.getTextLength());
+ fSchemaDOMParser.ignorableWhitespace(fTempString, null);
+ break;
+ case XMLStreamConstants.CDATA:
+ fSchemaDOMParser.startCDATA(null);
+ fTempString.setValues(input.getTextCharacters(),
+ input.getTextStart(), input.getTextLength());
+ fSchemaDOMParser.characters(fTempString, null);
+ fSchemaDOMParser.endCDATA(null);
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ fillProcessingInstruction(input.getPIData());
+ fSchemaDOMParser.processingInstruction(input.getPITarget(), fTempString, null);
+ break;
+ case XMLStreamConstants.DTD:
+ /* There shouldn't be a DTD in the schema */
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ /* Not needed for schemas */
+ break;
+ case XMLStreamConstants.COMMENT:
+ /* No point in sending comments */
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ ++fDepth;
+ /* We automatically call startDocument before the loop */
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ /* We automatically call endDocument after the loop */
+ break;
+ }
+ }
+ fLocationWrapper.setLocation(null);
+ fNamespaceContext.setNamespaceContext(null);
+ fSchemaDOMParser.endDocument(null);
+ }
+ }
+
+ /** Send characters to the validator in CHUNK_SIZE character chunks. */
+ private void sendCharactersToSchemaParser(String str, boolean whitespace) {
+ if (str != null) {
+ final int length = str.length();
+ final int remainder = length & CHUNK_MASK;
+ if (remainder > 0) {
+ str.getChars(0, remainder, fCharBuffer, 0);
+ fTempString.setValues(fCharBuffer, 0, remainder);
+ if (whitespace) {
+ fSchemaDOMParser.ignorableWhitespace(fTempString, null);
+ }
+ else {
+ fSchemaDOMParser.characters(fTempString, null);
+ }
+ }
+ int i = remainder;
+ while (i < length) {
+ str.getChars(i, i += CHUNK_SIZE, fCharBuffer, 0);
+ fTempString.setValues(fCharBuffer, 0, CHUNK_SIZE);
+ if (whitespace) {
+ fSchemaDOMParser.ignorableWhitespace(fTempString, null);
+ }
+ else {
+ fSchemaDOMParser.characters(fTempString, null);
+ }
+ }
+ }
+ }
+
+ // processing instructions must be sent all in one chunk
+ private void fillProcessingInstruction(String data) {
+ final int dataLength = data.length();
+ char [] charBuffer = fCharBuffer;
+ if (charBuffer.length < dataLength) {
+ // toCharArray() creates a newly allocated array, so it's okay
+ // to keep a reference to it.
+ charBuffer = data.toCharArray();
+ }
+ else {
+ data.getChars(0, dataLength, charBuffer, 0);
+ }
+ fTempString.setValues(charBuffer, 0, dataLength);
+ }
+
+ private void fillXMLAttributes(StartElement event) {
+ fAttributes.removeAllAttributes();
+ final Iterator attrs = event.getAttributes();
+ while (attrs.hasNext()) {
+ Attribute attr = (Attribute) attrs.next();
+ fillQName(fAttributeQName, attr.getName());
+ String type = attr.getDTDType();
+ int idx = fAttributes.getLength();
+ fAttributes.addAttributeNS(fAttributeQName,
+ (type != null) ? type : XMLSymbols.fCDATASymbol, attr.getValue());
+ fAttributes.setSpecified(idx, attr.isSpecified());
+ }
+ }
+
+ private void fillXMLAttributes(XMLStreamReader input) {
+ fAttributes.removeAllAttributes();
+ final int len = input.getAttributeCount();
+ for (int i = 0; i < len; ++i) {
+ fillQName(fAttributeQName, input.getAttributeNamespace(i),
+ input.getAttributeLocalName(i), input.getAttributePrefix(i));
+ String type = input.getAttributeType(i);
+ fAttributes.addAttributeNS(fAttributeQName,
+ (type != null) ? type : XMLSymbols.fCDATASymbol, input.getAttributeValue(i));
+ fAttributes.setSpecified(i, input.isAttributeSpecified(i));
+ }
+ }
+
+ private void addNamespaceDeclarations() {
+ String prefix = null;
+ String localpart = null;
+ String rawname = null;
+ String nsPrefix = null;
+ String nsURI = null;
+
+ final Iterator iter = fDeclaredPrefixes.iterator();
+ while (iter.hasNext()) {
+ nsPrefix = (String) iter.next();
+ nsURI = fNamespaceContext.getURI(nsPrefix);
+ if (nsPrefix.length() > 0) {
+ prefix = XMLSymbols.PREFIX_XMLNS;
+ localpart = nsPrefix;
+ fStringBuffer.clear();
+ fStringBuffer.append(prefix);
+ fStringBuffer.append(':');
+ fStringBuffer.append(localpart);
+ rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
+ }
+ else {
+ prefix = XMLSymbols.EMPTY_STRING;
+ localpart = XMLSymbols.PREFIX_XMLNS;
+ rawname = XMLSymbols.PREFIX_XMLNS;
+ }
+ fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
+ fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol,
+ (nsURI != null) ? nsURI : XMLSymbols.EMPTY_STRING);
+ }
+ }
+
+ /** Fills in the list of declared prefixes. */
+ private void fillDeclaredPrefixes(StartElement event) {
+ fillDeclaredPrefixes(event.getNamespaces());
+ }
+
+ /** Fills in the list of declared prefixes. */
+ private void fillDeclaredPrefixes(EndElement event) {
+ fillDeclaredPrefixes(event.getNamespaces());
+ }
+
+ /** Fills in the list of declared prefixes. */
+ private void fillDeclaredPrefixes(Iterator namespaces) {
+ fDeclaredPrefixes.clear();
+ while (namespaces.hasNext()) {
+ Namespace ns = (Namespace) namespaces.next();
+ String prefix = ns.getPrefix();
+ fDeclaredPrefixes.add(prefix != null ? prefix : "");
+ }
+ }
+
+ /** Fills in the list of declared prefixes. */
+ private void fillDeclaredPrefixes(XMLStreamReader reader) {
+ fDeclaredPrefixes.clear();
+ final int len = reader.getNamespaceCount();
+ for (int i = 0; i < len; ++i) {
+ String prefix = reader.getNamespacePrefix(i);
+ fDeclaredPrefixes.add(prefix != null ? prefix : "");
+ }
+ }
+
+ /** Fills in a QName object. */
+ private void fillQName(QName toFill, javax.xml.namespace.QName toCopy) {
+ fillQName(toFill, toCopy.getNamespaceURI(), toCopy.getLocalPart(), toCopy.getPrefix());
+ }
+
+ /** Fills in a QName object. */
+ final void fillQName(QName toFill, String uri, String localpart, String prefix) {
+ uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
+ localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
+ prefix = (prefix != null && prefix.length() > 0) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
+ String raw = localpart;
+ if (prefix != XMLSymbols.EMPTY_STRING) {
+ fStringBuffer.clear();
+ fStringBuffer.append(prefix);
+ fStringBuffer.append(':');
+ fStringBuffer.append(localpart);
+ raw = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
+ }
+ toFill.setValues(prefix, localpart, raw, uri);
+ }
+
+} // StAXSchemaParser
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,8 +20,9 @@
package com.sun.org.apache.xerces.internal.impl.xs.traversers;
-import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -37,6 +38,7 @@
import com.sun.org.apache.xerces.internal.impl.xs.util.XIntPool;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
@@ -65,7 +67,7 @@
* @xerces.internal
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.9 2007/07/29 20:47:06 joehw Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.12 2010-11-01 04:40:02 joehw Exp $
*/
public class XSAttributeChecker {
@@ -455,7 +457,6 @@
// step 4: for each element, make a list of possible attributes
Container attrList;
- OneElement oneEle;
// for element "attribute" - global
attrList = Container.getContainer(5);
@@ -469,8 +470,7 @@
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
// type = QName
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, attrList);
// for element "attribute" - local name
attrList = Container.getContainer(7);
@@ -488,8 +488,7 @@
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
// use = (optional | prohibited | required) : optional
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(ATTRIBUTE_N, oneEle);
+ fEleAttrsMapL.put(ATTRIBUTE_N, attrList);
// for element "attribute" - local ref
attrList = Container.getContainer(5);
@@ -503,14 +502,13 @@
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
// use = (optional | prohibited | required) : optional
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(ATTRIBUTE_R, oneEle);
+ fEleAttrsMapL.put(ATTRIBUTE_R, attrList);
// for element "element" - global
attrList = Container.getContainer(10);
// abstract = boolean : false
attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]);
- // block = (#all | List of (substitution | extension | restriction | list | union))
+ // block = (#all | List of (extension | restriction | substitution))
attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
// default = string
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
@@ -528,12 +526,11 @@
attrList.put(SchemaSymbols.ATT_SUBSTITUTIONGROUP, allAttrs[ATT_SUBSTITUTION_G_N]);
// type = QName
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_ELEMENT, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_ELEMENT, attrList);
// for element "element" - local name
attrList = Container.getContainer(10);
- // block = (#all | List of (substitution | extension | restriction | list | union))
+ // block = (#all | List of (extension | restriction | substitution))
attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
// default = string
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
@@ -553,8 +550,7 @@
attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]);
// type = QName
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(ELEMENT_N, oneEle);
+ fEleAttrsMapL.put(ELEMENT_N, attrList);
// for element "element" - local ref
attrList = Container.getContainer(4);
@@ -566,8 +562,7 @@
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
// ref = QName
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(ELEMENT_R, oneEle);
+ fEleAttrsMapL.put(ELEMENT_R, attrList);
// for element "complexType" - global
attrList = Container.getContainer(6);
@@ -583,8 +578,7 @@
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
// name = NCName
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_COMPLEXTYPE, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_COMPLEXTYPE, attrList);
// for element "notation" - global
attrList = Container.getContainer(4);
@@ -596,8 +590,7 @@
attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
// system = anyURI
attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_NOTATION, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_NOTATION, attrList);
// for element "complexType" - local
@@ -606,15 +599,13 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// mixed = boolean : false
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXTYPE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXTYPE, attrList);
// for element "simpleContent" - local
attrList = Container.getContainer(1);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLECONTENT, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLECONTENT, attrList);
// for element "restriction" - local
attrList = Container.getContainer(2);
@@ -622,8 +613,7 @@
attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_N]);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_RESTRICTION, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_RESTRICTION, attrList);
// for element "extension" - local
attrList = Container.getContainer(2);
@@ -631,8 +621,7 @@
attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_R]);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_EXTENSION, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_EXTENSION, attrList);
// for element "attributeGroup" - local ref
attrList = Container.getContainer(2);
@@ -640,8 +629,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// ref = QName
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, attrList);
// for element "anyAttribute" - local
attrList = Container.getContainer(3);
@@ -651,8 +639,7 @@
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
// processContents = (lax | skip | strict) : strict
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, attrList);
// for element "complexContent" - local
attrList = Container.getContainer(2);
@@ -660,8 +647,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// mixed = boolean
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXCONTENT, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXCONTENT, attrList);
// for element "attributeGroup" - global
attrList = Container.getContainer(2);
@@ -669,8 +655,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// name = NCName
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, attrList);
// for element "group" - global
attrList = Container.getContainer(2);
@@ -678,8 +663,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// name = NCName
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_GROUP, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_GROUP, attrList);
// for element "group" - local ref
attrList = Container.getContainer(4);
@@ -691,8 +675,7 @@
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
// ref = QName
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_GROUP, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_GROUP, attrList);
// for element "all" - local
attrList = Container.getContainer(3);
@@ -702,8 +685,7 @@
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS1_D]);
// minOccurs = (0 | 1) : 1
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS1_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_ALL, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ALL, attrList);
// for element "choice" - local
attrList = Container.getContainer(3);
@@ -713,10 +695,9 @@
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
// minOccurs = nonNegativeInteger : 1
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_CHOICE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_CHOICE, attrList);
// for element "sequence" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_SEQUENCE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_SEQUENCE, attrList);
// for element "any" - local
attrList = Container.getContainer(5);
@@ -730,8 +711,7 @@
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
// processContents = (lax | skip | strict) : strict
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_ANY, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ANY, attrList);
// for element "unique" - local
attrList = Container.getContainer(2);
@@ -739,10 +719,9 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// name = NCName
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_UNIQUE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_UNIQUE, attrList);
// for element "key" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_KEY, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_KEY, attrList);
// for element "keyref" - local
attrList = Container.getContainer(3);
@@ -752,8 +731,7 @@
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
// refer = QName
attrList.put(SchemaSymbols.ATT_REFER, allAttrs[ATT_REFER_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_KEYREF, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_KEYREF, attrList);
// for element "selector" - local
attrList = Container.getContainer(2);
@@ -761,8 +739,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// xpath = a subset of XPath expression
attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_SELECTOR, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_SELECTOR, attrList);
// for element "field" - local
attrList = Container.getContainer(2);
@@ -770,25 +747,22 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// xpath = a subset of XPath expression
attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH1_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_FIELD, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_FIELD, attrList);
// for element "annotation" - global
attrList = Container.getContainer(1);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_ANNOTATION, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_ANNOTATION, attrList);
// for element "annotation" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_ANNOTATION, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ANNOTATION, attrList);
// for element "appinfo" - local
attrList = Container.getContainer(1);
// source = anyURI
attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_APPINFO, oneEle);
- fEleAttrsMapL.put(SchemaSymbols.ELT_APPINFO, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_APPINFO, attrList);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_APPINFO, attrList);
// for element "documentation" - local
attrList = Container.getContainer(2);
@@ -796,9 +770,8 @@
attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
// xml:lang = language
attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_DOCUMENTATION, oneEle);
- fEleAttrsMapL.put(SchemaSymbols.ELT_DOCUMENTATION, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_DOCUMENTATION, attrList);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_DOCUMENTATION, attrList);
// for element "simpleType" - global
attrList = Container.getContainer(3);
@@ -808,8 +781,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// name = NCName
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_SIMPLETYPE, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_SIMPLETYPE, attrList);
// for element "simpleType" - local
attrList = Container.getContainer(2);
@@ -817,8 +789,7 @@
attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLETYPE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLETYPE, attrList);
// for element "restriction" - local
// already registered for complexType
@@ -829,8 +800,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// itemType = QName
attrList.put(SchemaSymbols.ATT_ITEMTYPE, allAttrs[ATT_ITEMTYPE_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_LIST, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_LIST, attrList);
// for element "union" - local
attrList = Container.getContainer(2);
@@ -838,14 +808,13 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// memberTypes = List of QName
attrList.put(SchemaSymbols.ATT_MEMBERTYPES, allAttrs[ATT_MEMBER_T_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_UNION, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_UNION, attrList);
// for element "schema" - global
attrList = Container.getContainer(8);
// attributeFormDefault = (qualified | unqualified) : unqualified
attrList.put(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, allAttrs[ATT_ATTRIBUTE_FD_D]);
- // blockDefault = (#all | List of (substitution | extension | restriction | list | union)) : ''
+ // blockDefault = (#all | List of (extension | restriction | substitution)) : ''
attrList.put(SchemaSymbols.ATT_BLOCKDEFAULT, allAttrs[ATT_BLOCK_D_D]);
// elementFormDefault = (qualified | unqualified) : unqualified
attrList.put(SchemaSymbols.ATT_ELEMENTFORMDEFAULT, allAttrs[ATT_ELEMENT_FD_D]);
@@ -859,8 +828,7 @@
attrList.put(SchemaSymbols.ATT_VERSION, allAttrs[ATT_VERSION_N]);
// xml:lang = language
attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_SCHEMA, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_SCHEMA, attrList);
// for element "include" - global
attrList = Container.getContainer(2);
@@ -868,10 +836,9 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// schemaLocation = anyURI
attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_R]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_INCLUDE, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_INCLUDE, attrList);
// for element "redefine" - global
- fEleAttrsMapG.put(SchemaSymbols.ELT_REDEFINE, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_REDEFINE, attrList);
// for element "import" - global
attrList = Container.getContainer(3);
@@ -881,8 +848,7 @@
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_N]);
// schemaLocation = anyURI
attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapG.put(SchemaSymbols.ELT_IMPORT, oneEle);
+ fEleAttrsMapG.put(SchemaSymbols.ELT_IMPORT, attrList);
// for element "length" - local
attrList = Container.getContainer(3);
@@ -892,14 +858,13 @@
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_NNI_N]);
// fixed = boolean : false
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_LENGTH, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_LENGTH, attrList);
// for element "minLength" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_MINLENGTH, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MINLENGTH, attrList);
// for element "maxLength" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_MAXLENGTH, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MAXLENGTH, attrList);
// for element "fractionDigits" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_FRACTIONDIGITS, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_FRACTIONDIGITS, attrList);
// for element "totalDigits" - local
attrList = Container.getContainer(3);
@@ -909,8 +874,7 @@
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_PI_N]);
// fixed = boolean : false
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_TOTALDIGITS, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_TOTALDIGITS, attrList);
// for element "pattern" - local
attrList = Container.getContainer(2);
@@ -918,8 +882,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// value = string
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_PATTERN, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_PATTERN, attrList);
// for element "enumeration" - local
attrList = Container.getContainer(2);
@@ -927,8 +890,7 @@
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
// value = anySimpleType
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_ENUMERATION, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_ENUMERATION, attrList);
// for element "whiteSpace" - local
attrList = Container.getContainer(3);
@@ -938,8 +900,7 @@
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_WS_N]);
// fixed = boolean : false
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_WHITESPACE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_WHITESPACE, attrList);
// for element "maxInclusive" - local
attrList = Container.getContainer(3);
@@ -949,14 +910,13 @@
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
// fixed = boolean : false
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
- oneEle = new OneElement (attrList);
- fEleAttrsMapL.put(SchemaSymbols.ELT_MAXINCLUSIVE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MAXINCLUSIVE, attrList);
// for element "maxExclusive" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_MAXEXCLUSIVE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MAXEXCLUSIVE, attrList);
// for element "minInclusive" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_MININCLUSIVE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MININCLUSIVE, attrList);
// for element "minExclusive" - local
- fEleAttrsMapL.put(SchemaSymbols.ELT_MINEXCLUSIVE, oneEle);
+ fEleAttrsMapL.put(SchemaSymbols.ELT_MINEXCLUSIVE, attrList);
}
// used to resolver namespace prefixes
@@ -1055,8 +1015,8 @@
}
// get desired attribute list of this element
- OneElement oneEle = (OneElement)eleAttrsMap.get(lookupName);
- if (oneEle == null) {
+ Container attrList = (Container)eleAttrsMap.get(lookupName);
+ if (attrList == null) {
// should never gets here.
// when this method is called, the call already knows that
// the element can appear.
@@ -1068,7 +1028,6 @@
Object[] attrValues = getAvailableArray();
//Hashtable otherValues = new Hashtable();
long fromDefault = 0;
- Container attrList = oneEle.attrList;
// clear the "seen" flag.
System.arraycopy(fSeenTemp, 0, fSeen, 0, ATTIDX_COUNT);
@@ -1083,7 +1042,7 @@
String attrName = sattr.getName();
String attrURI = DOMUtil.getNamespaceURI(sattr);
String attrVal = DOMUtil.getValue(sattr);
-
+
if (attrName.startsWith("xml")) {
String attrPrefix = DOMUtil.getPrefix(sattr);
// we don't want to add namespace declarations to the non-schema attributes
@@ -1105,8 +1064,7 @@
if (attrURI != null && attrURI.length() != 0) {
// attributes with schema namespace are not allowed
// and not allowed on "document" and "appInfo"
- if (attrURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) ||
- !oneEle.allowNonSchemaAttr) {
+ if (attrURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) {
reportSchemaError ("s4s-att-not-allowed", new Object[] {elName, attrName}, element);
}
else {
@@ -1139,7 +1097,7 @@
}
// check whether this attribute is allowed
- OneAttr oneAttr = (OneAttr)attrList.get(attrName);
+ OneAttr oneAttr = attrList.get(attrName);
if (oneAttr == null) {
reportSchemaError ("s4s-att-not-allowed",
new Object[] {elName, attrName},
@@ -1192,7 +1150,7 @@
}
// apply default values
- OneAttr[] reqAttrs = oneEle.attrList.values;
+ OneAttr[] reqAttrs = attrList.values;
for (int i = 0; i < reqAttrs.length; i++) {
OneAttr oneAttr = reqAttrs[i];
@@ -1214,7 +1172,7 @@
int min = ((XInt)attrValues[ATTIDX_MINOCCURS]).intValue();
int max = ((XInt)attrValues[ATTIDX_MAXOCCURS]).intValue();
if (max != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
-
+
// maxOccurLimit is only check in secure mode
if (fSchemaHandler.fSecureProcessing != null) {
String localName = element.getLocalName();
@@ -1224,10 +1182,10 @@
// particle. These are now validated using a constant
// space algorithm. The restriction still applies to all
// other cases.
-
+
// Determine if constant-space algorithm can be applied
- final boolean optimize =
- (localName.equals("element") || localName.equals("any")) &&
+ final boolean optimize =
+ (localName.equals("element") || localName.equals("any")) &&
(element.getNextSibling() == null) &&
(element.getPreviousSibling() == null) &&
(element.getParentNode().getLocalName().equals("sequence"));
@@ -1238,15 +1196,15 @@
int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getMaxOccurNodeLimit();
if (max > maxOccurNodeLimit) {
reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
-
+
// reset max values in case processing continues on error
attrValues[ATTIDX_MAXOCCURS] = fXIntPool.getXInt(maxOccurNodeLimit);
//new Integer(maxOccurNodeLimit);
max = maxOccurNodeLimit;
- }
+ }
}
}
-
+
if (min > max) {
reportSchemaError ("p-props-correct.2.1",
new Object[] {elName, attrValues[ATTIDX_MINOCCURS], attrValues[ATTIDX_MAXOCCURS]},
@@ -1267,15 +1225,9 @@
// To validate these types, we don't actually need to normalize the
// strings. We only need to remove the whitespace from both ends.
// In some special cases (list types), StringTokenizer can correctly
- // process the un-normalized whitespace.
- /**
- * REVISIT: Trim removes all leading and trailing characters less
- * than or equal to U+0020. This is okay for XML 1.0 since all
- * of the valid characters in that range are white space but
- * in XML 1.1 control chars are allowed. We shouldn't be trimming
- * those. -- mrglavas
- */
- String value = ivalue.trim();
+ // process the un-normalized whitespace.
+
+ String value = XMLChar.trim(ivalue);
Object retValue = null;
Vector memberType;
int choice;
@@ -1315,35 +1267,28 @@
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "positiveInteger"});
break;
case DT_BLOCK:
- // block = (#all | List of (substitution | extension | restriction))
+ // block = (#all | List of (extension | restriction | substitution))
choice = 0;
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
XSConstants.DERIVATION_RESTRICTION;
}
else {
- // use the default \t\r\n\f delimiters
- StringTokenizer t = new StringTokenizer(value);
+ StringTokenizer t = new StringTokenizer(value, " \n\t\r");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
- if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) {
- choice |= XSConstants.DERIVATION_SUBSTITUTION;
- }
- else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
+ if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
choice |= XSConstants.DERIVATION_EXTENSION;
}
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
choice |= XSConstants.DERIVATION_RESTRICTION;
}
- else if (token.equals (SchemaSymbols.ATTVAL_LIST)) {
- choice |= XSConstants.DERIVATION_LIST;
- }
- else if (token.equals (SchemaSymbols.ATTVAL_UNION)) {
- choice |= XSConstants.DERIVATION_UNION;
+ else if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) {
+ choice |= XSConstants.DERIVATION_SUBSTITUTION;
}
else {
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (substitution | extension | restriction | list | union))"});
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (extension | restriction | substitution))"});
}
}
}
@@ -1371,8 +1316,7 @@
XSConstants.DERIVATION_UNION;
}
else {
- // use the default \t\r\n\f delimiters
- StringTokenizer t = new StringTokenizer(value);
+ StringTokenizer t = new StringTokenizer(value, " \n\t\r");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
@@ -1404,8 +1348,7 @@
XSConstants.DERIVATION_UNION;
}
else {
- // use the default \t\r\n\f delimiters
- StringTokenizer t = new StringTokenizer(value);
+ StringTokenizer t = new StringTokenizer(value, " \n\t\r");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
@@ -1440,8 +1383,7 @@
XSConstants.DERIVATION_UNION;
}
else {
- // use the default \t\r\n\f delimiters
- StringTokenizer t = new StringTokenizer(value);
+ StringTokenizer t = new StringTokenizer(value, " \n\t\r");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
@@ -1498,8 +1440,7 @@
// memberTypes = List of QName
memberType = new Vector();
try {
- // use the default \t\r\n\f delimiters
- StringTokenizer t = new StringTokenizer(value);
+ StringTokenizer t = new StringTokenizer(value, " \n\t\r");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
QName qname = (QName)fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext, null);
@@ -1543,8 +1484,7 @@
fNamespaceList.removeAllElements();
// tokenize
- // use the default \t\r\n\f delimiters
- StringTokenizer tokens = new StringTokenizer(value);
+ StringTokenizer tokens = new StringTokenizer(value, " \n\t\r");
String token;
String tempNamespace;
try {
@@ -1621,7 +1561,7 @@
void reportSchemaFatalError (String key, Object[] args, Element ele) {
fSchemaHandler.reportSchemaFatalError(key, args, ele);
}
-
+
void reportSchemaError (String key, Object[] args, Element ele) {
fSchemaHandler.reportSchemaError(key, args, ele);
}
@@ -1632,28 +1572,32 @@
// REVISIT: pass the proper element node to reportSchemaError
public void checkNonSchemaAttributes(XSGrammarBucket grammarBucket) {
// for all attributes
- Enumeration keys = fNonSchemaAttrs.keys();
+ Iterator entries = fNonSchemaAttrs.entrySet().iterator();
XSAttributeDecl attrDecl;
- while (keys.hasMoreElements()) {
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
// get name, uri, localpart
- String attrRName = (String)keys.nextElement();
+ String attrRName = (String) entry.getKey();
String attrURI = attrRName.substring(0,attrRName.indexOf(','));
String attrLocal = attrRName.substring(attrRName.indexOf(',')+1);
// find associated grammar
SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI);
- if (sGrammar == null)
+ if (sGrammar == null) {
continue;
+ }
// and get the datatype validator, if there is one
attrDecl = sGrammar.getGlobalAttributeDecl(attrLocal);
- if (attrDecl == null)
+ if (attrDecl == null) {
continue;
+ }
XSSimpleType dv = (XSSimpleType)attrDecl.getTypeDefinition();
- if (dv == null)
+ if (dv == null) {
continue;
+ }
// get all values appeared with this attribute name
- Vector values = (Vector)fNonSchemaAttrs.get(attrRName);
- String elName, attrVal;
+ Vector values = (Vector) entry.getValue();
+ String elName;
String attrName = (String)values.elementAt(0);
// for each of the values
int count = values.size();
@@ -1828,22 +1772,6 @@
}
}
-class OneElement {
- // the list of attributes that can appear in one element
- public Container attrList;
- // does this element allow attributes from non-schema namespace
- public boolean allowNonSchemaAttr;
-
- public OneElement (Container attrList) {
- this(attrList, true);
- }
-
- public OneElement (Container attrList, boolean allowNonSchemaAttr) {
- this.attrList = attrList;
- this.allowNonSchemaAttr = allowNonSchemaAttr;
- }
-}
-
abstract class Container {
static final int THRESHOLD = 5;
static Container getContainer(int size) {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,6 +26,7 @@
import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
import com.sun.org.apache.xerces.internal.impl.xs.identity.Selector;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
import org.w3c.dom.Element;
/**
@@ -33,8 +34,9 @@
* traversers (the XSDUniqueTraverser, XSDKeyTraverser and
* XSDKeyrefTraverser) rely upon.
*
- * @xerces.internal
+ * @xerces.internal
*
+ * @version $Id: XSDAbstractIDConstraintTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDAbstractIDConstraintTraverser extends XSDAbstractTraverser {
@@ -43,7 +45,7 @@
super(handler, gAttrCheck);
}
- void traverseIdentityConstraint(IdentityConstraint ic,
+ boolean traverseIdentityConstraint(IdentityConstraint ic,
Element icElem, XSDocumentInfo schemaDoc, Object [] icElemAttrs) {
// General Attribute Checking will have been done on icElem by caller
@@ -54,7 +56,7 @@
reportSchemaError("s4s-elt-must-match.2",
new Object[]{"identity constraint", "(annotation?, selector, field+)"},
icElem);
- return;
+ return false;
}
// General Attribute Checking on sElem
@@ -65,7 +67,7 @@
// if no more children report an error
if(sElem == null) {
reportSchemaError("s4s-elt-must-match.2", new Object[]{"identity constraint", "(annotation?, selector, field+)"}, icElem);
- return;
+ return false;
}
}
else {
@@ -75,13 +77,14 @@
}
}
+ // must be
+ if(!DOMUtil.getLocalName(sElem).equals(SchemaSymbols.ELT_SELECTOR)) {
+ reportSchemaError("s4s-elt-must-match.1", new Object[]{"identity constraint", "(annotation?, selector, field+)", SchemaSymbols.ELT_SELECTOR}, sElem);
+ return false;
+ }
Object [] attrValues = fAttrChecker.checkAttributes(sElem, false, schemaDoc);
- // if more than one annotation report an error
- if(!DOMUtil.getLocalName(sElem).equals(SchemaSymbols.ELT_SELECTOR)) {
- reportSchemaError("s4s-elt-must-match.1", new Object[]{"identity constraint", "(annotation?, selector, field+)", SchemaSymbols.ELT_SELECTOR}, sElem);
- }
- // and make sure 's content is fine:
+ // make sure 's content is fine:
Element selChild = DOMUtil.getFirstChildElement(sElem);
if (selChild !=null) {
@@ -107,9 +110,9 @@
String sText = ((String)attrValues[XSAttributeChecker.ATTIDX_XPATH]);
if(sText == null) {
reportSchemaError("s4s-att-must-appear", new Object [] {SchemaSymbols.ELT_SELECTOR, SchemaSymbols.ATT_XPATH}, sElem);
- return;
+ return false;
}
- sText = sText.trim();
+ sText = XMLChar.trim(sText);
Selector.XPath sXpath = null;
try {
@@ -122,7 +125,7 @@
reportSchemaError(e.getKey(), new Object[]{sText}, sElem);
// put back attr values...
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
- return;
+ return false;
}
// put back attr values...
@@ -132,14 +135,18 @@
Element fElem = DOMUtil.getNextSiblingElement(sElem);
if(fElem == null) {
reportSchemaError("s4s-elt-must-match.2", new Object[]{"identity constraint", "(annotation?, selector, field+)"}, sElem);
+ return false;
}
while (fElem != null) {
+ if(!DOMUtil.getLocalName(fElem).equals(SchemaSymbols.ELT_FIELD)) {
+ reportSchemaError("s4s-elt-must-match.1", new Object[]{"identity constraint", "(annotation?, selector, field+)", SchemaSymbols.ELT_FIELD}, fElem);
+ fElem = DOMUtil.getNextSiblingElement(fElem);
+ continue;
+ }
+
// General Attribute Checking
attrValues = fAttrChecker.checkAttributes(fElem, false, schemaDoc);
- if(!DOMUtil.getLocalName(fElem).equals(SchemaSymbols.ELT_FIELD))
- reportSchemaError("s4s-elt-must-match.1", new Object[]{"identity constraint", "(annotation?, selector, field+)", SchemaSymbols.ELT_FIELD}, fElem);
-
// and make sure 's content is fine:
Element fieldChild = DOMUtil.getFirstChildElement(fElem);
if (fieldChild != null) {
@@ -159,11 +166,12 @@
}
}
String fText = ((String)attrValues[XSAttributeChecker.ATTIDX_XPATH]);
- if(fText == null) {
+ if (fText == null) {
reportSchemaError("s4s-att-must-appear", new Object [] {SchemaSymbols.ELT_FIELD, SchemaSymbols.ATT_XPATH}, fElem);
- return;
+ fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+ return false;
}
- fText = fText.trim();
+ fText = XMLChar.trim(fText);
try {
Field.XPath fXpath = new Field.XPath(fText, fSymbolTable,
schemaDoc.fNamespaceSupport);
@@ -174,12 +182,14 @@
reportSchemaError(e.getKey(), new Object[]{fText}, fElem);
// put back attr values...
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
- return;
+ return false;
}
fElem = DOMUtil.getNextSiblingElement(fElem);
// put back attr values...
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
}
+ return ic.getFieldCount() > 0;
} // traverseIdentityConstraint(IdentityConstraint,Element, XSDocumentInfo)
} // XSDAbstractIDConstraintTraverser
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,15 +26,18 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl;
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.xs.XSObject;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import org.w3c.dom.Element;
/**
- * @xerces.internal
- *
+ * @xerces.internal
+ *
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
+ * @version $Id: XSDAbstractParticleTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser {
@@ -47,12 +50,12 @@
*
* Traverse the "All" declaration
*
- *
+ * minOccurs = (0 | 1) : 1>
* Content: (annotation? , element*)
- *
+ * </all>
**/
XSParticleDecl traverseAll(Element allDecl,
XSDocumentInfo schemaDoc,
@@ -108,12 +111,20 @@
group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
group.fParticleCount = fPArray.getParticleCount();
group.fParticles = fPArray.popContext();
- group.fAnnotation = annotation;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)annotations).addXSObject (annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ group.fAnnotations = annotations;
particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fMinOccurs = minAtt.intValue();
particle.fMaxOccurs = maxAtt.intValue();
particle.fValue = group;
+ particle.fAnnotations = annotations;
particle = checkOccurrences(particle,
SchemaSymbols.ELT_ALL,
@@ -205,7 +216,6 @@
}
}
- boolean hadContent = false;
String childName = null;
XSParticleDecl particle;
fPArray.pushContext();
@@ -265,12 +275,20 @@
group.fCompositor = choice ? XSModelGroupImpl.MODELGROUP_CHOICE : XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = fPArray.getParticleCount();
group.fParticles = fPArray.popContext();
- group.fAnnotation = annotation;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)annotations).addXSObject (annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ group.fAnnotations = annotations;
particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fMinOccurs = minAtt.intValue();
particle.fMaxOccurs = maxAtt.intValue();
particle.fValue = group;
+ particle.fAnnotations = annotations;
particle = checkOccurrences(particle,
choice ? SchemaSymbols.ELT_CHOICE : SchemaSymbols.ELT_SEQUENCE,
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -36,17 +36,16 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSWildcardDecl;
-import com.sun.org.apache.xerces.internal.xs.XSObjectList;
-import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
+import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* Class XSDAbstractTraverser
serves as the base class for all
@@ -59,12 +58,12 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Neeraj Bajaj, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.6 2010/07/23 02:09:30 joehw Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $
*/
abstract class XSDAbstractTraverser {
-
+
protected static final String NO_NAME = "(no name)";
-
+
// Flags for checkOccurrences to indicate any special
// restrictions on minOccurs and maxOccurs relating to "all".
// NOT_ALL_CONTEXT - not processing an
@@ -72,28 +71,28 @@
// GROUP_REF_WITH_ALL - processing reference that contained
// CHILD_OF_GROUP - processing a child of a model group definition
// PROCESSING_ALL_GP - processing an group itself
-
+
protected static final int NOT_ALL_CONTEXT = 0;
protected static final int PROCESSING_ALL_EL = 1;
protected static final int GROUP_REF_WITH_ALL = 2;
protected static final int CHILD_OF_GROUP = 4;
protected static final int PROCESSING_ALL_GP = 8;
-
+
//Shared data
protected XSDHandler fSchemaHandler = null;
protected SymbolTable fSymbolTable = null;
protected XSAttributeChecker fAttrChecker = null;
protected boolean fValidateAnnotations = false;
-
+
// used to validate default/fixed attribute values
ValidationState fValidationState = new ValidationState();
-
+
XSDAbstractTraverser (XSDHandler handler,
XSAttributeChecker attrChecker) {
fSchemaHandler = handler;
fAttrChecker = attrChecker;
}
-
+
void reset(SymbolTable symbolTable, boolean validateAnnotations, Locale locale) {
fSymbolTable = symbolTable;
fValidateAnnotations = validateAnnotations;
@@ -101,7 +100,7 @@
fValidationState.setSymbolTable(symbolTable);
fValidationState.setLocale(locale);
}
-
+
// traverse the annotation declaration
// REVISIT: how to pass the parentAttrs? as DOM attributes?
// as name/value pairs (string)? in parsed form?
@@ -111,51 +110,35 @@
// General Attribute Checking
Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
-
- String contents = null;
+
+ String contents = DOMUtil.getAnnotation(annotationDecl);
Element child = DOMUtil.getFirstChildElement(annotationDecl);
if (child != null) {
do {
String name = DOMUtil.getLocalName(child);
-
+
// the only valid children of "annotation" are
// "appinfo" and "documentation"
if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
(name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
reportSchemaError("src-annotation", new Object[]{name}, child);
- } else { // the annotation, as we currently know it, is a Text child
- Node textContent = child.getFirstChild();
- if(textContent != null && textContent.getNodeType() == Node.TEXT_NODE) {
- contents = ((Text)textContent).getData();
- }
}
-
- // General Attribute Checking
- // There is no difference between global or local appinfo/documentation,
- // so we assume it's always global.
- attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
- fAttrChecker.returnAttrArray(attrValues, schemaDoc);
-
+ else {
+ // General Attribute Checking
+ // There is no difference between global or local appinfo/documentation,
+ // so we assume it's always global.
+ attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
+ fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+ }
+
child = DOMUtil.getNextSiblingElement(child);
}
while (child != null);
}
- // REVISIT: When an annotation has no or
- // children the text child is stored on the first child of its
- // parent. Only if the annotation is the first child will we find the
- // text node there. See SchemaDOM. We need to store the string representation
- // in a consistent place so it can be reliably retrieved, perhaps as
- // user data. -- mrglavas
- else {
- Node textContent = annotationDecl.getFirstChild();
- if(textContent != null && textContent.getNodeType() == Node.TEXT_NODE) {
- contents = ((Text)textContent).getData();
- }
- }
// if contents was null, must have been some kind of error;
// nothing to contribute to PSVI
if (contents == null) return null;
-
+
// find the grammar; fSchemaHandler must be known!
SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
// fish out local attributes passed from parent
@@ -178,15 +161,15 @@
prefix = rawname.substring(0,colonIndex);
localpart = rawname.substring(colonIndex+1);
}
- String uri = schemaDoc.fNamespaceSupport.getURI(prefix.intern());
- if (!annotationDecl.getAttributeNS(uri, localpart).equals("")) {
+ String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
+ if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
i++; // skip the next value, too
continue;
}
localStrBuffer.append(rawname)
.append("=\"");
String value = (String)annotationLocalAttrs.elementAt(i++);
- // search for pesky "s and >s within attr value:
+ // search for pesky "s and s within attr value:
+ // search for pesky "s and , minOccurs attribute
// must be zero or one, and maxOccurs attribute must be one.
// For a complex type definition that contains an or a
@@ -770,7 +779,8 @@
// minOccurs and maxOccurs must be one.
if (processingAllEl) {
if (max != 1) {
- reportSchemaError("cos-all-limited.2", new Object[]{new Integer(max),
+ reportSchemaError("cos-all-limited.2", new Object[]{
+ (max == SchemaSymbols.OCCURRENCE_UNBOUNDED) ? SchemaSymbols.ATTVAL_UNBOUNDED : Integer.toString(max),
((XSElementDecl)particle.fValue).getName()}, parent);
max = 1;
if (min > 1)
@@ -785,26 +795,56 @@
max = 1;
}
}
-
- particle.fMaxOccurs = min;
+
+ particle.fMinOccurs = min;
particle.fMaxOccurs = max;
-
+
return particle;
}
-
- // this is not terribly performant!
+
private static String processAttValue(String original) {
+ final int length = original.length();
// normally, nothing will happen
- StringBuffer newVal = new StringBuffer(original.length());
- for(int i=0; i') {
- newVal.append(">");
- } else if (currChar == '&') {
+ }
+ else if (currChar == '<') {
+ newVal.append("<");
+ }
+ else if (currChar == '&') {
newVal.append("&");
- } else {
+ }
+ // Must escape 0x09, 0x0A and 0x0D if they appear in attribute
+ // value so that they may be round-tripped. They would otherwise
+ // be transformed to a 0x20 during attribute value normalization.
+ else if (currChar == 0x09) {
+ newVal.append(" ");
+ }
+ else if (currChar == 0x0A) {
+ newVal.append("
");
+ }
+ else if (currChar == 0x0D) {
+ newVal.append("
");
+ }
+ else {
newVal.append(currChar);
}
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -23,9 +23,11 @@
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
import com.sun.org.apache.xerces.internal.impl.xs.XSAnnotationImpl;
import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeGroupDecl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import org.w3c.dom.Element;
/**
@@ -39,11 +41,12 @@
* Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
*
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: XSDAttributeGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDAttributeGroupTraverser extends XSDAbstractTraverser {
@@ -62,7 +65,7 @@
Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc);
// get attribute
- QName refAttr = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
+ QName refAttr = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
XSAttributeGroupDecl attrGrp = null;
@@ -76,7 +79,6 @@
// get global decl
attrGrp = (XSAttributeGroupDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ATTRIBUTEGROUP_TYPE, refAttr, elmNode);
-
// no children are allowed here except annotation, which is optional.
Element child = DOMUtil.getFirstChildElement(elmNode);
if (child != null) {
@@ -84,6 +86,11 @@
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
+ } else {
+ String text = DOMUtil.getSyntheticAnnotation(child);
+ if (text != null) {
+ traverseSyntheticAnnotation(child, text, attrValues, false, schemaDoc);
+ }
}
if (child != null) {
@@ -111,7 +118,7 @@
// global declaration must have a name
if (nameAttr == null) {
reportSchemaError("s4s-att-must-appear", new Object[]{"attributeGroup (global)", "name"}, elmNode);
- nameAttr = "no name";
+ nameAttr = NO_NAME;
}
attrGrp.fName = nameAttr;
@@ -142,6 +149,12 @@
reportSchemaError("s4s-elt-must-match.1", args, nextNode);
}
+ if (nameAttr.equals(NO_NAME)) {
+ // if a global group doesn't have a name, then don't add it.
+ fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+ return null;
+ }
+
// Remove prohibited attributes from the set
attrGrp.removeProhibitedAttrs();
@@ -158,10 +171,35 @@
}
}
- attrGrp.fAnnotation = annotation;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)annotations).addXSObject (annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+
+ attrGrp.fAnnotations = annotations;
// make an entry in global declarations.
- grammar.addGlobalAttributeGroupDecl(attrGrp);
+ if (grammar.getGlobalAttributeGroupDecl(attrGrp.fName) == null) {
+ grammar.addGlobalAttributeGroupDecl(attrGrp);
+ }
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSAttributeGroupDecl attrGrp2 = grammar.getGlobalAttributeGroupDecl(attrGrp.fName, loc);
+ if (attrGrp2 == null) {
+ grammar.addGlobalAttributeGroupDecl(attrGrp, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (attrGrp2 != null) {
+ attrGrp = attrGrp2;
+ }
+ fSchemaHandler.addGlobalAttributeGroupDecl(attrGrp);
+ }
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
return attrGrp;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -30,10 +30,12 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeUseImpl;
import com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
import org.w3c.dom.Element;
@@ -53,10 +55,11 @@
* Content: (annotation?, (simpleType?))
*
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
+ * @version $Id: XSDAttributeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDAttributeTraverser extends XSDAbstractTraverser {
@@ -81,16 +84,22 @@
// get 'attribute declaration'
XSAttributeDecl attribute = null;
+ XSAnnotationImpl annotation = null;
if (attrDecl.getAttributeNode(SchemaSymbols.ATT_REF) != null) {
if (refAtt != null) {
attribute = (XSAttributeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ATTRIBUTE_TYPE, refAtt, attrDecl);
Element child = DOMUtil.getFirstChildElement(attrDecl);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: put this somewhere
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
+ else {
+ String text = DOMUtil.getSyntheticAnnotation(attrDecl);
+ if (text != null) {
+ annotation = traverseSyntheticAnnotation(attrDecl, text, attrValues, false, schemaDoc);
+ }
+ }
if (child != null) {
reportSchemaError("src-attribute.3.2", new Object[]{refAtt.rawname}, child);
@@ -128,6 +137,19 @@
attrUse.fDefault = new ValidatedInfo();
attrUse.fDefault.normalizedValue = defaultAtt;
}
+ // Get the annotation associated witht the local attr decl
+ if (attrDecl.getAttributeNode(SchemaSymbols.ATT_REF) == null) {
+ attrUse.fAnnotations = attribute.getAnnotations();
+ } else {
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ attrUse.fAnnotations = annotations;
+ }
}
//src-attribute
@@ -141,6 +163,8 @@
if (consType == XSConstants.VC_DEFAULT &&
useAtt != null && useAtt.intValue() != SchemaSymbols.USE_OPTIONAL) {
reportSchemaError("src-attribute.2", new Object[]{nameAtt}, attrDecl);
+ // Recover by honouring the default value
+ attrUse.fUse = SchemaSymbols.USE_OPTIONAL;
}
// a-props-correct
@@ -154,11 +178,17 @@
catch (InvalidDatatypeValueException ide) {
reportSchemaError (ide.getKey(), ide.getArgs(), attrDecl);
reportSchemaError ("a-props-correct.2", new Object[]{nameAtt, defaultAtt}, attrDecl);
+ // Recover by removing the default value
+ attrUse.fDefault = null;
+ attrUse.fConstraintType = XSConstants.VC_NONE;
}
// 3 If the {type definition} is or is derived from ID then there must not be a {value constraint}.
if (((XSSimpleType)attribute.getTypeDefinition()).isIDType() ) {
reportSchemaError ("a-props-correct.3", new Object[]{nameAtt}, attrDecl);
+ // Recover by removing the default value
+ attrUse.fDefault = null;
+ attrUse.fConstraintType = XSConstants.VC_NONE;
}
// check 3.5.6 constraint
@@ -169,6 +199,9 @@
if (attrUse.fConstraintType != XSConstants.VC_FIXED ||
!attrUse.fAttrDecl.getValInfo().actualValue.equals(attrUse.fDefault.actualValue)) {
reportSchemaError ("au-props-correct.2", new Object[]{nameAtt, attrUse.fAttrDecl.getValInfo().stringValue()}, attrDecl);
+ // Recover by using the decl's {value constraint}
+ attrUse.fDefault = attrUse.fAttrDecl.getValInfo();
+ attrUse.fConstraintType = XSConstants.VC_FIXED;
}
}
}
@@ -289,25 +322,33 @@
}
}
- // Handler type attribute
+ // Handle type attribute
if (attrType == null && typeAtt != null) {
XSTypeDefinition type = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, typeAtt, attrDecl);
- if (type != null && type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE)
+ if (type != null && type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
attrType = (XSSimpleType)type;
- else
+ }
+ else {
reportSchemaError("src-resolve", new Object[]{typeAtt.rawname, "simpleType definition"}, attrDecl);
+ if (type == null) {
+ attribute.fUnresolvedTypeName = typeAtt;
+ }
+ }
}
if (attrType == null) {
attrType = SchemaGrammar.fAnySimpleType;
}
- attribute.setValues(nameAtt, tnsAtt, attrType,
- constraintType, scope, attDefault, enclCT, annotation);
-
- // Step 2: register attribute decl to the grammar
- if (isGlobal && nameAtt != null)
- grammar.addGlobalAttributeDecl(attribute);
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
+ attDefault, enclCT, annotations);
// Step 3: check against schema for schemas
@@ -364,6 +405,11 @@
catch (InvalidDatatypeValueException ide) {
reportSchemaError (ide.getKey(), ide.getArgs(), attrDecl);
reportSchemaError ("a-props-correct.2", new Object[]{nameAtt, attDefault.normalizedValue}, attrDecl);
+ // Recover by removing the default value
+ attDefault = null;
+ constraintType = XSConstants.VC_NONE;
+ attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
+ attDefault, enclCT, annotations);
}
}
@@ -371,6 +417,11 @@
if (attDefault != null) {
if (attrType.isIDType() ) {
reportSchemaError ("a-props-correct.3", new Object[]{nameAtt}, attrDecl);
+ // Recover by removing the default value
+ attDefault = null;
+ constraintType = XSConstants.VC_NONE;
+ attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
+ attDefault, enclCT, annotations);
}
}
@@ -379,6 +430,7 @@
// The {name} of an attribute declaration must not match xmlns.
if (nameAtt != null && nameAtt.equals(XMLSymbols.PREFIX_XMLNS)) {
reportSchemaError("no-xmlns", null, attrDecl);
+ return null;
}
// no-xsi
@@ -386,12 +438,34 @@
// The {target namespace} of an attribute declaration, whether local or top-level, must not match http://www.w3.org/2001/XMLSchema-instance (unless it is one of the four built-in declarations given in the next section).
if (tnsAtt != null && tnsAtt.equals(SchemaSymbols.URI_XSI)) {
reportSchemaError("no-xsi", new Object[]{SchemaSymbols.URI_XSI}, attrDecl);
+ return null;
}
// Attribute without a name. Return null.
- if (attribute.getName() == null)
+ if (nameAtt.equals(NO_NAME))
return null;
+ // Step 2: register attribute decl to the grammar
+ if (isGlobal) {
+ if (grammar.getGlobalAttributeDecl(nameAtt) == null) {
+ grammar.addGlobalAttributeDecl(attribute);
+ }
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSAttributeDecl attribute2 = grammar.getGlobalAttributeDecl(nameAtt, loc);
+ if (attribute2 == null) {
+ grammar.addGlobalAttributeDecl(attribute, loc);
+ }
+
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (attribute2 != null) {
+ attribute = attribute2;
+ }
+ fSchemaHandler.addGlobalAttributeDecl(attribute);
+ }
+ }
+
return attribute;
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -23,6 +23,7 @@
import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
import com.sun.org.apache.xerces.internal.impl.dv.XSFacets;
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
import com.sun.org.apache.xerces.internal.impl.xs.XSAnnotationImpl;
@@ -61,14 +62,44 @@
*
* @xerces.internal
*
- * @version $Id: XSDComplexTypeTraverser.java,v 1.6 2010/07/20 20:25:22 joehw Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
-
+
// size of stack to hold globals:
private final static int GLOBAL_NUM = 11;
-
+
+ private static XSParticleDecl fErrorContent = null;
+ private static XSWildcardDecl fErrorWildcard = null;
+ private static XSParticleDecl getErrorContent() {
+ if (fErrorContent == null) {
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
+ particle.fValue = getErrorWildcard();
+ particle.fMinOccurs = 0;
+ particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
+ group.fParticleCount = 1;
+ group.fParticles = new XSParticleDecl[1];
+ group.fParticles[0] = particle;
+ XSParticleDecl errorContent = new XSParticleDecl();
+ errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
+ errorContent.fValue = group;
+ fErrorContent = errorContent;
+ }
+ return fErrorContent;
+ }
+ private static XSWildcardDecl getErrorWildcard() {
+ if (fErrorWildcard == null) {
+ XSWildcardDecl wildcard = new XSWildcardDecl();
+ wildcard.fProcessContents = XSWildcardDecl.PC_SKIP;
+ fErrorWildcard = wildcard;
+ }
+ return fErrorWildcard;
+ }
+
// globals for building XSComplexTypeDecls
private String fName = null;
private String fTargetNamespace = null;
@@ -83,27 +114,23 @@
private boolean fIsAbstract = false;
private XSComplexTypeDecl fComplexTypeDecl = null;
private XSAnnotationImpl [] fAnnotations = null;
-
- private XSParticleDecl fEmptyParticle = null;
-
+
// our own little stack to retain state when getGlobalDecls is called:
private Object [] fGlobalStore = null;
private int fGlobalStorePos = 0;
-
+
XSDComplexTypeTraverser (XSDHandler handler,
XSAttributeChecker gAttrCheck) {
super(handler, gAttrCheck);
}
-
-
+
+
private static final boolean DEBUG=false;
-
- private SchemaDVFactory schemaFactory = SchemaDVFactory.getInstance();
-
- private class ComplexTypeRecoverableError extends Exception {
-
+
+ private static final class ComplexTypeRecoverableError extends Exception {
+
private static final long serialVersionUID = 6802729912091130335L;
-
+
Object[] errorSubstText=null;
Element errorElem = null;
ComplexTypeRecoverableError() {
@@ -114,9 +141,9 @@
errorSubstText=args;
errorElem = e;
}
-
+
}
-
+
/**
* Traverse local complexType declarations
*
@@ -128,8 +155,8 @@
XSComplexTypeDecl traverseLocal(Element complexTypeNode,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
-
-
+
+
Object[] attrValues = fAttrChecker.checkAttributes(complexTypeNode, false,
schemaDoc);
String complexTypeName = genAnonTypeName(complexTypeNode);
@@ -141,10 +168,10 @@
grammar.addComplexTypeDecl(type, fSchemaHandler.element2Locator(complexTypeNode));
type.setIsAnonymous();
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
-
+
return type;
}
-
+
/**
* Traverse global complexType declarations
*
@@ -156,7 +183,7 @@
XSComplexTypeDecl traverseGlobal (Element complexTypeNode,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
-
+
Object[] attrValues = fAttrChecker.checkAttributes(complexTypeNode, true,
schemaDoc);
String complexTypeName = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
@@ -164,46 +191,69 @@
XSComplexTypeDecl type = traverseComplexTypeDecl (complexTypeNode,
complexTypeName, attrValues, schemaDoc, grammar);
contentRestore();
- if (complexTypeName == null) {
- reportSchemaError("s4s-att-must-appear", new Object[]{SchemaSymbols.ELT_COMPLEXTYPE, SchemaSymbols.ATT_NAME}, complexTypeNode);
- } else {
- grammar.addGlobalTypeDecl(type);
- }
// need to add the type to the grammar for later constraint checking
grammar.addComplexTypeDecl(type, fSchemaHandler.element2Locator(complexTypeNode));
+
+ if (complexTypeName == null) {
+ reportSchemaError("s4s-att-must-appear", new Object[]{SchemaSymbols.ELT_COMPLEXTYPE, SchemaSymbols.ATT_NAME}, complexTypeNode);
+ type = null;
+ } else {
+ if (grammar.getGlobalTypeDecl(type.getName()) == null) {
+ grammar.addGlobalComplexTypeDecl(type);
+ }
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
+ if (type2 == null) {
+ grammar.addGlobalComplexTypeDecl(type, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (type2 != null) {
+ if (type2 instanceof XSComplexTypeDecl) {
+ type = (XSComplexTypeDecl) type2;
+ }
+ }
+ fSchemaHandler.addGlobalTypeDecl(type);
+ }
+ }
+
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
-
+
return type;
}
-
-
+
+
private XSComplexTypeDecl traverseComplexTypeDecl(Element complexTypeDecl,
String complexTypeName,
Object[] attrValues,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
-
+
fComplexTypeDecl = new XSComplexTypeDecl();
fAttrGrp = new XSAttributeGroupDecl();
Boolean abstractAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
XInt blockAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_BLOCK];
Boolean mixedAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
XInt finalAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_FINAL];
-
+
fName = complexTypeName;
fComplexTypeDecl.setName(fName);
fTargetNamespace = schemaDoc.fTargetNamespace;
-
+
fBlock = blockAtt == null ? schemaDoc.fBlockDefault : blockAtt.shortValue();
fFinal = finalAtt == null ? schemaDoc.fFinalDefault : finalAtt.shortValue();
//discard valid Block/Final 'Default' values that are invalid for Block/Final
fBlock &= (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION);
fFinal &= (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION);
-
+
fIsAbstract = (abstractAtt != null && abstractAtt.booleanValue());
-
+ fAnnotations = null;
+
Element child = null;
-
+
try {
// ---------------------------------------------------------------
// First, handle any ANNOTATION declaration and get next child
@@ -239,9 +289,10 @@
//
// EMPTY complexType with complexContent
//
-
+
// set the base to the anyType
fBaseType = SchemaGrammar.fAnyType;
+ fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
processComplexContent(child, mixedAtt.booleanValue(), false,
schemaDoc, grammar);
}
@@ -277,45 +328,46 @@
// GROUP, ALL, SEQUENCE or CHOICE, followed by optional attributes
// Note that it's possible that only attributes are specified.
//
-
+
// set the base to the anyType
fBaseType = SchemaGrammar.fAnyType;
+ fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
processComplexContent(child, mixedAtt.booleanValue(), false,
schemaDoc, grammar);
}
-
+
}
catch (ComplexTypeRecoverableError e) {
handleComplexTypeError(e.getMessage(), e.errorSubstText,
e.errorElem);
}
-
+
if (DEBUG) {
System.out.println(fName);
}
fComplexTypeDecl.setValues(fName, fTargetNamespace, fBaseType,
fDerivedBy, fFinal, fBlock, fContentType, fIsAbstract,
- fAttrGrp, fXSSimpleType, fParticle, new XSObjectListImpl(fAnnotations,
+ fAttrGrp, fXSSimpleType, fParticle, new XSObjectListImpl(fAnnotations,
fAnnotations == null? 0 : fAnnotations.length));
return fComplexTypeDecl;
}
-
-
+
+
private void traverseSimpleContent(Element simpleContentElement,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar)
throws ComplexTypeRecoverableError {
-
-
+
+
Object[] simpleContentAttrValues = fAttrChecker.checkAttributes(simpleContentElement, false,
schemaDoc);
-
+
// -----------------------------------------------------------------------
// Set content type
// -----------------------------------------------------------------------
fContentType = XSComplexTypeDecl.CONTENTTYPE_SIMPLE;
fParticle = null;
-
+
Element simpleContent = DOMUtil.getFirstChildElement(simpleContentElement);
if (simpleContent != null && DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
addAnnotation(traverseAnnotationDecl(simpleContent, simpleContentAttrValues, false, schemaDoc));
@@ -327,7 +379,7 @@
addAnnotation(traverseSyntheticAnnotation(simpleContentElement, text, simpleContentAttrValues, false, schemaDoc));
}
}
-
+
// If there are no children, return
if (simpleContent==null) {
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
@@ -335,7 +387,7 @@
new Object[]{fName,SchemaSymbols.ELT_SIMPLECONTENT},
simpleContentElement);
}
-
+
// -----------------------------------------------------------------------
// The content should be either "restriction" or "extension"
// -----------------------------------------------------------------------
@@ -358,12 +410,12 @@
new Object[]{fName,siblingName},
elemTmp);
}
-
+
Object [] derivationTypeAttrValues = fAttrChecker.checkAttributes(simpleContent, false,
schemaDoc);
QName baseTypeName = (QName) derivationTypeAttrValues[XSAttributeChecker.ATTIDX_BASE];
-
-
+
+
// -----------------------------------------------------------------------
// Need a base type.
// -----------------------------------------------------------------------
@@ -373,7 +425,7 @@
throw new ComplexTypeRecoverableError("s4s-att-must-appear",
new Object[]{simpleContentName, "base"}, simpleContent);
}
-
+
XSTypeDefinition type = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc,
XSDHandler.TYPEDECL_TYPE, baseTypeName,
simpleContent);
@@ -382,16 +434,16 @@
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
throw new ComplexTypeRecoverableError();
}
-
+
fBaseType = type;
-
+
XSSimpleType baseValidator = null;
XSComplexTypeDecl baseComplexType = null;
int baseFinalSet = 0;
-
+
// If the base type is complex, it must have simpleContent
if ((type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)) {
-
+
baseComplexType = (XSComplexTypeDecl)type;
baseFinalSet = baseComplexType.getFinal();
// base is a CT with simple content (both restriction and extension are OK)
@@ -421,7 +473,7 @@
}
baseFinalSet=baseValidator.getFinal();
}
-
+
// -----------------------------------------------------------------------
// Check that the base permits the derivation
// -----------------------------------------------------------------------
@@ -433,7 +485,7 @@
throw new ComplexTypeRecoverableError(errorKey,
new Object[]{fName, fBaseType.getName()}, simpleContent);
}
-
+
// -----------------------------------------------------------------------
// Skip over any potential annotations
// -----------------------------------------------------------------------
@@ -441,7 +493,7 @@
simpleContent = DOMUtil.getFirstChildElement(simpleContent);
if (simpleContent != null) {
// traverse annotation if any
-
+
if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
addAnnotation(traverseAnnotationDecl(simpleContent, derivationTypeAttrValues, false, schemaDoc));
simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
@@ -452,7 +504,7 @@
addAnnotation(traverseSyntheticAnnotation(scElement, text, derivationTypeAttrValues, false, schemaDoc));
}
}
-
+
if (simpleContent !=null &&
DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)){
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
@@ -468,19 +520,19 @@
addAnnotation(traverseSyntheticAnnotation(scElement, text, derivationTypeAttrValues, false, schemaDoc));
}
}
-
+
// -----------------------------------------------------------------------
// Process a RESTRICTION
// -----------------------------------------------------------------------
if (fDerivedBy == XSConstants.DERIVATION_RESTRICTION) {
-
+
// -----------------------------------------------------------------------
// There may be a simple type definition in the restriction element
// The data type validator will be based on it, if specified
// -----------------------------------------------------------------------
if (simpleContent !=null &&
DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_SIMPLETYPE )) {
-
+
XSSimpleType dv = fSchemaHandler.fSimpleTypeTraverser.traverseLocal(
simpleContent, schemaDoc, grammar);
if (dv == null) {
@@ -490,7 +542,7 @@
}
//check that this datatype validator is validly derived from the base
//according to derivation-ok-restriction 5.1.2.1
-
+
if (baseValidator != null &&
!XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
baseValidator.getFinal())) {
@@ -503,7 +555,7 @@
baseValidator = dv;
simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
}
-
+
// this only happens when restricting a mixed/emptiable CT
// but there is no , which is required
if (baseValidator == null) {
@@ -512,7 +564,7 @@
throw new ComplexTypeRecoverableError("src-ct.2.2",
new Object[]{fName}, simpleContent);
}
-
+
// -----------------------------------------------------------------------
// Traverse any facets
// -----------------------------------------------------------------------
@@ -520,7 +572,7 @@
XSFacets facetData = null;
short presentFacets = 0 ;
short fixedFacets = 0 ;
-
+
if (simpleContent!=null) {
FacetInfo fi = traverseFacets(simpleContent, baseValidator, schemaDoc);
attrNode = fi.nodeAfterFacets;
@@ -528,15 +580,21 @@
presentFacets = fi.fPresentFacets;
fixedFacets = fi.fFixedFacets;
}
-
- fXSSimpleType = schemaFactory.createTypeRestriction(null,schemaDoc.fTargetNamespace,(short)0,baseValidator,null);
+
+ String name = genAnonTypeName(simpleContentElement);
+ fXSSimpleType = fSchemaHandler.fDVFactory.createTypeRestriction(name,schemaDoc.fTargetNamespace,(short)0,baseValidator,null);
try{
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
fXSSimpleType.applyFacets(facetData, presentFacets, fixedFacets, fValidationState);
}catch(InvalidDatatypeFacetException ex){
reportSchemaError(ex.getKey(), ex.getArgs(), simpleContent);
+ // Recreate the type, ignoring the facets
+ fXSSimpleType = fSchemaHandler.fDVFactory.createTypeRestriction(name,schemaDoc.fTargetNamespace,(short)0,baseValidator,null);
}
-
+ if (fXSSimpleType instanceof XSSimpleTypeDecl) {
+ ((XSSimpleTypeDecl)fXSSimpleType).setAnonymous(true);
+ }
+
// -----------------------------------------------------------------------
// Traverse any attributes
// -----------------------------------------------------------------------
@@ -558,7 +616,7 @@
node);
}
}
-
+
try {
mergeAttributes(baseComplexType.getAttrGrp(), fAttrGrp, fName, false, simpleContentElement);
} catch (ComplexTypeRecoverableError e) {
@@ -568,7 +626,7 @@
}
// Prohibited uses must be removed after merge for RESTRICTION
fAttrGrp.removeProhibitedAttrs();
-
+
Object[] errArgs=fAttrGrp.validRestrictionOf(fName, baseComplexType.getAttrGrp());
if (errArgs != null) {
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
@@ -576,7 +634,7 @@
throw new ComplexTypeRecoverableError((String)errArgs[errArgs.length-1],
errArgs, attrNode);
}
-
+
}
// -----------------------------------------------------------------------
// Process a EXTENSION
@@ -597,7 +655,7 @@
}
Element node=traverseAttrsAndAttrGrps(attrNode,fAttrGrp,
schemaDoc,grammar,fComplexTypeDecl);
-
+
if (node!=null) {
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
@@ -608,7 +666,7 @@
// Remove prohibited uses. Should be done prior to any merge.
fAttrGrp.removeProhibitedAttrs();
}
-
+
if (baseComplexType != null) {
try {
mergeAttributes(baseComplexType.getAttrGrp(), fAttrGrp, fName, true, simpleContentElement);
@@ -624,17 +682,17 @@
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
}
-
+
private void traverseComplexContent(Element complexContentElement,
boolean mixedOnType, XSDocumentInfo schemaDoc,
SchemaGrammar grammar)
throws ComplexTypeRecoverableError {
-
-
+
+
Object[] complexContentAttrValues = fAttrChecker.checkAttributes(complexContentElement, false,
schemaDoc);
-
-
+
+
// -----------------------------------------------------------------------
// Determine if this is mixed content
// -----------------------------------------------------------------------
@@ -643,14 +701,14 @@
if (mixedAtt != null) {
mixedContent = mixedAtt.booleanValue();
}
-
-
+
+
// -----------------------------------------------------------------------
// Since the type must have complex content, set the simple type validators
// to null
// -----------------------------------------------------------------------
fXSSimpleType = null;
-
+
Element complexContent = DOMUtil.getFirstChildElement(complexContentElement);
if (complexContent != null && DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
addAnnotation(traverseAnnotationDecl(complexContent, complexContentAttrValues, false, schemaDoc));
@@ -662,7 +720,7 @@
addAnnotation(traverseSyntheticAnnotation(complexContentElement, text, complexContentAttrValues, false, schemaDoc));
}
}
-
+
// If there are no children, return
if (complexContent==null) {
fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
@@ -670,7 +728,7 @@
new Object[]{fName,SchemaSymbols.ELT_COMPLEXCONTENT},
complexContentElement);
}
-
+
// -----------------------------------------------------------------------
// The content should be either "restriction" or "extension"
// -----------------------------------------------------------------------
@@ -691,12 +749,12 @@
throw new ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
new Object[]{fName, siblingName}, elemTmp);
}
-
+
Object[] derivationTypeAttrValues = fAttrChecker.checkAttributes(complexContent, false,
schemaDoc);
QName baseTypeName = (QName) derivationTypeAttrValues[XSAttributeChecker.ATTIDX_BASE];
-
-
+
+
// -----------------------------------------------------------------------
// Need a base type. Check that it's a complex type
// -----------------------------------------------------------------------
@@ -706,18 +764,18 @@
throw new ComplexTypeRecoverableError("s4s-att-must-appear",
new Object[]{complexContentName, "base"}, complexContent);
}
-
+
XSTypeDefinition type = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc,
XSDHandler.TYPEDECL_TYPE,
baseTypeName,
complexContent);
-
+
if (type==null) {
fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
throw new ComplexTypeRecoverableError();
}
-
+
if (! (type instanceof XSComplexTypeDecl)) {
fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
@@ -726,7 +784,7 @@
}
XSComplexTypeDecl baseType = (XSComplexTypeDecl)type;
fBaseType = baseType;
-
+
// -----------------------------------------------------------------------
// Check that the base permits the derivation
// -----------------------------------------------------------------------
@@ -738,12 +796,12 @@
throw new ComplexTypeRecoverableError(errorKey,
new Object[]{fName, fBaseType.getName()}, complexContent);
}
-
+
// -----------------------------------------------------------------------
// Skip over any potential annotations
// -----------------------------------------------------------------------
complexContent = DOMUtil.getFirstChildElement(complexContent);
-
+
if (complexContent != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -782,20 +840,20 @@
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
throw e;
}
-
+
// -----------------------------------------------------------------------
// Compose the final content and attribute uses
// -----------------------------------------------------------------------
XSParticleDecl baseContent = (XSParticleDecl)baseType.getParticle();
if (fDerivedBy==XSConstants.DERIVATION_RESTRICTION) {
-
+
// This is an RESTRICTION
-
+
// N.B. derivation-ok-restriction.5.3 is checked under schema
// full checking. That's because we need to wait until locals are
// traversed so that occurrence information is correct.
-
-
+
+
if (fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED &&
baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_MIXED) {
fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
@@ -804,7 +862,7 @@
new Object[]{fName, baseType.getName()},
complexContent);
}
-
+
try {
mergeAttributes(baseType.getAttrGrp(), fAttrGrp, fName, false, complexContent);
} catch (ComplexTypeRecoverableError e) {
@@ -814,7 +872,7 @@
}
// Remove prohibited uses. Must be done after merge for RESTRICTION.
fAttrGrp.removeProhibitedAttrs();
-
+
if (baseType != SchemaGrammar.fAnyType) {
Object[] errArgs = fAttrGrp.validRestrictionOf(fName, baseType.getAttrGrp());
if (errArgs != null) {
@@ -826,9 +884,9 @@
}
}
else {
-
+
// This is an EXTENSION
-
+
// Create the particle
if (fParticle == null) {
fContentType = baseType.getContentType();
@@ -855,7 +913,7 @@
throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.3.2.2.1.b",
new Object[]{fName}, complexContent);
}
-
+
// if the content of either type is an "all" model group, error.
if (fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
((XSModelGroupImpl)fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL ||
@@ -873,14 +931,16 @@
group.fParticles = new XSParticleDecl[2];
group.fParticles[0] = (XSParticleDecl)baseType.getParticle();
group.fParticles[1] = fParticle;
+ group.fAnnotations = XSObjectListImpl.EMPTY_LIST;
// the particle to contain the above sequence
XSParticleDecl particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fValue = group;
-
+ particle.fAnnotations = XSObjectListImpl.EMPTY_LIST;
+
fParticle = particle;
}
-
+
// Remove prohibited uses. Must be done before merge for EXTENSION.
fAttrGrp.removeProhibitedAttrs();
try {
@@ -890,18 +950,17 @@
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
throw e;
}
-
+
}
-
+
// and *finally* we can legitimately return the attributes!
fAttrChecker.returnAttrArray(complexContentAttrValues, schemaDoc);
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
-
+
} // end of traverseComplexContent
-
-
+
+
// This method merges attribute uses from the base, into the derived set.
- // The first duplicate attribute, if any, is returned.
// LM: may want to merge with attributeGroup processing.
private void mergeAttributes(XSAttributeGroupDecl fromAttrGrp,
XSAttributeGroupDecl toAttrGrp,
@@ -909,16 +968,16 @@
boolean extension,
Element elem)
throws ComplexTypeRecoverableError {
-
+
XSObjectList attrUseS = fromAttrGrp.getAttributeUses();
- XSAttributeUseImpl duplicateAttrUse = null, oneAttrUse = null;
+ XSAttributeUseImpl oneAttrUse = null;
int attrCount = attrUseS.getLength();
for (int i=0; i= 0)
particle.fMinOccurs = m;
}
@@ -129,10 +132,10 @@
if (particle.fType == XSParticleDecl.PARTICLE_EMPTY)
particle = null;
}
-
+
return particle;
}
-
+
/**
* Traverse a locally declared element (or an element reference).
*
@@ -148,29 +151,35 @@
int allContextFlags,
XSObject parent,
String[] localNSDecls) {
-
+
if (localNSDecls != null) {
schemaDoc.fNamespaceSupport.setEffectiveContext(localNSDecls);
}
-
+
// General Attribute Checking
Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, false, schemaDoc);
-
+
QName refAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
XInt minAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
XInt maxAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
-
+
XSElementDecl element = null;
+ XSAnnotationImpl annotation = null;
if (elmDecl.getAttributeNode(SchemaSymbols.ATT_REF) != null) {
if (refAtt != null) {
element = (XSElementDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ELEMENT_TYPE, refAtt, elmDecl);
-
+
Element child = DOMUtil.getFirstChildElement(elmDecl);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: put this somewhere
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
+ else {
+ String text = DOMUtil.getSyntheticAnnotation(elmDecl);
+ if (text != null) {
+ annotation = traverseSyntheticAnnotation(elmDecl, text, attrValues, false, schemaDoc);
+ }
+ }
// Element Declaration Representation OK
// 2 If the item's parent is not , then all of the following must be true:
// 2.1 One of ref or name must be present, but not both.
@@ -184,7 +193,7 @@
} else {
element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, false, parent);
}
-
+
particle.fMinOccurs = minAtt.intValue();
particle.fMaxOccurs = maxAtt.intValue();
if (element != null) {
@@ -194,14 +203,27 @@
else {
particle.fType = XSParticleDecl.PARTICLE_EMPTY;
}
+ if (refAtt != null) {
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ particle.fAnnotations = annotations;
+ } else {
+ particle.fAnnotations = ((element != null) ? element.fAnnotations
+ : XSObjectListImpl.EMPTY_LIST);
+ }
Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
checkOccurrences(particle, SchemaSymbols.ELT_ELEMENT,
(Element)elmDecl.getParentNode(), allContextFlags,
defaultVals.longValue());
-
+
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
}
-
+
/**
* Traverse a globally declared element.
*
@@ -213,16 +235,16 @@
XSElementDecl traverseGlobal(Element elmDecl,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
-
+
// General Attribute Checking'
Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, true, schemaDoc);
XSElementDecl element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true, null);
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
return element;
-
+
}
-
+
/**
* Traverse a globally declared element.
*
@@ -239,7 +261,7 @@
SchemaGrammar grammar,
boolean isGlobal,
XSObject parent) {
-
+
Boolean abstractAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
XInt blockAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_BLOCK];
String defaultAtt = (String) attrValues[XSAttributeChecker.ATTIDX_DEFAULT];
@@ -250,9 +272,9 @@
Boolean nillableAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_NILLABLE];
QName subGroupAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_SUBSGROUP];
QName typeAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_TYPE];
-
+
// Step 1: get declaration information
-
+
XSElementDecl element = null;
if (fSchemaHandler.fDeclPool !=null) {
element = fSchemaHandler.fDeclPool.getElementDecl();
@@ -262,7 +284,7 @@
// get 'name'
if (nameAtt != null)
element.fName = fSymbolTable.addSymbol(nameAtt);
-
+
// get 'target namespace'
if (isGlobal) {
element.fTargetNamespace = schemaDoc.fTargetNamespace;
@@ -271,7 +293,7 @@
else {
if (parent instanceof XSComplexTypeDecl)
element.setIsLocal((XSComplexTypeDecl)parent);
-
+
if (formAtt != null) {
if (formAtt.intValue() == SchemaSymbols.FORM_QUALIFIED)
element.fTargetNamespace = schemaDoc.fTargetNamespace;
@@ -283,40 +305,40 @@
element.fTargetNamespace = null;
}
}
-
+
// get 'block', 'final', 'nillable', 'abstract'
- if (blockAtt == null) {
- // use defaults
- element.fBlock = schemaDoc.fBlockDefault;
- // discard valid Block 'Default' values that are invalid for Block
- // respect #all
- if (element.fBlock != XSConstants.DERIVATION_ALL) {
- element.fBlock &= (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
- }
- } else {
- // use specified values
- element.fBlock = blockAtt.shortValue();
- // check for valid values
- if ((element.fBlock != XSConstants.DERIVATION_ALL)
- &&
- ((element.fBlock | XSConstants.DERIVATION_EXTENSION_RESTRICTION_SUBSTITION)
- != XSConstants.DERIVATION_EXTENSION_RESTRICTION_SUBSTITION)) {
- reportSchemaError(
- "s4s-att-invalid-value",
- new Object[]{element.fName, "block", "must be (#all | List of (extension | restriction | substitution))"},
- elmDecl);
- }
+ if (blockAtt == null) {
+ // use defaults
+ element.fBlock = schemaDoc.fBlockDefault;
+ // discard valid Block 'Default' values that are invalid for Block
+ // respect #all
+ if (element.fBlock != XSConstants.DERIVATION_ALL) {
+ element.fBlock &= (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
+ }
+ } else {
+ // use specified values
+ element.fBlock = blockAtt.shortValue();
+ // check for valid values
+ if ((element.fBlock != XSConstants.DERIVATION_ALL)
+ &&
+ ((element.fBlock | XSConstants.DERIVATION_EXTENSION_RESTRICTION_SUBSTITION)
+ != XSConstants.DERIVATION_EXTENSION_RESTRICTION_SUBSTITION)) {
+ reportSchemaError(
+ "s4s-att-invalid-value",
+ new Object[]{element.fName, "block", "must be (#all | List of (extension | restriction | substitution))"},
+ elmDecl);
+ }
}
element.fFinal = finalAtt == null ? schemaDoc.fFinalDefault : finalAtt.shortValue();
// discard valid Final 'Default' values that are invalid for Final
element.fFinal &= (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION);
-
+
if (nillableAtt.booleanValue())
element.setIsNillable();
if (abstractAtt != null && abstractAtt.booleanValue())
element.setIsAbstract();
-
+
// get 'value constraint'
if (fixedAtt != null) {
element.fDefault = new ValidatedInfo();
@@ -329,12 +351,12 @@
} else {
element.setConstraintType(XSConstants.VC_NONE);
}
-
+
// get 'substitutionGroup affiliation'
if (subGroupAtt != null) {
element.fSubGroup = (XSElementDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ELEMENT_TYPE, subGroupAtt, elmDecl);
}
-
+
// get 'annotation'
Element child = DOMUtil.getFirstChildElement(elmDecl);
XSAnnotationImpl annotation = null;
@@ -348,16 +370,24 @@
annotation = traverseSyntheticAnnotation(elmDecl, text, attrValues, false, schemaDoc);
}
}
- element.fAnnotation = annotation;
-
+
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl)annotations).addXSObject (annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ element.fAnnotations = annotations;
+
// get 'type definition'
XSTypeDefinition elementType = null;
boolean haveAnonType = false;
-
+
// Handle Anonymous type if there is one
if (child != null) {
String childName = DOMUtil.getLocalName(child);
-
+
if (childName.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
elementType = fSchemaHandler.fComplexTypeTraverser.traverseLocal(child, schemaDoc, grammar);
haveAnonType = true;
@@ -369,25 +399,28 @@
child = DOMUtil.getNextSiblingElement(child);
}
}
-
+
// Handler type attribute
if (elementType == null && typeAtt != null) {
elementType = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, typeAtt, elmDecl);
+ if (elementType == null) {
+ element.fUnresolvedTypeName = typeAtt;
+ }
}
-
+
// Get it from the substitutionGroup declaration
if (elementType == null && element.fSubGroup != null) {
elementType = element.fSubGroup.fType;
}
-
+
if (elementType == null) {
elementType = SchemaGrammar.fAnyType;
}
-
+
element.fType = elementType;
-
+
// get 'identity constraint'
-
+
// see if there's something here; it had better be key, keyref or unique.
if (child != null) {
String childName = DOMUtil.getLocalName(child);
@@ -395,18 +428,18 @@
(childName.equals(SchemaSymbols.ELT_KEY) ||
childName.equals(SchemaSymbols.ELT_KEYREF) ||
childName.equals(SchemaSymbols.ELT_UNIQUE))) {
-
+
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);
+ DOMUtil.setHidden(child, fSchemaHandler.fHiddenNodes);
fSchemaHandler.fUniqueOrKeyTraverser.traverse(child, element, schemaDoc, grammar);
if(DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME).length() != 0 ) {
fSchemaHandler.checkForDuplicateNames(
(schemaDoc.fTargetNamespace == null) ? ","+DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME)
: schemaDoc.fTargetNamespace+","+ DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME),
- fSchemaHandler.getIDRegistry(), fSchemaHandler.getIDRegistry_sub(),
+ fSchemaHandler.ATTRIBUTE_TYPE, fSchemaHandler.getIDRegistry(), fSchemaHandler.getIDRegistry_sub(),
child, schemaDoc);
}
} else if (childName.equals(SchemaSymbols.ELT_KEYREF)) {
@@ -418,13 +451,9 @@
}
}
}
-
- // Step 2: register the element decl to the grammar
- if (isGlobal && nameAtt != null)
- grammar.addGlobalElementDecl(element);
-
+
// Step 3: check against schema for schemas
-
+
// required attributes
if (nameAtt == null) {
if (isGlobal)
@@ -433,55 +462,57 @@
reportSchemaError("src-element.2.1", null, elmDecl);
nameAtt = NO_NAME;
}
-
+
// element
if (child != null) {
reportSchemaError("s4s-elt-must-match.1", new Object[]{nameAtt, "(annotation?, (simpleType | complexType)?, (unique | key | keyref)*))", DOMUtil.getLocalName(child)}, child);
}
-
+
// Step 4: check 3.3.3 constraints
-
+
// src-element
-
+
// 1 default and fixed must not both be present.
if (defaultAtt != null && fixedAtt != null) {
reportSchemaError("src-element.1", new Object[]{nameAtt}, elmDecl);
}
-
+
// 2 If the item's parent is not , then all of the following must be true:
// 2.1 One of ref or name must be present, but not both.
// This is checked in XSAttributeChecker
-
+
// 2.2 If ref is present, then all of , , , , , nillable, default, fixed, form, block and type must be absent, i.e. only minOccurs, maxOccurs, id are allowed in addition to ref, along with .
// Attributes are checked in XSAttributeChecker, elements are checked in "traverse" method
-
+
// 3 type and either or are mutually exclusive.
if (haveAnonType && (typeAtt != null)) {
reportSchemaError("src-element.3", new Object[]{nameAtt}, elmDecl);
}
-
+
// Step 5: check 3.3.6 constraints
// check for NOTATION type
checkNotationType(nameAtt, elementType, elmDecl);
-
+
// e-props-correct
-
+
// 2 If there is a {value constraint}, the canonical lexical representation of its value must be valid with respect to the {type definition} as defined in Element Default Valid (Immediate) (3.3.6).
if (element.fDefault != null) {
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
if (XSConstraints.ElementDefaultValidImmediate(element.fType, element.fDefault.normalizedValue, fValidationState, element.fDefault) == null) {
reportSchemaError ("e-props-correct.2", new Object[]{nameAtt, element.fDefault.normalizedValue}, elmDecl);
+ element.fDefault = null;
element.setConstraintType(XSConstants.VC_NONE);
}
}
-
+
// 4 If there is an {substitution group affiliation}, the {type definition} of the element declaration must be validly derived from the {type definition} of the {substitution group affiliation}, given the value of the {substitution group exclusions} of the {substitution group affiliation}, as defined in Type Derivation OK (Complex) (3.4.6) (if the {type definition} is complex) or as defined in Type Derivation OK (Simple) (3.14.6) (if the {type definition} is simple).
if (element.fSubGroup != null) {
if (!XSConstraints.checkTypeDerivationOk(element.fType, element.fSubGroup.fType, element.fSubGroup.fFinal)) {
reportSchemaError ("e-props-correct.4", new Object[]{nameAtt, subGroupAtt.prefix+":"+subGroupAtt.localpart}, elmDecl);
+ element.fSubGroup = null;
}
}
-
+
// 5 If the {type definition} or {type definition}'s {content type} is or is derived from ID then there must not be a {value constraint}.
if (element.fDefault != null) {
if ((elementType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE &&
@@ -489,19 +520,46 @@
(elementType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE &&
((XSComplexTypeDecl)elementType).containsTypeID())) {
reportSchemaError ("e-props-correct.5", new Object[]{element.fName}, elmDecl);
+ element.fDefault = null;
+ element.setConstraintType(XSConstants.VC_NONE);
}
}
-
+
// Element without a name. Return null.
if (element.fName == null)
return null;
-
+
+ // Step 5: register the element decl to the grammar
+ if (isGlobal) {
+ grammar.addGlobalElementDeclAll(element);
+
+ if (grammar.getGlobalElementDecl(element.fName) == null) {
+ grammar.addGlobalElementDecl(element);
+ }
+
+ // we also add the element to the tolerate duplicates list as well
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSElementDecl element2 = grammar.getGlobalElementDecl(element.fName, loc);
+ if (element2 == null) {
+ grammar.addGlobalElementDecl(element, loc);
+ }
+
+ // if we are tolerating duplicates, and we found a duplicate declaration
+ // use the duplicate one instead
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (element2 != null) {
+ element = element2;
+ }
+ fSchemaHandler.addGlobalElementDecl(element);
+ }
+ }
+
return element;
}
-
+
void reset(SymbolTable symbolTable, boolean validateAnnotations, Locale locale) {
super.reset(symbolTable, validateAnnotations, locale);
fDeferTraversingLocalElements = true;
} // reset()
-
+
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -22,13 +22,16 @@
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
import com.sun.org.apache.xerces.internal.impl.xs.XSAnnotationImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.XSConstraints;
import com.sun.org.apache.xerces.internal.impl.xs.XSGroupDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl;
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import org.w3c.dom.Element;
/**
@@ -39,11 +42,12 @@
* Content: (annotation?, (all | choice | sequence))
*
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
* @author Lisa Martin, IBM
+ * @version $Id: XSDGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDGroupTraverser extends XSDAbstractParticleTraverser {
@@ -75,13 +79,19 @@
group = (XSGroupDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.GROUP_TYPE, refAttr, elmNode);
}
+ XSAnnotationImpl annotation = null;
// no children other than "annotation?" are allowed
Element child = DOMUtil.getFirstChildElement(elmNode);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: put this somewhere
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
+ else {
+ String text = DOMUtil.getSyntheticAnnotation(elmNode);
+ if (text != null) {
+ annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc);
+ }
+ }
if (child != null) {
reportSchemaError("s4s-elt-must-match.1", new Object[]{"group (local)", "(annotation?)", DOMUtil.getLocalName(elmNode)}, elmNode);
@@ -105,6 +115,24 @@
particle.fValue = group.fModelGroup;
particle.fMinOccurs = minOccurs;
particle.fMaxOccurs = maxOccurs;
+ if (group.fModelGroup.fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
+ Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
+ particle = checkOccurrences(particle, SchemaSymbols.ELT_GROUP,
+ (Element)elmNode.getParentNode(), GROUP_REF_WITH_ALL,
+ defaultVals.longValue());
+ }
+ if (refAttr != null) {
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ particle.fAnnotations = annotations;
+ } else {
+ particle.fAnnotations = group.fAnnotations;
+ }
}
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
@@ -127,7 +155,9 @@
reportSchemaError("s4s-att-must-appear", new Object[]{"group (global)", "name"}, elmNode);
}
- XSGroupDecl group = null;
+ // Create the group defi up-front, so it can be passed
+ // to the traversal methods
+ XSGroupDecl group = new XSGroupDecl();
XSParticleDecl particle = null;
// must have at least one child
@@ -138,10 +168,6 @@
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))"},
elmNode);
} else {
- // Create the group defi up-front, so it can be passed
- // to the traversal methods
- group = new XSGroupDecl();
-
String childName = l_elmChild.getLocalName();
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
annotation = traverseAnnotationDecl(l_elmChild, attrValues, true, schemaDoc);
@@ -179,28 +205,56 @@
DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(l_elmChild))},
DOMUtil.getNextSiblingElement(l_elmChild));
}
+ }
- // add global group declaration to the grammar
- if (strNameAttr != null) {
- group.fName = strNameAttr;
- group.fTargetNamespace = schemaDoc.fTargetNamespace;
- if (particle != null)
- group.fModelGroup = (XSModelGroupImpl)particle.fValue;
- group.fAnnotation = annotation;
+ // add global group declaration to the grammar
+ if (strNameAttr != null) {
+ group.fName = strNameAttr;
+ group.fTargetNamespace = schemaDoc.fTargetNamespace;
+ if (particle == null) {
+ particle = XSConstraints.getEmptySequence();
+ }
+ group.fModelGroup = (XSModelGroupImpl)particle.fValue;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ group.fAnnotations = annotations;
+ // Add group declaration to grammar
+ if (grammar.getGlobalGroupDecl(group.fName) == null) {
grammar.addGlobalGroupDecl(group);
}
- else {
- // name attribute is not there, don't return this group.
- group = null;
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSGroupDecl group2 = grammar.getGlobalGroupDecl(group.fName, loc);
+ if (group2 == null) {
+ grammar.addGlobalGroupDecl(group, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (group2 != null) {
+ group = group2;
+ }
+ fSchemaHandler.addGlobalGroupDecl(group);
}
}
- if(group != null) {
+ else {
+ // name attribute is not there, don't return this group.
+ group = null;
+ }
+
+ 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(XMLSymbols.EMPTY_STRING, strNameAttr, strNameAttr, schemaDoc.fTargetNamespace),
schemaDoc, elmNode);
- if(redefinedGrp != null) {
+ if (redefinedGrp != null) {
// store in grammar
grammar.addRedefinedGroupDecl(group, (XSGroupDecl)redefinedGrp,
fSchemaHandler.element2Locator(elmNode));
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Wed Sep 28 17:36:24 2011 +0100
@@ -23,19 +23,28 @@
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Stack;
import java.util.Vector;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+import com.sun.org.apache.xerces.internal.impl.dv.SchemaDVFactory;
+import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader;
+import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDecl;
+import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeGroupDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSDDescription;
import com.sun.org.apache.xerces.internal.impl.xs.XSDeclarationPool;
@@ -44,23 +53,30 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSGroupDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl;
+import com.sun.org.apache.xerces.internal.impl.xs.XSNotationDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
+import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl;
import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser;
import com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig;
import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator;
-
-import com.sun.org.apache.xerces.internal.util.DOMUtil;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSInputSource;
import com.sun.org.apache.xerces.internal.parsers.SAXParser;
import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
import com.sun.org.apache.xerces.internal.util.DOMInputSource;
+import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
+import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXInputSource;
import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.util.StAXInputSource;
+import com.sun.org.apache.xerces.internal.util.StAXLocationWrapper;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
import com.sun.org.apache.xerces.internal.xni.QName;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
@@ -70,17 +86,32 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+import com.sun.org.apache.xerces.internal.xs.StringList;
+import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
+import com.sun.org.apache.xerces.internal.xs.XSAttributeGroupDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSAttributeUse;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
+import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
+import com.sun.org.apache.xerces.internal.xs.XSModelGroup;
+import com.sun.org.apache.xerces.internal.xs.XSModelGroupDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSNamedMap;
import com.sun.org.apache.xerces.internal.xs.XSObject;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import com.sun.org.apache.xerces.internal.xs.XSParticle;
+import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
+import com.sun.org.apache.xerces.internal.xs.XSTerm;
+import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
+import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
-
/**
* The purpose of this class is to co-ordinate the construction of a
* grammar object corresponding to a schema. To do this, it must be
@@ -94,85 +125,93 @@
* @author Neil Graham, IBM
* @author Pavani Mukthipudi, Sun Microsystems
*
- * @version $Id: XSDHandler.java,v 1.7 2010/07/23 02:09:30 joehw Exp $
+ * @version $Id: XSDHandler.java,v 1.9 2010-11-01 04:40:02 joehw Exp $
*/
public class XSDHandler {
-
+
/** Feature identifier: validation. */
protected static final String VALIDATION =
Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
-
+
/** feature identifier: XML Schema validation */
protected static final String XMLSCHEMA_VALIDATION =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
-
+
/** Feature identifier: allow java encodings */
protected static final String ALLOW_JAVA_ENCODINGS =
Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
-
+
/** Feature identifier: continue after fatal error */
protected static final String CONTINUE_AFTER_FATAL_ERROR =
Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
-
+
/** Feature identifier: allow java encodings */
protected static final String STANDARD_URI_CONFORMANT_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.STANDARD_URI_CONFORMANT_FEATURE;
-
+
/** Feature: disallow doctype*/
protected static final String DISALLOW_DOCTYPE =
Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
-
+
/** Feature: generate synthetic annotations */
- protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =
+ protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;
-
+
/** Feature identifier: validate annotations. */
protected static final String VALIDATE_ANNOTATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE;
-
+
/** Feature identifier: honour all schemaLocations */
- protected static final String HONOUR_ALL_SCHEMALOCATIONS =
+ protected static final String HONOUR_ALL_SCHEMALOCATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
-
+
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
/** Feature identifier: namespace prefixes. */
private static final String NAMESPACE_PREFIXES =
Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
-
+
/** Feature identifier: string interning. */
protected static final String STRING_INTERNING =
Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_FEATURE;
-
+
/** Property identifier: error handler. */
protected static final String ERROR_HANDLER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
-
+
/** Property identifier: JAXP schema source. */
protected static final String JAXP_SCHEMA_SOURCE =
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
-
+
/** Property identifier: entity resolver. */
public static final String ENTITY_RESOLVER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
/** Property identifier: entity manager. */
protected static final String ENTITY_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
-
+
/** Property identifier: error reporter. */
public static final String ERROR_REPORTER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
-
+
/** Property identifier: grammar pool. */
public static final String XMLGRAMMAR_POOL =
Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
-
+
/** Property identifier: symbol table. */
public static final String SYMBOL_TABLE =
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
-
+
/** Property identifier: security manager. */
protected static final String SECURITY_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
-
+
private static final String SECURE_PROCESSING =
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
@@ -181,9 +220,9 @@
Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
protected static final boolean DEBUG_NODE_POOL = false;
-
+
// Data
-
+
// different sorts of declarations; should make lookup and
// traverser calling more efficient/less bulky.
final static int ATTRIBUTE_TYPE = 1;
@@ -193,26 +232,25 @@
final static int IDENTITYCONSTRAINT_TYPE = 5;
final static int NOTATION_TYPE = 6;
final static int TYPEDECL_TYPE = 7;
-
+
// this string gets appended to redefined names; it's purpose is to be
// as unlikely as possible to cause collisions.
public final static String REDEF_IDENTIFIER = "_fn3dktizrknc9pi";
-
+
//
//protected data that can be accessable by any traverser
// stores decl
protected Hashtable fNotationRegistry = new Hashtable();
-
+
protected XSDeclarationPool fDeclPool = null;
-
+
/**
* Security manager in effect.
- *
+ *
* Protected to allow access by any traverser.
*/
protected SecurityManager fSecureProcessing = null;
-
// These tables correspond to the symbol spaces defined in the
// spec.
// They are keyed with a QName (that is, String("URI,localpart) and
@@ -227,7 +265,7 @@
private Hashtable fUnparsedIdentityConstraintRegistry = new Hashtable();
private Hashtable fUnparsedNotationRegistry = new Hashtable();
private Hashtable fUnparsedTypeRegistry = new Hashtable();
- // Compensation for the above hashtables to locate XSDocumentInfo,
+ // Compensation for the above hashtables to locate XSDocumentInfo,
// Since we may take Schema Element directly, so can not get the
// corresponding XSDocumentInfo object just using above hashtables.
private Hashtable fUnparsedAttributeRegistrySub = new Hashtable();
@@ -237,7 +275,20 @@
private Hashtable fUnparsedIdentityConstraintRegistrySub = new Hashtable();
private Hashtable fUnparsedNotationRegistrySub = new Hashtable();
private Hashtable fUnparsedTypeRegistrySub = new Hashtable();
-
+
+ // Stores XSDocumentInfo (keyed by component name), to check for duplicate
+ // components declared within the same xsd document
+ private Hashtable fUnparsedRegistriesExt[] = new Hashtable[] {
+ null,
+ new Hashtable(), // ATTRIBUTE_TYPE
+ new Hashtable(), // ATTRIBUTEGROUP_TYPE
+ new Hashtable(), // ELEMENT_TYPE
+ new Hashtable(), // GROUP_TYPE
+ new Hashtable(), // IDENTITYCONSTRAINT_TYPE
+ new Hashtable(), // NOTATION_TYPE
+ new Hashtable(), // TYPEDECL_TYPE
+ };
+
// this is keyed with a documentNode (or the schemaRoot nodes
// contained in the XSDocumentInfo objects) and its value is the
// XSDocumentInfo object corresponding to that document.
@@ -245,12 +296,12 @@
// between the nodes we fetch from calls to the fUnparsed*
// arrays and the XSDocumentInfos they live in.
private Hashtable fXSDocumentInfoRegistry = new Hashtable();
-
+
// this hashtable is keyed on by XSDocumentInfo objects. Its values
// are Vectors containing the XSDocumentInfo objects d,
// ed or d by the key XSDocumentInfo.
private Hashtable fDependencyMap = new Hashtable();
-
+
// this hashtable is keyed on by a target namespace. Its values
// are Vectors containing namespaces imported by schema documents
// with the key target namespace.
@@ -262,11 +313,11 @@
private Vector fAllTNSs = new Vector();
// stores instance document mappings between namespaces and schema hints
private Hashtable fLocationPairs = null;
-
- //this hashtable is keyded on by DOM node objects.
- //The table stores the hidden nodes
- private Hashtable fHiddenNodes = null;
-
+ private static final Hashtable EMPTY_TABLE = new Hashtable();
+
+ // Records which nodes are hidden when the input is a DOMInputSource.
+ Hashtable fHiddenNodes = null;
+
// convenience methods
private String null2EmptyString(String ns) {
return ns == null ? XMLSymbols.EMPTY_STRING : ns;
@@ -285,32 +336,32 @@
}
return documentURI != null ? documentURI : (String) fDoc2SystemId.get(ele);
}
-
+
// This vector stores strings which are combinations of the
// publicId and systemId of the inputSource corresponding to a
// schema document. This combination is used so that the user's
// EntityResolver can provide a consistent way of identifying a
// schema document that is included in multiple other schemas.
private Hashtable fTraversed = new Hashtable();
-
+
// this hashtable contains a mapping from Schema Element to its systemId
// this is useful to resolve a uri relative to the referring document
private Hashtable fDoc2SystemId = new Hashtable();
-
+
// the primary XSDocumentInfo we were called to parse
private XSDocumentInfo fRoot = null;
-
+
// This hashtable's job is to act as a link between the Schema Element and its
// XSDocumentInfo object.
private Hashtable fDoc2XSDocumentMap = new Hashtable();
-
+
// map between elements and the XSDocumentInfo
// objects that correspond to the documents being redefined.
private Hashtable fRedefine2XSDMap = new Hashtable();
-
+
// map between elements and the namespace support
private Hashtable fRedefine2NSSupport = new Hashtable();
-
+
// these objects store a mapping between the names of redefining
// groups/attributeGroups and the groups/AttributeGroups which
// they redefine by restriction (implicitly). It is up to the
@@ -318,36 +369,42 @@
// validity.
private Hashtable fRedefinedRestrictedAttributeGroupRegistry = new Hashtable();
private Hashtable fRedefinedRestrictedGroupRegistry = new Hashtable();
-
+
// a variable storing whether the last schema document
// processed (by getSchema) was a duplicate.
private boolean fLastSchemaWasDuplicate;
-
+
// validate annotations feature
private boolean fValidateAnnotations = false;
-
+
//handle multiple import feature
private boolean fHonourAllSchemaLocations = false;
+ //handle namespace growth feature
+ boolean fNamespaceGrowth = false;
+
+ // handle tolerate duplicates feature
+ boolean fTolerateDuplicates = false;
+
// the XMLErrorReporter
private XMLErrorReporter fErrorReporter;
private XMLEntityResolver fEntityResolver;
-
+
// the XSAttributeChecker
private XSAttributeChecker fAttributeChecker;
-
+
// the symbol table
private SymbolTable fSymbolTable;
-
+
// the GrammarResolver
private XSGrammarBucket fGrammarBucket;
-
+
// the Grammar description
private XSDDescription fSchemaGrammarDescription;
-
+
// the Grammar Pool
private XMLGrammarPool fGrammarPool;
-
+
//************ Traversers **********
XSDAttributeGroupTraverser fAttributeGroupTraverser;
XSDAttributeTraverser fAttributeTraverser;
@@ -359,63 +416,74 @@
XSDSimpleTypeTraverser fSimpleTypeTraverser;
XSDUniqueOrKeyTraverser fUniqueOrKeyTraverser;
XSDWildcardTraverser fWildCardTraverser;
-
+
+ SchemaDVFactory fDVFactory;
SchemaDOMParser fSchemaParser;
SchemaContentHandler fXSContentHandler;
+ StAXSchemaParser fStAXSchemaParser;
XML11Configuration fAnnotationValidator;
XSAnnotationGrammarPool fGrammarBucketAdapter;
-
+
// these data members are needed for the deferred traversal
// of local elements.
-
+
// the initial size of the array to store deferred local elements
private static final int INIT_STACK_SIZE = 30;
// the incremental size of the array to store deferred local elements
private static final int INC_STACK_SIZE = 10;
// current position of the array (# of deferred local elements)
private int fLocalElemStackPos = 0;
-
+
private XSParticleDecl[] fParticle = new XSParticleDecl[INIT_STACK_SIZE];
private Element[] fLocalElementDecl = new Element[INIT_STACK_SIZE];
private XSDocumentInfo[] fLocalElementDecl_schema = new XSDocumentInfo[INIT_STACK_SIZE]; //JACK
private int[] fAllContext = new int[INIT_STACK_SIZE];
private XSObject[] fParent = new XSObject[INIT_STACK_SIZE];
private String [][] fLocalElemNamespaceContext = new String [INIT_STACK_SIZE][1];
-
+
// these data members are needed for the deferred traversal
// of keyrefs.
-
+
// the initial size of the array to store deferred keyrefs
private static final int INIT_KEYREF_STACK = 2;
// the incremental size of the array to store deferred keyrefs
private static final int INC_KEYREF_STACK_AMOUNT = 2;
// current position of the array (# of deferred keyrefs)
private int fKeyrefStackPos = 0;
-
+
private Element [] fKeyrefs = new Element[INIT_KEYREF_STACK];
private XSDocumentInfo [] fKeyrefsMapXSDocumentInfo = new XSDocumentInfo[INIT_KEYREF_STACK];
private XSElementDecl [] fKeyrefElems = new XSElementDecl [INIT_KEYREF_STACK];
private String [][] fKeyrefNamespaceContext = new String[INIT_KEYREF_STACK][1];
-
+
+ // global decls: map from decl name to decl object
+ SymbolHash fGlobalAttrDecls = new SymbolHash();
+ SymbolHash fGlobalAttrGrpDecls = new SymbolHash();
+ SymbolHash fGlobalElemDecls = new SymbolHash();
+ SymbolHash fGlobalGroupDecls = new SymbolHash();
+ SymbolHash fGlobalNotationDecls = new SymbolHash();
+ SymbolHash fGlobalIDConstraintDecls = new SymbolHash();
+ SymbolHash fGlobalTypeDecls = new SymbolHash();
+
// Constructors
public XSDHandler(){
- fHiddenNodes = new Hashtable();
+ fHiddenNodes = new Hashtable();
fSchemaParser = new SchemaDOMParser(new SchemaParsingConfig());
}
-
+
// it should be possible to use the same XSDHandler to parse
// multiple schema documents; this will allow one to be
// constructed.
public XSDHandler (XSGrammarBucket gBucket) {
this();
fGrammarBucket = gBucket;
-
+
// Note: don't use SchemaConfiguration internally
// we will get stack overflaw because
// XMLSchemaValidator will be instantiating XSDHandler...
fSchemaGrammarDescription = new XSDDescription();
} // end constructor
-
+
/**
* This method initiates the parse of a schema. It will likely be
* called from the Validator and it will make the
@@ -424,17 +492,18 @@
* @param is
* @param desc
* @param locationPairs
- * @return
+ * @return the SchemaGrammar
* @throws IOException
*/
public SchemaGrammar parseSchema(XMLInputSource is, XSDDescription desc,
Hashtable locationPairs)
throws IOException {
fLocationPairs = locationPairs;
- fSchemaParser.resetNodePool();
+ fSchemaParser.resetNodePool();
SchemaGrammar grammar = null;
String schemaNamespace = null;
short referType = desc.getContextType();
+
// if loading using JAXP schemaSource property, or using grammar caching loadGrammar
// the desc.targetNamespace is always null.
// Therefore we should not attempt to find out if
@@ -443,112 +512,75 @@
// no namespace schema.
if (referType != XSDDescription.CONTEXT_PREPARSE){
// first try to find it in the bucket/pool, return if one is found
- if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT && isExistingGrammar(desc)) {
+ if (fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT && isExistingGrammar(desc, fNamespaceGrowth)) {
grammar = fGrammarBucket.getGrammar(desc.getTargetNamespace());
}
else {
- grammar = findGrammar(desc);
+ grammar = findGrammar(desc, fNamespaceGrowth);
}
- if (grammar != null)
- return grammar;
+ if (grammar != null) {
+ if (!fNamespaceGrowth) {
+ return grammar;
+ }
+ else {
+ try {
+ if (grammar.getDocumentLocations().contains(XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false))) {
+ return grammar;
+ }
+ }
+ catch (MalformedURIException e) {
+ //REVISIT: return the grammar?
+ }
+ }
+ }
+
schemaNamespace = desc.getTargetNamespace();
// handle empty string URI as null
if (schemaNamespace != null) {
schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
}
}
-
+
// before parsing a schema, need to clear registries associated with
// parsing schemas
- prepareForParse();
-
- Document schemaRootDoc = null;
+ prepareForParse();
+
Element schemaRoot = null;
// first phase: construct trees.
if (is instanceof DOMInputSource) {
- //clean up the field fHiddenNodes, used for DOMInputSource
- fHiddenNodes.clear();
- Node domNode = ((DOMInputSource)is).getNode();
-
- if (domNode instanceof Document) {
- schemaRootDoc = (Document)domNode;
- schemaRoot = DOMUtil.getRoot(schemaRootDoc);
- }
- else if (domNode instanceof Element) {
- schemaRoot = (Element)domNode;
- }
- else {
- return null;
- }
+ schemaRoot = getSchemaDocument(schemaNamespace, (DOMInputSource) is,
+ referType == XSDDescription.CONTEXT_PREPARSE,
+ referType, null);
} // DOMInputSource
else if (is instanceof SAXInputSource) {
- XMLReader parser = ((SAXInputSource)is).getXMLReader();
- InputSource inputSource = ((SAXInputSource)is).getInputSource();
- boolean namespacePrefixes = false;
- if (parser != null) {
- try {
- namespacePrefixes = parser.getFeature(NAMESPACE_PREFIXES);
- }
- catch (SAXException se) {}
- }
- else {
- try {
- parser = XMLReaderFactory.createXMLReader();
- }
- // If something went wrong with the factory
- // just use our own SAX parser.
- catch (SAXException se) {
- parser = new SAXParser();
- }
- try {
- parser.setFeature(NAMESPACE_PREFIXES, true);
- namespacePrefixes = true;
- }
- catch (SAXException se) {}
- }
- // If XML names and Namespace URIs are already internalized we
- // can avoid running them through the SymbolTable.
- boolean stringsInternalized = false;
- try {
- stringsInternalized = parser.getFeature(STRING_INTERNING);
- }
- catch (SAXException exc) {
- // The feature isn't recognized or getting it is not supported.
- // In either case, assume that strings are not internalized.
- }
- if (fXSContentHandler == null) {
- fXSContentHandler = new SchemaContentHandler();
- }
- fXSContentHandler.reset(fSchemaParser, fSymbolTable,
- namespacePrefixes, stringsInternalized);
- parser.setContentHandler(fXSContentHandler);
- parser.setErrorHandler(fErrorReporter.getSAXErrorHandler());
- try {
- parser.parse(inputSource);
- }
- catch (SAXException se) {
- return null;
- }
- schemaRootDoc = fXSContentHandler.getDocument();
- if (schemaRootDoc == null) {
- // something went wrong right off the hop
- return null;
- }
- schemaRoot = DOMUtil.getRoot(schemaRootDoc);
- }
+ schemaRoot = getSchemaDocument(schemaNamespace, (SAXInputSource) is,
+ referType == XSDDescription.CONTEXT_PREPARSE,
+ referType, null);
+ } // SAXInputSource
+ else if (is instanceof StAXInputSource) {
+ schemaRoot = getSchemaDocument(schemaNamespace, (StAXInputSource) is,
+ referType == XSDDescription.CONTEXT_PREPARSE,
+ referType, null);
+ } // StAXInputSource
+ else if (is instanceof XSInputSource) {
+ schemaRoot = getSchemaDocument((XSInputSource) is, desc);
+ } // XSInputSource
else {
schemaRoot = getSchemaDocument(schemaNamespace, is,
referType == XSDDescription.CONTEXT_PREPARSE,
referType, null);
-
- }//is instanceof XMLInputSource
-
- if(schemaRoot == null){
+
+ } //is instanceof XMLInputSource
+
+ if (schemaRoot == null) {
// something went wrong right off the hop
- return null;
- }
-
- if ( referType == XSDDescription.CONTEXT_PREPARSE) {
+ if (is instanceof XSInputSource) {
+ return fGrammarBucket.getGrammar(desc.getTargetNamespace());
+ }
+ return grammar;
+ }
+
+ if (referType == XSDDescription.CONTEXT_PREPARSE) {
Element schemaElem = schemaRoot;
schemaNamespace = DOMUtil.getAttrValue(schemaElem, SchemaSymbols.ATT_TARGETNAMESPACE);
if(schemaNamespace != null && schemaNamespace.length() > 0) {
@@ -560,43 +592,49 @@
else {
schemaNamespace = null;
}
- grammar = findGrammar(desc);
- if (grammar != null)
- return grammar;
+ grammar = findGrammar(desc, fNamespaceGrowth);
String schemaId = XMLEntityManager.expandSystemId(is.getSystemId(), is.getBaseSystemId(), false);
+ if (grammar != null) {
+ // When namespace growth is enabled and a null location is provided we cannot tell
+ // whether we've loaded this schema document before so we must assume that we haven't.
+ if (!fNamespaceGrowth || (schemaId != null && grammar.getDocumentLocations().contains(schemaId))) {
+ return grammar;
+ }
+ }
+
XSDKey key = new XSDKey(schemaId, referType, schemaNamespace);
fTraversed.put(key, schemaRoot);
if (schemaId != null) {
fDoc2SystemId.put(schemaRoot, schemaId);
}
}
-
+
// before constructing trees and traversing a schema, need to reset
// all traversers and clear all registries
prepareForTraverse();
-
- fRoot = constructTrees(schemaRoot, is.getSystemId(), desc);
+
+ fRoot = constructTrees(schemaRoot, is.getSystemId(), desc, grammar != null);
if (fRoot == null) {
return null;
}
-
+
// second phase: fill global registries.
buildGlobalNameRegistries();
-
+
// third phase: call traversers
ArrayList annotationInfo = fValidateAnnotations ? new ArrayList() : null;
traverseSchemas(annotationInfo);
-
+
// fourth phase: handle local element decls
traverseLocalElements();
-
+
// fifth phase: handle Keyrefs
resolveKeyRefs();
-
+
// sixth phase: validate attribute of non-schema namespaces
// REVISIT: skip this for now. we really don't want to do it.
//fAttributeChecker.checkNonSchemaAttributes(fGrammarBucket);
-
+
// seventh phase: store imported grammars
// for all grammars with s
for (int i = fAllTNSs.size() - 1; i >= 0; i--) {
@@ -622,7 +660,7 @@
// set the imported grammars
sg.setImportedGrammars(ins);
}
-
+
/** validate annotations **/
if (fValidateAnnotations && annotationInfo.size() > 0) {
validateAnnotations(annotationInfo);
@@ -631,7 +669,7 @@
// and return.
return fGrammarBucket.getGrammar(fRoot.fTargetNamespace);
} // end parseSchema
-
+
private void validateAnnotations(ArrayList annotationInfo) {
if (fAnnotationValidator == null) {
createAnnotationValidator();
@@ -652,7 +690,7 @@
}
}
}
-
+
private void createAnnotationValidator() {
fAnnotationValidator = new XML11Configuration();
fGrammarBucketAdapter = new XSAnnotationGrammarPool();
@@ -674,13 +712,13 @@
SchemaGrammar getGrammar(String tns) {
return fGrammarBucket.getGrammar(tns);
}
-
+
/**
* First try to find a grammar in the bucket, if failed, consult the
* grammar pool. If a grammar is found in the pool, then add it (and all
* imported ones) into the bucket.
*/
- protected SchemaGrammar findGrammar(XSDDescription desc) {
+ protected SchemaGrammar findGrammar(XSDDescription desc, boolean ignoreConflict) {
SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
if (sg == null) {
if (fGrammarPool != null) {
@@ -688,7 +726,7 @@
if (sg != null) {
// put this grammar into the bucket, along with grammars
// imported by it (directly or indirectly)
- if (!fGrammarBucket.putGrammar(sg, true)) {
+ if (!fGrammarBucket.putGrammar(sg, true, ignoreConflict)) {
// REVISIT: a conflict between new grammar(s) and grammars
// in the bucket. What to do? A warning? An exception?
reportSchemaWarning("GrammarConflict", null, null);
@@ -699,10 +737,10 @@
}
return sg;
}
-
+
// may wish to have setter methods for ErrorHandler,
// EntityResolver...
-
+
private static final String[][] NS_ERROR_CODES = {
{"src-include.2.1", "src-include.2.1"},
{"src-redefine.3.1", "src-redefine.3.1"},
@@ -713,12 +751,12 @@
{"TargetNamespace.1", "TargetNamespace.2"},
{"TargetNamespace.1", "TargetNamespace.2"}
};
-
+
private static final String[] ELE_ERROR_CODES = {
"src-include.1", "src-redefine.2", "src-import.2", "schema_reference.4",
"schema_reference.4", "schema_reference.4", "schema_reference.4", "schema_reference.4"
};
-
+
// This method does several things:
// It constructs an instance of an XSDocumentInfo object using the
// schemaRoot node. Then, for each ,
@@ -729,11 +767,11 @@
// depends on.
// It also makes sure the targetNamespace of the schema it was
// called to parse is correct.
- protected XSDocumentInfo constructTrees(Element schemaRoot, String locationHint, XSDDescription desc) {
+ protected XSDocumentInfo constructTrees(Element schemaRoot, String locationHint, XSDDescription desc, boolean nsCollision) {
if (schemaRoot == null) return null;
String callerTNS = desc.getTargetNamespace();
short referType = desc.getContextType();
-
+
XSDocumentInfo currSchemaInfo = null;
try {
// note that attributes are freed at end of traverseSchemas()
@@ -752,7 +790,7 @@
schemaRoot);
currSchemaInfo.fTargetNamespace = null;
}
-
+
if (callerTNS != null) {
// the second index to the NS_ERROR_CODES array
// if the caller/expected NS is not absent, we use the first column
@@ -803,18 +841,34 @@
}
// the other cases (callerTNS == currSchemaInfo.fTargetNamespce == null)
// are valid
-
+
// a schema document can always access it's own target namespace
currSchemaInfo.addAllowedNS(currSchemaInfo.fTargetNamespace);
-
+
SchemaGrammar sg = null;
-
- if (referType == XSDDescription.CONTEXT_INCLUDE ||
+
+ // we have a namespace collision
+ if (nsCollision) {
+ SchemaGrammar sg2 = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
+ if (sg2.isImmutable()) {
+ sg = new SchemaGrammar(sg2);
+ fGrammarBucket.putGrammar(sg);
+ // update all the grammars in the bucket to point to the new grammar.
+ updateImportListWith(sg);
+ }
+ else {
+ sg = sg2;
+ }
+
+ // update import list of the new grammar
+ updateImportListFor(sg);
+ }
+ else if (referType == XSDDescription.CONTEXT_INCLUDE ||
referType == XSDDescription.CONTEXT_REDEFINE) {
sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
}
else if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT) {
- sg = findGrammar(desc);
+ sg = findGrammar(desc, false);
if(sg == null) {
sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone(), fSymbolTable);
fGrammarBucket.putGrammar(sg);
@@ -824,15 +878,15 @@
sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone(), fSymbolTable);
fGrammarBucket.putGrammar(sg);
}
-
+
// store the document and its location
// REVISIT: don't expose the DOM tree
sg.addDocument(null, (String)fDoc2SystemId.get(currSchemaInfo.fSchemaElement));
-
+
fDoc2XSDocumentMap.put(schemaRoot, currSchemaInfo);
Vector dependencies = new Vector();
Element rootNode = schemaRoot;
-
+
Element newSchemaRoot = null;
for (Element child = DOMUtil.getFirstChildElement(rootNode);
child != null;
@@ -840,9 +894,10 @@
String schemaNamespace=null;
String schemaHint=null;
String localName = DOMUtil.getLocalName(child);
-
+
short refType = -1;
-
+ boolean importCollision = false;
+
if (localName.equals(SchemaSymbols.ELT_ANNOTATION))
continue;
else if (localName.equals(SchemaSymbols.ELT_IMPORT)) {
@@ -854,11 +909,7 @@
schemaNamespace = (String)importAttrs[XSAttributeChecker.ATTIDX_NAMESPACE];
if (schemaNamespace != null)
schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
- // a document can't import another document with the same namespace
- if (schemaNamespace == currSchemaInfo.fTargetNamespace) {
- reportSchemaError("src-import.1.1", new Object [] {schemaNamespace}, child);
- }
-
+
// check contents and process optional annotations
Element importChild = DOMUtil.getFirstChildElement(child);
if(importChild != null ) {
@@ -881,11 +932,18 @@
}
}
fAttributeChecker.returnAttrArray(importAttrs, currSchemaInfo);
-
+
+ // a document can't import another document with the same namespace
+ if (schemaNamespace == currSchemaInfo.fTargetNamespace) {
+ reportSchemaError(schemaNamespace != null ?
+ "src-import.1.1" : "src-import.1.2", new Object [] {schemaNamespace}, child);
+ continue;
+ }
+
// if this namespace has not been imported by this document,
// then import if multiple imports support is enabled.
if(currSchemaInfo.isAllowedNS(schemaNamespace)) {
- if(!fHonourAllSchemaLocations)
+ if(!fHonourAllSchemaLocations && !fNamespaceGrowth)
continue;
}
else {
@@ -907,18 +965,43 @@
else if (!ins.contains(schemaNamespace)){
ins.addElement(schemaNamespace);
}
-
+
fSchemaGrammarDescription.reset();
fSchemaGrammarDescription.setContextType(XSDDescription.CONTEXT_IMPORT);
fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
+ fSchemaGrammarDescription.setLiteralSystemId(schemaHint);
fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
fSchemaGrammarDescription.setTargetNamespace(schemaNamespace);
-
+
// if a grammar with the same namespace and location exists (or being
// built), ignore this one (don't traverse it).
- if ((!fHonourAllSchemaLocations && findGrammar(fSchemaGrammarDescription) != null) || isExistingGrammar(fSchemaGrammarDescription))
- continue;
- newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child);
+ SchemaGrammar isg = findGrammar(fSchemaGrammarDescription, fNamespaceGrowth);
+ if (isg != null) {
+ if (fNamespaceGrowth) {
+ try {
+ if (isg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(schemaHint, fSchemaGrammarDescription.getBaseSystemId(), false))) {
+ continue;
+ }
+ else {
+ importCollision = true;
+ }
+ }
+ catch (MalformedURIException e) {
+ }
+ }
+ else if (!fHonourAllSchemaLocations || isExistingGrammar(fSchemaGrammarDescription, false)) {
+ continue;
+ }
+ }
+ //if ((!fHonourAllSchemaLocations && findGrammar(fSchemaGrammarDescription) != null) || isExistingGrammar(fSchemaGrammarDescription))
+ // continue;
+
+ // If "findGrammar" returns a grammar, then this is not the
+ // the first time we see a location for a given namespace.
+ // Don't consult the location pair hashtable in this case,
+ // otherwise the location will be ignored because it'll get
+ // resolved to the same location as the first hint.
+ newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child, isg == null);
}
else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
(localName.equals(SchemaSymbols.ELT_REDEFINE))) {
@@ -931,7 +1014,7 @@
if (localName.equals(SchemaSymbols.ELT_REDEFINE)) {
fRedefine2NSSupport.put(child, new SchemaNamespaceSupport(currSchemaInfo.fNamespaceSupport));
}
-
+
// check annotations. Must do this here to avoid having to
// re-parse attributes later
if(localName.equals(SchemaSymbols.ELT_INCLUDE)) {
@@ -995,15 +1078,33 @@
fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
fSchemaGrammarDescription.setTargetNamespace(callerTNS);
- newSchemaRoot = resolveSchema(fSchemaGrammarDescription, mustResolve, child);
- schemaNamespace = currSchemaInfo.fTargetNamespace;
+
+ boolean alreadyTraversed = false;
+ XMLInputSource schemaSource = resolveSchemaSource(fSchemaGrammarDescription, mustResolve, child, true);
+ if (fNamespaceGrowth && refType == XSDDescription.CONTEXT_INCLUDE) {
+ try {
+ final String schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
+ alreadyTraversed = sg.getDocumentLocations().contains(schemaId);
+ }
+ catch(MalformedURIException e) {
+
+ }
+ }
+
+ if (!alreadyTraversed) {
+ newSchemaRoot = resolveSchema(schemaSource, fSchemaGrammarDescription, mustResolve, child);
+ schemaNamespace = currSchemaInfo.fTargetNamespace;
+ }
+ else {
+ fLastSchemaWasDuplicate = true;
+ }
}
else {
// no more possibility of schema references in well-formed
// schema...
break;
}
-
+
// If the schema is duplicate, we needn't call constructTrees() again.
// To handle mutual s
XSDocumentInfo newSchemaInfo = null;
@@ -1011,9 +1112,9 @@
newSchemaInfo = newSchemaRoot == null ? null : (XSDocumentInfo)fDoc2XSDocumentMap.get(newSchemaRoot);
}
else {
- newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription);
+ newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription, importCollision);
}
-
+
if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
newSchemaInfo != null) {
// must record which schema we're redefining so that we can
@@ -1026,32 +1127,87 @@
newSchemaRoot = null;
}
}
-
+
fDependencyMap.put(currSchemaInfo, dependencies);
return currSchemaInfo;
} // end constructTrees
-
- private boolean isExistingGrammar(XSDDescription desc) {
+
+ private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
- if(sg == null) {
- return findGrammar(desc) != null;
+ if (sg == null) {
+ return findGrammar(desc, ignoreConflict) != null;
+ }
+ else if (sg.isImmutable()) {
+ return true;
}
else {
try {
return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
- } catch (MalformedURIException e) {
+ }
+ catch (MalformedURIException e) {
return false;
}
}
}
-
+
+ /**
+ * Namespace growth
+ *
+ * Go through the import list of a given grammar and for each imported
+ * grammar, check to see if the grammar bucket has a newer version.
+ * If a new instance is found, we update the import list with the
+ * newer version.
+ */
+ private void updateImportListFor(SchemaGrammar grammar) {
+ Vector importedGrammars = grammar.getImportedGrammars();
+ if (importedGrammars != null) {
+ for (int i=0; i use the namespace delcs for it.
@@ -1517,44 +1873,50 @@
nsSupport = (SchemaNamespaceSupport)fRedefine2NSSupport.get(parent);
// back up the current SchemaNamespaceSupport, because we need to provide
// a fresh one to the traverseGlobal methods.
- schemaWithDecl.backupNSSupport(nsSupport);
-
+ schemaDoc.backupNSSupport(nsSupport);
+
// traverse the referenced global component
switch (declType) {
+ case TYPEDECL_TYPE :
+ if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
+ retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+ }
+ else {
+ retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+ }
+ break;
case ATTRIBUTE_TYPE :
- retObj = fAttributeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+ retObj = fAttributeTraverser.traverseGlobal(decl, schemaDoc, grammar);
+ break;
+ case ELEMENT_TYPE :
+ retObj = fElementTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case ATTRIBUTEGROUP_TYPE :
- retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
- break;
- case ELEMENT_TYPE :
- retObj = fElementTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+ retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case GROUP_TYPE :
- retObj = fGroupTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
+ retObj = fGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
+ break;
+ case NOTATION_TYPE :
+ retObj = fNotationTraverser.traverse(decl, schemaDoc, grammar);
break;
case IDENTITYCONSTRAINT_TYPE :
// identity constraints should have been parsed already...
// we should never get here
- retObj = null;
break;
- case NOTATION_TYPE :
- retObj = fNotationTraverser.traverse(decl, schemaWithDecl, sGrammar);
- break;
- case TYPEDECL_TYPE :
- if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE))
- retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
- else
- retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaWithDecl, sGrammar);
}
-
+
// restore the previous SchemaNamespaceSupport, so that the caller can get
// proper namespace binding.
- schemaWithDecl.restoreNSSupport();
-
+ schemaDoc.restoreNSSupport();
+
return retObj;
- } // getGlobalDecl(XSDocumentInfo, int, QName): Object
-
+ }
+
+ public String schemaDocument2SystemId(XSDocumentInfo schemaDoc) {
+ return (String)fDoc2SystemId.get(schemaDoc.fSchemaElement);
+ }
+
// This method determines whether there is a group
// (attributeGroup) which the given one has redefined by
// restriction. If so, it returns it; else it returns null.
@@ -1596,7 +1958,7 @@
}
return retObj;
} // getGrpOrAttrGrpRedefinedByRestriction(int, QName, XSDocumentInfo): Object
-
+
// Since ID constraints can occur in local elements, unless we
// wish to completely traverse all our DOM trees looking for ID
// constraints while we're building our global name registries,
@@ -1618,19 +1980,19 @@
fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar);
}
} // end resolveKeyRefs
-
+
// an accessor method. Just makes sure callers
// who want the Identity constraint registry vaguely know what they're about.
protected Hashtable getIDRegistry() {
return fUnparsedIdentityConstraintRegistry;
}
- // an accessor method.
+ // an accessor method.
protected Hashtable getIDRegistry_sub() {
return fUnparsedIdentityConstraintRegistrySub;
}
-
-
-
+
+
+
// This method squirrels away declarations--along with the element
// decls and namespace bindings they might find handy.
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
@@ -1639,10 +2001,10 @@
if (keyrefName.length() != 0) {
String keyrefQName = schemaDoc.fTargetNamespace == null?
"," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
- checkForDuplicateNames(keyrefQName, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
+ checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
}
// now set up all the registries we'll need...
-
+
// check array sizes
if (fKeyrefStackPos == fKeyrefs.length) {
Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
@@ -1654,20 +2016,20 @@
String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
fKeyrefNamespaceContext = stringArray;
-
+
XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
fKeyrefsMapXSDocumentInfo = xsDocumentInfo;
-
+
}
fKeyrefs[fKeyrefStackPos] = keyrefToStore;
fKeyrefElems[fKeyrefStackPos] = currElemDecl;
fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();
-
- fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
+
+ fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
} // storeKeyref (Element, XSDocumentInfo, XSElementDecl): void
-
-
+
+
/**
* resolveSchema method is responsible for resolving location of the schema (using XMLEntityResolver),
* and if it was succefully resolved getting the schema Document.
@@ -1676,11 +2038,12 @@
* @param referElement
* @return A schema Element or null.
*/
- private Element resolveSchema(XSDDescription desc,
- boolean mustResolve, Element referElement) {
+ private Element resolveSchema(XSDDescription desc, boolean mustResolve,
+ Element referElement, boolean usePairs) {
XMLInputSource schemaSource = null;
try {
- schemaSource = XMLSchemaLoader.resolveDocument(desc, fLocationPairs, fEntityResolver);
+ Hashtable pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
+ schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
}
catch (IOException ex) {
if (mustResolve) {
@@ -1695,80 +2058,62 @@
}
}
if (schemaSource instanceof DOMInputSource) {
- fHiddenNodes.clear();
- Node node = ((DOMInputSource)schemaSource).getNode();
-
- if (node instanceof Document) {
- return DOMUtil.getRoot((Document) node);
- }
- else if (node instanceof Element) {
- return (Element) node;
- }
- else {
- return null;
- }
+ return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // DOMInputSource
+ else if (schemaSource instanceof SAXInputSource) {
+ return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // SAXInputSource
+ else if (schemaSource instanceof StAXInputSource) {
+ return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // StAXInputSource
+ else if (schemaSource instanceof XSInputSource) {
+ return getSchemaDocument((XSInputSource) schemaSource, desc);
+ } // XSInputSource
+ return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // getSchema(String, String, String, boolean, short): Document
+
+ private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
+ boolean mustResolve, Element referElement) {
+
+ if (schemaSource instanceof DOMInputSource) {
+ return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
} // DOMInputSource
else if (schemaSource instanceof SAXInputSource) {
- XMLReader parser = ((SAXInputSource)schemaSource).getXMLReader();
- InputSource inputSource = ((SAXInputSource)schemaSource).getInputSource();
- boolean namespacePrefixes = false;
- if (parser != null) {
- try {
- namespacePrefixes = parser.getFeature(NAMESPACE_PREFIXES);
- }
- catch (SAXException se) {}
+ return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // SAXInputSource
+ else if (schemaSource instanceof StAXInputSource) {
+ return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
+ } // StAXInputSource
+ else if (schemaSource instanceof XSInputSource) {
+ return getSchemaDocument((XSInputSource) schemaSource, desc);
+ } // XSInputSource
+ return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
+ }
+
+ private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
+ Element referElement, boolean usePairs) {
+
+ XMLInputSource schemaSource = null;
+ try {
+ Hashtable pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
+ schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
+ }
+ catch (IOException ex) {
+ if (mustResolve) {
+ reportSchemaError("schema_reference.4",
+ new Object[]{desc.getLocationHints()[0]},
+ referElement);
}
else {
- try {
- parser = XMLReaderFactory.createXMLReader();
- }
- // If something went wrong with the factory
- // just use our own SAX parser.
- catch (SAXException se) {
- parser = new SAXParser();
- }
- try {
- parser.setFeature(NAMESPACE_PREFIXES, true);
- namespacePrefixes = true;
- }
- catch (SAXException se) {}
- }
- // If XML names and Namespace URIs are already internalized we
- // can avoid running them through the SymbolTable.
- boolean stringsInternalized = false;
- try {
- stringsInternalized = parser.getFeature(STRING_INTERNING);
- }
- catch (SAXException exc) {
- // The feature isn't recognized or getting it is not supported.
- // In either case, assume that strings are not internalized.
+ reportSchemaWarning("schema_reference.4",
+ new Object[]{desc.getLocationHints()[0]},
+ referElement);
}
- if (fXSContentHandler == null) {
- fXSContentHandler = new SchemaContentHandler();
- }
- fXSContentHandler.reset(fSchemaParser, fSymbolTable,
- namespacePrefixes, stringsInternalized);
- parser.setContentHandler(fXSContentHandler);
- parser.setErrorHandler(fErrorReporter.getSAXErrorHandler());
- try {
- parser.parse(inputSource);
- }
- catch (SAXException se) {
- return null;
- }
- catch (IOException ioe) {
- return null;
- }
- Document root = fXSContentHandler.getDocument();
- if (root == null) {
- // something went wrong right off the hop
- return null;
- }
- return DOMUtil.getRoot(root);
- }
- return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
- } // getSchema(String, String, String, boolean, short): Document
-
+ }
+
+ return schemaSource;
+ }
+
/**
* getSchemaDocument method uses XMLInputSource to parse a schema document.
* @param schemaNamespace
@@ -1780,8 +2125,9 @@
*/
private Element getSchemaDocument(String schemaNamespace, XMLInputSource schemaSource,
boolean mustResolve, short referType, Element referElement) {
-
+
boolean hasInput = true;
+ IOException exception = null;
// contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
Element schemaElement = null;
try {
@@ -1795,7 +2141,7 @@
(schemaSource.getSystemId() != null ||
schemaSource.getByteStream() != null ||
schemaSource.getCharacterStream() != null)) {
-
+
// When the system id of the input source is used, first try to
// expand it, and check whether the same document has been
// parsed before. If so, return the document corresponding to
@@ -1810,55 +2156,1213 @@
return schemaElement;
}
}
-
+
fSchemaParser.parse(schemaSource);
Document schemaDocument = fSchemaParser.getDocument();
schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
-
- // now we need to store the mapping information from system id
- // to the document. also from the document to the system id.
- if (key != null)
- fTraversed.put(key, schemaElement );
- if (schemaId != null)
- fDoc2SystemId.put(schemaElement, schemaId );
- fLastSchemaWasDuplicate = false;
- return schemaElement;
+ return getSchemaDocument0(key, schemaId, schemaElement);
}
else {
hasInput = false;
}
}
catch (IOException ex) {
+ exception = ex;
}
-
+ return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
+ } // getSchemaDocument(String, XMLInputSource, boolean, short, Element): Element
+
+ /**
+ * getSchemaDocument method uses SAXInputSource to parse a schema document.
+ * @param schemaNamespace
+ * @param schemaSource
+ * @param mustResolve
+ * @param referType
+ * @param referElement
+ * @return A schema Element.
+ */
+ private Element getSchemaDocument(String schemaNamespace, SAXInputSource schemaSource,
+ boolean mustResolve, short referType, Element referElement) {
+ XMLReader parser = schemaSource.getXMLReader();
+ InputSource inputSource = schemaSource.getInputSource();
+ boolean hasInput = true;
+ IOException exception = null;
+ Element schemaElement = null;
+ try {
+ if (inputSource != null &&
+ (inputSource.getSystemId() != null ||
+ inputSource.getByteStream() != null ||
+ inputSource.getCharacterStream() != null)) {
+
+ // check whether the same document has been parsed before.
+ // If so, return the document corresponding to that system id.
+ XSDKey key = null;
+ String schemaId = null;
+ if (referType != XSDDescription.CONTEXT_PREPARSE) {
+ schemaId = XMLEntityManager.expandSystemId(inputSource.getSystemId(), schemaSource.getBaseSystemId(), false);
+ key = new XSDKey(schemaId, referType, schemaNamespace);
+ if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+ fLastSchemaWasDuplicate = true;
+ return schemaElement;
+ }
+ }
+
+ boolean namespacePrefixes = false;
+ if (parser != null) {
+ try {
+ namespacePrefixes = parser.getFeature(NAMESPACE_PREFIXES);
+ }
+ catch (SAXException se) {}
+ }
+ else {
+ try {
+ parser = XMLReaderFactory.createXMLReader();
+ }
+ // If something went wrong with the factory
+ // just use our own SAX parser.
+ catch (SAXException se) {
+ parser = new SAXParser();
+ }
+ try {
+ parser.setFeature(NAMESPACE_PREFIXES, true);
+ namespacePrefixes = true;
+ // If this is a Xerces SAX parser set the security manager if there is one
+ if (parser instanceof SAXParser) {
+ Object securityManager = fSchemaParser.getProperty(SECURITY_MANAGER);
+ if (securityManager != null) {
+ parser.setProperty(SECURITY_MANAGER, securityManager);
+ }
+ }
+ }
+ catch (SAXException se) {}
+ }
+ // If XML names and Namespace URIs are already internalized we
+ // can avoid running them through the SymbolTable.
+ boolean stringsInternalized = false;
+ try {
+ stringsInternalized = parser.getFeature(STRING_INTERNING);
+ }
+ catch (SAXException exc) {
+ // The feature isn't recognized or getting it is not supported.
+ // In either case, assume that strings are not internalized.
+ }
+ if (fXSContentHandler == null) {
+ fXSContentHandler = new SchemaContentHandler();
+ }
+ fXSContentHandler.reset(fSchemaParser, fSymbolTable,
+ namespacePrefixes, stringsInternalized);
+ parser.setContentHandler(fXSContentHandler);
+ parser.setErrorHandler(fErrorReporter.getSAXErrorHandler());
+
+ parser.parse(inputSource);
+ // Disconnect the schema loader and other objects from the XMLReader
+ try {
+ parser.setContentHandler(null);
+ parser.setErrorHandler(null);
+ }
+ // Ignore any exceptions thrown by the XMLReader. Old versions of SAX
+ // required an XMLReader to throw a NullPointerException if an attempt
+ // to set a handler to null was made.
+ catch (Exception e) {}
+
+ Document schemaDocument = fXSContentHandler.getDocument();
+ schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
+ return getSchemaDocument0(key, schemaId, schemaElement);
+ }
+ else {
+ hasInput = false;
+ }
+ }
+ catch (SAXParseException spe) {
+ throw SAX2XNIUtil.createXMLParseException0(spe);
+ }
+ catch (SAXException se) {
+ throw SAX2XNIUtil.createXNIException0(se);
+ }
+ catch (IOException ioe) {
+ exception = ioe;
+ }
+ return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
+ } // getSchemaDocument(String, SAXInputSource, boolean, short, Element): Element
+
+ /**
+ * getSchemaDocument method uses DOMInputSource to parse a schema document.
+ * @param schemaNamespace
+ * @param schemaSource
+ * @param mustResolve
+ * @param referType
+ * @param referElement
+ * @return A schema Element.
+ */
+ private Element getSchemaDocument(String schemaNamespace, DOMInputSource schemaSource,
+ boolean mustResolve, short referType, Element referElement) {
+ boolean hasInput = true;
+ IOException exception = null;
+ Element schemaElement = null;
+ Element schemaRootElement = null;
+
+ final Node node = schemaSource.getNode();
+ short nodeType = -1;
+ if (node != null) {
+ nodeType = node.getNodeType();
+ if (nodeType == Node.DOCUMENT_NODE) {
+ schemaRootElement = DOMUtil.getRoot((Document) node);
+ }
+ else if (nodeType == Node.ELEMENT_NODE) {
+ schemaRootElement = (Element) node;
+ }
+ }
+
+ try {
+ if (schemaRootElement != null) {
+ // check whether the same document has been parsed before.
+ // If so, return the document corresponding to that system id.
+ XSDKey key = null;
+ String schemaId = null;
+ if (referType != XSDDescription.CONTEXT_PREPARSE) {
+ schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
+ boolean isDocument = (nodeType == Node.DOCUMENT_NODE);
+ if (!isDocument) {
+ Node parent = schemaRootElement.getParentNode();
+ if (parent != null) {
+ isDocument = (parent.getNodeType() == Node.DOCUMENT_NODE);
+ }
+ }
+ if (isDocument) {
+ key = new XSDKey(schemaId, referType, schemaNamespace);
+ if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+ fLastSchemaWasDuplicate = true;
+ return schemaElement;
+ }
+ }
+ }
+
+ schemaElement = schemaRootElement;
+ return getSchemaDocument0(key, schemaId, schemaElement);
+ }
+ else {
+ hasInput = false;
+ }
+ }
+ catch (IOException ioe) {
+ exception = ioe;
+ }
+ return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
+ } // getSchemaDocument(String, DOMInputSource, boolean, short, Element): Element
+
+ /**
+ * getSchemaDocument method uses StAXInputSource to parse a schema document.
+ * @param schemaNamespace
+ * @param schemaSource
+ * @param mustResolve
+ * @param referType
+ * @param referElement
+ * @return A schema Element.
+ */
+ private Element getSchemaDocument(String schemaNamespace, StAXInputSource schemaSource,
+ boolean mustResolve, short referType, Element referElement) {
+ IOException exception = null;
+ Element schemaElement = null;
+ try {
+ final boolean consumeRemainingContent = schemaSource.shouldConsumeRemainingContent();
+ final XMLStreamReader streamReader = schemaSource.getXMLStreamReader();
+ final XMLEventReader eventReader = schemaSource.getXMLEventReader();
+
+ // check whether the same document has been parsed before.
+ // If so, return the document corresponding to that system id.
+ XSDKey key = null;
+ String schemaId = null;
+ if (referType != XSDDescription.CONTEXT_PREPARSE) {
+ schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
+ boolean isDocument = consumeRemainingContent;
+ if (!isDocument) {
+ if (streamReader != null) {
+ isDocument = (streamReader.getEventType() == XMLStreamReader.START_DOCUMENT);
+ }
+ else {
+ isDocument = eventReader.peek().isStartDocument();
+ }
+ }
+ if (isDocument) {
+ key = new XSDKey(schemaId, referType, schemaNamespace);
+ if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+ fLastSchemaWasDuplicate = true;
+ return schemaElement;
+ }
+ }
+ }
+
+ if (fStAXSchemaParser == null) {
+ fStAXSchemaParser = new StAXSchemaParser();
+ }
+ fStAXSchemaParser.reset(fSchemaParser, fSymbolTable);
+
+ if (streamReader != null) {
+ fStAXSchemaParser.parse(streamReader);
+ if (consumeRemainingContent) {
+ while (streamReader.hasNext()) {
+ streamReader.next();
+ }
+ }
+ }
+ else {
+ fStAXSchemaParser.parse(eventReader);
+ if (consumeRemainingContent) {
+ while (eventReader.hasNext()) {
+ eventReader.nextEvent();
+ }
+ }
+ }
+ Document schemaDocument = fStAXSchemaParser.getDocument();
+ schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
+ return getSchemaDocument0(key, schemaId, schemaElement);
+ }
+ catch (XMLStreamException e) {
+ StAXLocationWrapper slw = new StAXLocationWrapper();
+ slw.setLocation(e.getLocation());
+ throw new XMLParseException(slw, e.getMessage(), e);
+ }
+ catch (IOException e) {
+ exception = e;
+ }
+ return getSchemaDocument1(mustResolve, true, schemaSource, referElement, exception);
+ } // getSchemaDocument(String, StAXInputSource, boolean, short, Element): Element
+
+ /**
+ * Code shared between the various getSchemaDocument() methods which
+ * stores mapping information for the document.
+ */
+ private Element getSchemaDocument0(XSDKey key, String schemaId, Element schemaElement) {
+ // now we need to store the mapping information from system id
+ // to the document. also from the document to the system id.
+ if (key != null) {
+ fTraversed.put(key, schemaElement);
+ }
+ if (schemaId != null) {
+ fDoc2SystemId.put(schemaElement, schemaId);
+ }
+ fLastSchemaWasDuplicate = false;
+ return schemaElement;
+ } // getSchemaDocument0(XSDKey, String, Element): Element
+
+ /**
+ * Error handling code shared between the various getSchemaDocument() methods.
+ */
+ private Element getSchemaDocument1(boolean mustResolve, boolean hasInput,
+ XMLInputSource schemaSource, Element referElement, IOException ioe) {
// either an error occured (exception), or empty input source was
// returned, we need to report an error or a warning
if (mustResolve) {
if (hasInput) {
reportSchemaError("schema_reference.4",
new Object[]{schemaSource.getSystemId()},
- referElement);
+ referElement, ioe);
}
else {
reportSchemaError("schema_reference.4",
new Object[]{schemaSource == null ? "" : schemaSource.getSystemId()},
- referElement);
+ referElement, ioe);
}
}
else if (hasInput) {
reportSchemaWarning("schema_reference.4",
new Object[]{schemaSource.getSystemId()},
- referElement);
+ referElement, ioe);
}
-
+
fLastSchemaWasDuplicate = false;
return null;
- } // getSchema(String, XMLInputSource, boolean, boolean): Document
-
+ } // getSchemaDocument1(boolean, boolean, XMLInputSource, Element): Element
+
+ /**
+ * getSchemaDocument method uses XMLInputSource to parse a schema document.
+ * @param schemaNamespace
+ * @param schemaSource
+ * @param mustResolve
+ * @param referType
+ * @param referElement
+ * @return A schema Element.
+ */
+ private Element getSchemaDocument(XSInputSource schemaSource, XSDDescription desc) {
+
+ SchemaGrammar[] grammars = schemaSource.getGrammars();
+ short referType = desc.getContextType();
+
+ if (grammars != null && grammars.length > 0) {
+ Vector expandedGrammars = expandGrammars(grammars);
+ // check for existing grammars in our bucket
+ // and if there exist any, and namespace growth is
+ // not enabled - we do nothing
+ if (fNamespaceGrowth || !existingGrammars(expandedGrammars)) {
+ addGrammars(expandedGrammars);
+ if (referType == XSDDescription.CONTEXT_PREPARSE) {
+ desc.setTargetNamespace(grammars[0].getTargetNamespace());
+ }
+ }
+ }
+ else {
+ XSObject[] components = schemaSource.getComponents();
+ if (components != null && components.length > 0) {
+ Hashtable importDependencies = new Hashtable();
+ Vector expandedComponents = expandComponents(components, importDependencies);
+ if (fNamespaceGrowth || canAddComponents(expandedComponents)) {
+ addGlobalComponents(expandedComponents, importDependencies);
+ if (referType == XSDDescription.CONTEXT_PREPARSE) {
+ desc.setTargetNamespace(components[0].getNamespace());
+ }
+ }
+ }
+ }
+ return null;
+ } // getSchemaDocument(String, XSInputSource, boolean, short, Element): Element
+
+ private Vector expandGrammars(SchemaGrammar[] grammars) {
+ Vector currGrammars = new Vector();
+
+ for (int i=0; i= 0; j--) {
+ sg2 = (SchemaGrammar)gs.elementAt(j);
+ if (!currGrammars.contains(sg2)) {
+ currGrammars.addElement(sg2);
+ }
+ }
+ }
+
+ return currGrammars;
+ }
+
+ private boolean existingGrammars(Vector grammars) {
+ int length = grammars.size();
+ final XSDDescription desc = new XSDDescription();
+
+ for (int i=0; i < length; i++) {
+ final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
+ desc.setNamespace(sg1.getTargetNamespace());
+
+ final SchemaGrammar sg2 = findGrammar(desc, false);
+ if (sg2 != null) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private boolean canAddComponents(Vector components) {
+ final int size = components.size();
+ final XSDDescription desc = new XSDDescription();
+ for (int i=0; i 0) {
+ for (int i=0; i 0) {
+ expandImportList(namespace, importList);
+ }
+ }
+ }
+
+ private void expandImportList(String namespace, Vector namespaceList) {
+ SchemaGrammar sg = fGrammarBucket.getGrammar(namespace);
+ // shouldn't be null
+ if (sg != null) {
+ Vector isgs = sg.getImportedGrammars();
+ if (isgs == null) {
+ isgs = new Vector();
+ addImportList(sg, isgs, namespaceList);
+ sg.setImportedGrammars(isgs);
+ }
+ else {
+ updateImportList(sg, isgs, namespaceList);
+ }
+ }
+ }
+
+ private void addImportList(SchemaGrammar sg, Vector importedGrammars, Vector namespaceList) {
+ final int size = namespaceList.size();
+ SchemaGrammar isg;
+
+ for (int i=0; is occur in children of elem
private boolean nonAnnotationContent(Element elem) {
for(Element child = DOMUtil.getFirstChildElement(elem); child != null; child = DOMUtil.getNextSiblingElement(child)) {
@@ -2491,11 +4049,11 @@
}
return false;
} // nonAnnotationContent(Element): boolean
-
+
private void setSchemasVisible(XSDocumentInfo startSchema) {
if (DOMUtil.isHidden(startSchema.fSchemaElement, fHiddenNodes)) {
// make it visible
- DOMUtil.setVisible(startSchema.fSchemaElement, fHiddenNodes);
+ DOMUtil.setVisible(startSchema.fSchemaElement, fHiddenNodes);
Vector dependingSchemas = (Vector)fDependencyMap.get(startSchema);
for (int i = 0; i < dependingSchemas.size(); i++) {
setSchemasVisible((XSDocumentInfo)dependingSchemas.elementAt(i));
@@ -2503,9 +4061,9 @@
}
// if it's visible already than so must be its children
} // setSchemasVisible(XSDocumentInfo): void
-
+
private SimpleLocator xl = new SimpleLocator();
-
+
/**
* Extract location information from an Element node, and create a
* new SimpleLocator object from such information. Returning null means
@@ -2514,11 +4072,11 @@
public SimpleLocator element2Locator(Element e) {
if (!( e instanceof ElementImpl))
return null;
-
+
SimpleLocator l = new SimpleLocator();
return element2Locator(e, l) ? l : null;
}
-
+
/**
* Extract location information from an Element node, store such
* information in the passed-in SimpleLocator object, then return
@@ -2540,30 +4098,38 @@
}
return false;
}
-
+
void reportSchemaFatalError(String key, Object[] args, Element ele) {
- reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_FATAL_ERROR);
+ reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_FATAL_ERROR, null);
}
void reportSchemaError(String key, Object[] args, Element ele) {
- reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR);
+ reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR, null);
}
-
+
+ void reportSchemaError(String key, Object[] args, Element ele, Exception exception) {
+ reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_ERROR, exception);
+ }
+
void reportSchemaWarning(String key, Object[] args, Element ele) {
- reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING);
+ reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING, null);
}
- void reportSchemaErr(String key, Object[] args, Element ele, short type) {
+ void reportSchemaWarning(String key, Object[] args, Element ele, Exception exception) {
+ reportSchemaErr(key, args, ele, XMLErrorReporter.SEVERITY_WARNING, exception);
+ }
+
+ void reportSchemaErr(String key, Object[] args, Element ele, short type, Exception exception) {
if (element2Locator(ele, xl)) {
fErrorReporter.reportError(xl, XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, type);
+ key, args, type, exception);
}
else {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
- key, args, type);
+ key, args, type, exception);
}
}
-
+
/**
* Grammar pool used for validating annotations. This will return all of the
* grammars from the grammar bucket. It will also return an object for the
@@ -2571,19 +4137,19 @@
* for annotations.
*/
private static class XSAnnotationGrammarPool implements XMLGrammarPool {
-
+
private XSGrammarBucket fGrammarBucket;
private Grammar [] fInitialGrammarSet;
-
+
public Grammar[] retrieveInitialGrammarSet(String grammarType) {
if (grammarType == XMLGrammarDescription.XML_SCHEMA) {
if (fInitialGrammarSet == null) {
if (fGrammarBucket == null) {
- fInitialGrammarSet = new Grammar [] {SchemaGrammar.SG_Schema4Annotations};
+ fInitialGrammarSet = new Grammar [] {SchemaGrammar.Schema4Annotations.INSTANCE};
}
else {
SchemaGrammar [] schemaGrammars = fGrammarBucket.getGrammars();
- /**
+ /**
* If the grammar bucket already contains the schema for schemas
* then we already have the definitions for the parts relevant
* to annotations.
@@ -2596,7 +4162,7 @@
}
Grammar [] grammars = new Grammar[schemaGrammars.length + 1];
System.arraycopy(schemaGrammars, 0, grammars, 0, schemaGrammars.length);
- grammars[grammars.length - 1] = SchemaGrammar.SG_Schema4Annotations;
+ grammars[grammars.length - 1] = SchemaGrammar.Schema4Annotations.INSTANCE;
fInitialGrammarSet = grammars;
}
}
@@ -2606,7 +4172,7 @@
}
public void cacheGrammars(String grammarType, Grammar[] grammars) {
-
+
}
public Grammar retrieveGrammar(XMLGrammarDescription desc) {
@@ -2619,12 +4185,12 @@
}
}
if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
- return SchemaGrammar.SG_Schema4Annotations;
+ return SchemaGrammar.Schema4Annotations.INSTANCE;
}
}
return null;
}
-
+
public void refreshGrammars(XSGrammarBucket gBucket) {
fGrammarBucket = gBucket;
fInitialGrammarSet = null;
@@ -2680,50 +4246,59 @@
// for inclue/redefine, this is the enclosing namespace
// for import/preparse/instance, this is the target namespace
String referNS;
-
+
XSDKey(String systemId, short referType, String referNS) {
this.systemId = systemId;
this.referType = referType;
this.referNS = referNS;
}
-
+
public int hashCode() {
// according to the description at the beginning of this class,
// we use the hashcode of the namespace as the hashcoe of this key.
return referNS == null ? 0 : referNS.hashCode();
}
-
+
public boolean equals(Object obj) {
if (!(obj instanceof XSDKey)) {
return false;
}
XSDKey key = (XSDKey)obj;
-
+
// condition 1: both are redefine
- if (referType == XSDDescription.CONTEXT_REDEFINE ||
+ /** if (referType == XSDDescription.CONTEXT_REDEFINE ||
key.referType == XSDDescription.CONTEXT_REDEFINE) {
if (referType != key.referType)
return false;
- }
-
+ }**/
+
// condition 2: same namespace
if (referNS != key.referNS)
return false;
-
- // condition 3: same non-null locatoin
+
+ // condition 3: same non-null location
if (systemId == null || !systemId.equals(key.systemId)) {
return false;
}
-
+
return true;
}
}
-
+
+ private static final class SAX2XNIUtil extends ErrorHandlerWrapper {
+ public static XMLParseException createXMLParseException0(SAXParseException exception) {
+ return createXMLParseException(exception);
+ }
+ public static XNIException createXNIException0(SAXException exception) {
+ return createXNIException(exception);
+ }
+ }
+
/**
* @param state
*/
public void setGenerateSyntheticAnnotations(boolean state) {
fSchemaParser.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, state);
}
-
+
} // XSDHandler
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,9 +32,10 @@
/**
* This class contains code that is used to traverse s.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neil Graham, IBM
+ * @version $Id: XSDKeyrefTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser {
@@ -85,20 +86,41 @@
KeyRef keyRef = new KeyRef(schemaDoc.fTargetNamespace, krName, element.fName, key);
- // add to element decl
- traverseIdentityConstraint(keyRef, krElem, schemaDoc, attrValues);
+ // If errors occurred in traversing the identity constraint, then don't
+ // add it to the schema, to avoid errors when processing the instance.
+ if (traverseIdentityConstraint(keyRef, krElem, schemaDoc, attrValues)) {
+ //Schema Component Constraint: Identity-constraint Definition Properties Correct
+ //2 If the {identity-constraint category} is keyref, the cardinality of the {fields} must equal that of the {fields} of the {referenced key}.
+ if(key.getFieldCount() != keyRef.getFieldCount()) {
+ reportSchemaError("c-props-correct.2" , new Object [] {krName,key.getIdentityConstraintName()}, krElem);
+ } else {
+ // add key reference to element decl
+ // and stuff this in the grammar
+ if (grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName()) == null) {
+ grammar.addIDConstraintDecl(element, keyRef);
+ }
- //Schema Component Constraint: Identity-constraint Definition Properties Correct
- //2 If the {identity-constraint category} is keyref, the cardinality of the {fields} must equal that of the {fields} of the {referenced key}.
- if(key.getFieldCount() != keyRef.getFieldCount()) {
- reportSchemaError("c-props-correct.2" , new Object [] {krName,key.getIdentityConstraintName()}, krElem);
- } else {
- // add key reference to element decl
- // and stuff this in the grammar
- grammar.addIDConstraintDecl(element, keyRef);
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final IdentityConstraint idc = grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName(), loc);
+ if (idc == null) {
+ grammar.addIDConstraintDecl(element, keyRef, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (idc != null) {
+ if (idc instanceof KeyRef) {
+ keyRef = (KeyRef) idc;
+ }
+ }
+ fSchemaHandler.addIDConstraintDecl(keyRef);
+ }
+ }
}
// and put back attributes
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
} // traverse(Element,int,XSDocumentInfo, SchemaGrammar)
} // XSDKeyrefTraverser
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -24,7 +24,9 @@
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
import com.sun.org.apache.xerces.internal.impl.xs.XSAnnotationImpl;
import com.sun.org.apache.xerces.internal.impl.xs.XSNotationDecl;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import org.w3c.dom.Element;
/**
@@ -39,10 +41,11 @@
* Content: (annotation?)
*
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
+ * @version $Id: XSDNotationTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDNotationTraverser extends XSDAbstractTraverser {
@@ -68,8 +71,10 @@
return null;
}
- if (systemAttr == null && publicAttr == null)
+ if (systemAttr == null && publicAttr == null) {
reportSchemaError("PublicSystemOnNotation", null, elmNode);
+ publicAttr = "missing";
+ }
XSNotationDecl notation = new XSNotationDecl();
notation.fName = nameAttr;
@@ -91,13 +96,37 @@
annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc);
}
}
- notation.fAnnotation = annotation;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ notation.fAnnotations = annotations;
if (content!=null){
Object[] args = new Object [] {SchemaSymbols.ELT_NOTATION, "(annotation?)", DOMUtil.getLocalName(content)};
reportSchemaError("s4s-elt-must-match.1", args, content);
}
- grammar.addGlobalNotationDecl(notation);
+ if (grammar.getGlobalNotationDecl(notation.fName) == null) {
+ grammar.addGlobalNotationDecl(notation);
+ }
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSNotationDecl notation2 = grammar.getGlobalNotationDecl(notation.fName, loc);
+ if (notation2 == null) {
+ grammar.addGlobalNotationDecl(notation, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (notation2 != null) {
+ notation = notation2;
+ }
+ fSchemaHandler.addGlobalNotationDecl(notation);
+ }
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
return notation;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.xs.traversers;
+import java.util.ArrayList;
import java.util.Vector;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeFacetException;
@@ -71,27 +72,22 @@
* Content: (annotation?, (simpleType*))
*
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Elena Litani, IBM
* @author Neeraj Bajaj, Sun Microsystems, Inc.
* @author Sandy Gao, IBM
- *
+ *
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
- // the factory used to query/create simple types
- private final SchemaDVFactory schemaFactory = SchemaDVFactory.getInstance();
-
// whether the type being parsed is a S4S built-in type.
private boolean fIsBuiltIn = false;
XSDSimpleTypeTraverser (XSDHandler handler,
XSAttributeChecker gAttrCheck) {
super(handler, gAttrCheck);
- if (schemaFactory instanceof SchemaDVFactoryImpl) {
- ((SchemaDVFactoryImpl)schemaFactory).setDeclPool(handler.fDeclPool);
- }
}
//return qualified name of simpleType or empty string if error occured
@@ -102,6 +98,9 @@
// General Attribute Checking
Object[] attrValues = fAttrChecker.checkAttributes(elmNode, true, schemaDoc);
String nameAtt = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
+ if (nameAtt == null) {
+ attrValues[XSAttributeChecker.ATTIDX_NAME] = NO_NAME;
+ }
XSSimpleType type = traverseSimpleTypeDecl(elmNode, attrValues, schemaDoc, grammar);
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
@@ -113,7 +112,26 @@
// don't add global components without name to the grammar
if (type != null) {
- grammar.addGlobalTypeDecl(type);
+ if (grammar.getGlobalTypeDecl(type.getName()) == null) {
+ grammar.addGlobalSimpleTypeDecl(type);
+ }
+
+ // also add it to extended map
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final XSTypeDefinition type2 = grammar.getGlobalTypeDecl(type.getName(), loc);
+ if (type2 == null) {
+ grammar.addGlobalSimpleTypeDecl(type, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (type2 != null) {
+ if (type2 instanceof XSSimpleType) {
+ type = (XSSimpleType) type2;
+ }
+ }
+ fSchemaHandler.addGlobalTypeDecl(type);
+ }
}
return type;
@@ -270,12 +288,12 @@
}
}
// get types from "memberTypes" attribute
- Vector dTValidators = null;
+ ArrayList dTValidators = null;
XSSimpleType dv = null;
XSObjectList dvs;
if (union && memberTypes != null && memberTypes.size() > 0) {
int size = memberTypes.size();
- dTValidators = new Vector(size, 2);
+ dTValidators = new ArrayList(size);
// for each qname in the list
for (int i = 0; i < size; i++) {
// get the type decl
@@ -286,17 +304,14 @@
if (dv.getVariety() == XSSimpleType.VARIETY_UNION) {
dvs = dv.getMemberTypes();
for (int j = 0; j < dvs.getLength(); j++)
- dTValidators.addElement(dvs.item(j));
+ dTValidators.add(dvs.item(j));
} else {
- dTValidators.addElement(dv);
+ dTValidators.add(dv);
}
}
}
}
- // when there is an error finding the base type of a restriction
- // we use anySimpleType as the base, then we should skip the facets,
- // because anySimpleType doesn't recognize any facet.
- boolean skipFacets = false;
+
// check if there is a child "simpleType"
if (content != null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_SIMPLETYPE)) {
if (restriction || list) {
@@ -304,8 +319,8 @@
if (baseTypeName != null) {
reportSchemaError(list ? "src-simple-type.3.a" : "src-simple-type.2.a", null, content);
}
- else {
- // traver this child to get the base type
+ if (baseValidator == null) {
+ // traverse this child to get the base type
baseValidator = traverseLocal(content, schemaDoc, grammar);
}
// get the next element
@@ -313,19 +328,21 @@
}
else if (union) {
if (dTValidators == null) {
- dTValidators = new Vector(2, 2);
+ dTValidators = new ArrayList(2);
}
do {
- // traver this child to get the member type
+ // traverse this child to get the member type
dv = traverseLocal(content, schemaDoc, grammar);
if (dv != null) {
// if it's a union, expand it
if (dv.getVariety() == XSSimpleType.VARIETY_UNION) {
dvs = dv.getMemberTypes();
- for (int j = 0; j < dvs.getLength(); j++)
- dTValidators.addElement(dvs.item(j));
- } else {
- dTValidators.addElement(dv);
+ for (int j = 0; j < dvs.getLength(); j++) {
+ dTValidators.add(dvs.item(j));
+ }
+ }
+ else {
+ dTValidators.add(dv);
}
}
// get the next element
@@ -334,48 +351,47 @@
}
}
else if ((restriction || list) && baseTypeName == null) {
- // it's an error if neither "base" nor "simpleType" appears
+ // it's an error if neither "base/itemType" nor "simpleType" appears
reportSchemaError(list ? "src-simple-type.3.b" : "src-simple-type.2.b", null, child);
- // base can't be found, skip the facets.
- skipFacets = true;
- baseValidator = SchemaGrammar.fAnySimpleType;
}
else if (union && (memberTypes == null || memberTypes.size() == 0)) {
// it's an error if "memberTypes" is empty and no "simpleType" appears
reportSchemaError("src-union-memberTypes-or-simpleTypes", null, child);
- dTValidators = new Vector(1);
- dTValidators.addElement(SchemaGrammar.fAnySimpleType);
}
// error finding "base" or error traversing "simpleType".
// don't need to report an error, since some error has been reported.
if ((restriction || list) && baseValidator == null) {
- baseValidator = SchemaGrammar.fAnySimpleType;
+ fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
+ return errorType(name, schemaDoc.fTargetNamespace,
+ restriction ? XSConstants.DERIVATION_RESTRICTION : XSConstants.DERIVATION_LIST);
}
// error finding "memberTypes" or error traversing "simpleType".
// don't need to report an error, since some error has been reported.
if (union && (dTValidators == null || dTValidators.size() == 0)) {
- dTValidators = new Vector(1);
- dTValidators.addElement(SchemaGrammar.fAnySimpleType);
+ fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
+ return errorType(name, schemaDoc.fTargetNamespace,
+ XSConstants.DERIVATION_UNION);
}
// item type of list types can't have list content
if (list && isListDatatype(baseValidator)) {
reportSchemaError("cos-st-restricts.2.1", new Object[]{name, baseValidator.getName()}, child);
+ fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
+ return errorType(name, schemaDoc.fTargetNamespace,
+ XSConstants.DERIVATION_LIST);
}
// create the simple type based on the "base" type
XSSimpleType newDecl = null;
if (restriction) {
- newDecl = schemaFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
+ newDecl = fSchemaHandler.fDVFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (list) {
- newDecl = schemaFactory.createTypeList(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
+ newDecl = fSchemaHandler.fDVFactory.createTypeList(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (union) {
- XSSimpleType[] memberDecls = new XSSimpleType[dTValidators.size()];
- for (int i = 0; i < dTValidators.size(); i++)
- memberDecls[i] = (XSSimpleType)dTValidators.elementAt(i);
- newDecl = schemaFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls,
+ XSSimpleType[] memberDecls = (XSSimpleType[]) dTValidators.toArray(new XSSimpleType[dTValidators.size()]);
+ newDecl = fSchemaHandler.fDVFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls,
annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
// now traverse facets, if it's derived by restriction
@@ -383,16 +399,17 @@
FacetInfo fi = traverseFacets(content, baseValidator, schemaDoc);
content = fi.nodeAfterFacets;
- if (!skipFacets) {
- try {
- fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
- newDecl.applyFacets(fi.facetdata, fi.fPresentFacets, fi.fFixedFacets, fValidationState);
- } catch (InvalidDatatypeFacetException ex) {
- reportSchemaError(ex.getKey(), ex.getArgs(), child);
- }
+ try {
+ fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
+ newDecl.applyFacets(fi.facetdata, fi.fPresentFacets, fi.fFixedFacets, fValidationState);
+ } catch (InvalidDatatypeFacetException ex) {
+ reportSchemaError(ex.getKey(), ex.getArgs(), child);
+ // Recreate the type, ignoring the facets
+ newDecl = fSchemaHandler.fDVFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
+ annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
}
- // now element should appear after this point
+ // no element should appear after this point
if (content != null) {
if (restriction) {
reportSchemaError("s4s-elt-must-match.1", new Object[]{SchemaSymbols.ELT_RESTRICTION, "(annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*))", DOMUtil.getLocalName(content)}, content);
@@ -422,31 +439,37 @@
return null;
XSTypeDefinition baseType = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, baseTypeStr, elm);
- if (baseType != null) {
- // if it's a complex type, or if its restriction of anySimpleType
- if (baseType.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE ||
- baseType == SchemaGrammar.fAnySimpleType &&
- baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
- // if the base type is anySimpleType and the current type is
- // a S4S built-in type, return null. (not an error).
- if (baseType == SchemaGrammar.fAnySimpleType &&
- checkBuiltIn(refName, schemaDoc.fTargetNamespace)) {
- return null;
- }
- reportSchemaError("cos-st-restricts.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
- return SchemaGrammar.fAnySimpleType;
+ if (baseType == null) {
+ return null;
+ }
+ if (baseType.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE) {
+ reportSchemaError("cos-st-restricts.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
+ return null;
+ }
+
+ // if it's a complex type, or if its restriction of anySimpleType
+ if (baseType == SchemaGrammar.fAnySimpleType &&
+ baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
+ // if the base type is anySimpleType and the current type is
+ // a S4S built-in type, return null. (not an error).
+ if (checkBuiltIn(refName, schemaDoc.fTargetNamespace)) {
+ return null;
}
- if ((baseType.getFinal() & baseRefContext) != 0) {
- if (baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
- reportSchemaError("st-props-correct.3", new Object[]{refName, baseTypeStr.rawname}, elm);
- }
- else if (baseRefContext == XSConstants.DERIVATION_LIST) {
- reportSchemaError("cos-st-restricts.2.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
- }
- else if (baseRefContext == XSConstants.DERIVATION_UNION) {
- reportSchemaError("cos-st-restricts.3.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
- }
+ reportSchemaError("cos-st-restricts.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
+ return null;
+ }
+
+ if ((baseType.getFinal() & baseRefContext) != 0) {
+ if (baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
+ reportSchemaError("st-props-correct.3", new Object[]{refName, baseTypeStr.rawname}, elm);
}
+ else if (baseRefContext == XSConstants.DERIVATION_LIST) {
+ reportSchemaError("cos-st-restricts.2.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
+ }
+ else if (baseRefContext == XSConstants.DERIVATION_UNION) {
+ reportSchemaError("cos-st-restricts.3.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm);
+ }
+ return null;
}
return (XSSimpleType)baseType;
@@ -480,16 +503,17 @@
}//isListDatatype(XSSimpleTypeDecl):boolean
private XSSimpleType errorType(String name, String namespace, short refType) {
+ XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string");
switch (refType) {
case XSConstants.DERIVATION_RESTRICTION:
- return schemaFactory.createTypeRestriction(name, namespace, (short)0,
- SchemaGrammar.fAnySimpleType, null);
+ return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0,
+ stringType, null);
case XSConstants.DERIVATION_LIST:
- return schemaFactory.createTypeList(name, namespace, (short)0,
- SchemaGrammar.fAnySimpleType, null);
+ return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0,
+ stringType, null);
case XSConstants.DERIVATION_UNION:
- return schemaFactory.createTypeUnion(name, namespace, (short)0,
- new XSSimpleType[]{SchemaGrammar.fAnySimpleType}, null);
+ return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0,
+ new XSSimpleType[]{stringType}, null);
}
return null;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,9 +32,10 @@
* This class contains code that is used to traverse both s and
* s.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Neil Graham, IBM
+ * @version $Id: XSDUniqueOrKeyTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser {
@@ -70,11 +71,30 @@
// duplication (or if there is that restriction is involved
// and there's identity).
- // get selector and fields
- traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, attrValues);
+ // If errors occurred in traversing the identity constraint, then don't
+ // add it to the schema, to avoid errors when processing the instance.
+ if (traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, attrValues)) {
+ // and stuff this in the grammar
+ if (grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName()) == null) {
+ grammar.addIDConstraintDecl(element, uniqueOrKey);
+ }
- // and stuff this in the grammar
- grammar.addIDConstraintDecl(element, uniqueOrKey);
+ final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
+ final IdentityConstraint idc = grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName(), loc);
+ if (idc == null) {
+ grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
+ }
+
+ // handle duplicates
+ if (fSchemaHandler.fTolerateDuplicates) {
+ if (idc != null) {
+ if (idc instanceof UniqueOrKey) {
+ uniqueOrKey = (UniqueOrKey) uniqueOrKey;
+ }
+ }
+ fSchemaHandler.addIDConstraintDecl(uniqueOrKey);
+ }
+ }
// and fix up attributeChecker
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,35 +26,38 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl;
import com.sun.org.apache.xerces.internal.impl.xs.XSWildcardDecl;
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
+import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl;
import com.sun.org.apache.xerces.internal.util.DOMUtil;
+import com.sun.org.apache.xerces.internal.xs.XSObjectList;
import org.w3c.dom.Element;
/**
* The wildcard schema component traverser.
*
- *
+ * {any attributes with non-schema namespace . . .}>
* Content: (annotation?)
- *
+ * </any>
*
- *
+ * {any attributes with non-schema namespace . . .}>
* Content: (annotation?)
- *
+ * </anyAttribute>
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Sandy Gao, IBM
*
+ * @version $Id: XSDWildcardTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $
*/
class XSDWildcardTraverser extends XSDAbstractTraverser {
@@ -72,7 +75,7 @@
/**
- * Traverse
+ * Traverse <any>
*
* @param elmNode
* @param schemaDoc
@@ -102,6 +105,7 @@
particle.fValue = wildcard;
particle.fMinOccurs = min;
particle.fMaxOccurs = max;
+ particle.fAnnotations = wildcard.fAnnotations;
}
}
@@ -112,7 +116,7 @@
/**
- * Traverse
+ * Traverse <anyAttribute>
*
* @param elmNode
* @param schemaDoc
@@ -182,7 +186,14 @@
annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc);
}
}
- wildcard.fAnnotation = annotation;
+ XSObjectList annotations;
+ if (annotation != null) {
+ annotations = new XSObjectListImpl();
+ ((XSObjectListImpl) annotations).addXSObject(annotation);
+ } else {
+ annotations = XSObjectListImpl.EMPTY_LIST;
+ }
+ wildcard.fAnnotations = annotations;
return wildcard;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,126 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.xs.util;
+
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+
+import com.sun.org.apache.xerces.internal.xs.LSInputList;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * Contains a list of LSInputs.
+ *
+ * @xerces.internal
+ *
+ * @author Michael Glavassevich, IBM
+ *
+ * @version $Id: LSInputListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $
+ */
+public final class LSInputListImpl extends AbstractList implements LSInputList {
+
+ /**
+ * An immutable empty list.
+ */
+ public static final LSInputListImpl EMPTY_LIST = new LSInputListImpl(new LSInput[0], 0);
+
+ // The array to hold all data
+ private final LSInput[] fArray;
+ // Number of elements in this list
+ private final int fLength;
+
+ /**
+ * Construct an LSInputList implementation
+ *
+ * @param array the data array
+ * @param length the number of elements
+ */
+ public LSInputListImpl(LSInput[] array, int length) {
+ fArray = array;
+ fLength = length;
+ }
+
+ /**
+ * The number of LSInput
s in the list. The range of valid
+ * child object indices is 0 to length-1
inclusive.
+ */
+ public int getLength() {
+ return fLength;
+ }
+
+ /**
+ * Returns the index
th item in the collection or
+ * null
if index
is greater than or equal to
+ * the number of objects in the list. The index starts at 0.
+ * @param index index into the collection.
+ * @return The LSInput
at the index
th
+ * position in the LSInputList
, or null
if
+ * the index specified is not valid.
+ */
+ public LSInput item(int index) {
+ if (index < 0 || index >= fLength) {
+ return null;
+ }
+ return fArray[index];
+ }
+
+ /*
+ * List methods
+ */
+
+ public Object get(int index) {
+ if (index >= 0 && index < fLength) {
+ return fArray[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public Object[] toArray() {
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
+
+} // LSInputListImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/NSItemListImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/NSItemListImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.sun.org.apache.xerces.internal.impl.xs.util;
-
-import java.util.Vector;
-
-import com.sun.org.apache.xerces.internal.xs.XSNamespaceItem;
-import com.sun.org.apache.xerces.internal.xs.XSNamespaceItemList;
-/**
- * Containts a list of Object's.
- *
- * @xerces.internal
- *
- * @author Sandy Gao, IBM
- *
- */
-public class NSItemListImpl implements XSNamespaceItemList {
-
- // The array to hold all data
- private XSNamespaceItem[] fArray = null;
- // Number of elements in this list
- private int fLength = 0;
-
- // REVISIT: this is temp solution. In general we need to use this class
- // instead of the Vector.
- private Vector fVector;
-
- public NSItemListImpl(Vector v) {
- fVector = v;
- fLength = v.size();
- }
-
- /**
- * Construct an XSNamespaceItemList implementation
- *
- * @param array the data array
- * @param length the number of elements
- */
- public NSItemListImpl(XSNamespaceItem[] array, int length) {
- fArray = array;
- fLength = length;
- }
-
- /**
- * The number of Objects
in the list. The range of valid
- * child node indices is 0 to length-1
inclusive.
- */
- public int getLength() {
- return fLength;
- }
-
- public XSNamespaceItem item(int index) {
- if (index < 0 || index >= fLength)
- return null;
- if (fVector != null) {
- return (XSNamespaceItem)fVector.elementAt(index);
- }
- return fArray[index];
- }
-
-} // class XSParticle
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,119 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.xs.util;
+
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+
+import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;
+
+/**
+ * Contains a list of Objects.
+ *
+ * @xerces.internal
+ *
+ * @version $Id: ObjectListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $
+ */
+public final class ObjectListImpl extends AbstractList implements ObjectList {
+
+ /**
+ * An immutable empty list.
+ */
+ public static final ObjectListImpl EMPTY_LIST = new ObjectListImpl(new Object[0], 0);
+
+ // The array to hold all data
+ private final Object[] fArray;
+
+ // Number of elements in this list
+ private final int fLength;
+
+ public ObjectListImpl(Object[] array, int length) {
+ fArray = array;
+ fLength = length;
+ }
+
+ public int getLength() {
+ return fLength;
+ }
+
+ public boolean contains(Object item) {
+ if (item == null) {
+ for (int i = 0; i < fLength; i++) {
+ if (fArray[i] == null)
+ return true;
+ }
+ }
+ else {
+ for (int i = 0; i < fLength; i++) {
+ if (item.equals(fArray[i]))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Object item(int index) {
+ if (index < 0 || index >= fLength) {
+ return null;
+ }
+ return fArray[index];
+ }
+
+ /*
+ * List methods
+ */
+ public Object get(int index) {
+ if (index >= 0 && index < fLength) {
+ return fArray[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public Object[] toArray() {
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
+}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,23 +20,31 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import java.util.AbstractList;
+
import com.sun.org.apache.xerces.internal.xs.ShortList;
import com.sun.org.apache.xerces.internal.xs.XSException;
/**
* Containts a list of Object's.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: ShortListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
-public class ShortListImpl implements ShortList {
+public final class ShortListImpl extends AbstractList implements ShortList {
+
+ /**
+ * An immutable empty list.
+ */
+ public static final ShortListImpl EMPTY_LIST = new ShortListImpl(new short[0], 0);
// The array to hold all data
- private short[] fArray = null;
+ private final short[] fArray;
// Number of elements in this list
- private int fLength = 0;
+ private final int fLength;
/**
* Construct an XSObjectList implementation
@@ -67,15 +75,17 @@
*/
public boolean contains(short item) {
for (int i = 0; i < fLength; i++) {
- if (fArray[i] == item)
+ if (fArray[i] == item) {
return true;
+ }
}
return false;
}
public short item(int index) throws XSException {
- if (index < 0 || index >= fLength)
+ if (index < 0 || index >= fLength) {
throw new XSException(XSException.INDEX_SIZE_ERR, null);
+ }
return fArray[index];
}
@@ -88,7 +98,6 @@
if (fLength != rhs.getLength()) {
return false;
}
-
for (int i = 0;i < fLength; ++i) {
if (fArray[i] != rhs.item(i)) {
return false;
@@ -97,4 +106,19 @@
return true;
}
-} // class XSParticle
+ /*
+ * List methods
+ */
+
+ public Object get(int index) {
+ if (index >= 0 && index < fLength) {
+ return new Short(fArray[index]);
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+} // class ShortListImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,45 +20,41 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+import java.util.Vector;
+
import com.sun.org.apache.xerces.internal.xs.StringList;
-import java.util.Vector;
+
/**
* Containts a list of Object's.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: StringListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
-public class StringListImpl implements StringList {
+public final class StringListImpl extends AbstractList implements StringList {
/**
* An immutable empty list.
*/
- public static final StringList EMPTY_LIST = new StringList () {
- public int getLength() {
- return 0;
- }
- public boolean contains(String item) {
- return false;
- }
- public String item(int index) {
- return null;
- }
- };
+ public static final StringListImpl EMPTY_LIST = new StringListImpl(new String[0], 0);
// The array to hold all data
- private String[] fArray = null;
+ private final String[] fArray;
// Number of elements in this list
- private int fLength = 0;
+ private final int fLength;
// REVISIT: this is temp solution. In general we need to use this class
// instead of the Vector.
- private Vector fVector;
+ private final Vector fVector;
public StringListImpl(Vector v) {
fVector = v;
fLength = (v == null) ? 0 : v.size();
+ fArray = null;
}
/**
@@ -70,6 +66,7 @@
public StringListImpl(String[] array, int length) {
fArray = array;
fLength = length;
+ fVector = null;
}
/**
@@ -89,9 +86,9 @@
* item
.
*/
public boolean contains(String item) {
- if (fVector != null)
+ if (fVector != null) {
return fVector.contains(item);
-
+ }
if (item == null) {
for (int i = 0; i < fLength; i++) {
if (fArray[i] == null)
@@ -108,12 +105,62 @@
}
public String item(int index) {
- if (index < 0 || index >= fLength)
+ if (index < 0 || index >= fLength) {
return null;
+ }
if (fVector != null) {
return (String)fVector.elementAt(index);
}
return fArray[index];
}
-} // class XSParticle
+ /*
+ * List methods
+ */
+
+ public Object get(int index) {
+ if (index >= 0 && index < fLength) {
+ if (fVector != null) {
+ return fVector.elementAt(index);
+ }
+ return fArray[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public Object[] toArray() {
+ if (fVector != null) {
+ return fVector.toArray();
+ }
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (fVector != null) {
+ return fVector.toArray(a);
+ }
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
+
+} // class StringListImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,21 +20,26 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import java.util.ArrayList;
+
+import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
import com.sun.org.apache.xerces.internal.impl.xs.XSModelImpl;
-import com.sun.org.apache.xerces.internal.xs.XSModel;
import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
+import com.sun.org.apache.xerces.internal.xs.XSModel;
/**
* Add a method that return an XSModel
that represents components in
* the schema grammars in this pool implementation.
- *
- * @xerces.internal
- *
+ *
+ * @xerces.internal
+ *
+ * @version $Id: XSGrammarPool.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
public class XSGrammarPool extends XMLGrammarPoolImpl {
+
/**
* Return an XSModel
that represents components in
* the schema grammars in this pool implementation.
@@ -42,22 +47,28 @@
* @return an XSModel
representing this schema grammar
*/
public XSModel toXSModel() {
- java.util.Vector list = new java.util.Vector();
+ return toXSModel(Constants.SCHEMA_VERSION_1_0);
+ }
+
+ public XSModel toXSModel(short schemaVersion) {
+ ArrayList list = new ArrayList();
for (int i = 0; i < fGrammars.length; i++) {
for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) {
- if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA))
- list.addElement(entry.grammar);
+ if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA)) {
+ list.add(entry.grammar);
+ }
}
}
-
int size = list.size();
- if (size == 0)
- return null;
- SchemaGrammar[] gs = new SchemaGrammar[size];
- for (int i = 0; i < size; i++)
- gs[i] = (SchemaGrammar)list.elementAt(i);
- return new XSModelImpl(gs);
+ if (size == 0) {
+ return toXSModel(new SchemaGrammar[0], schemaVersion);
+ }
+ SchemaGrammar[] gs = (SchemaGrammar[])list.toArray(new SchemaGrammar[size]);
+ return toXSModel(gs, schemaVersion);
}
+ protected XSModel toXSModel(SchemaGrammar[] grammars, short schemaVersion) {
+ return new XSModelImpl(grammars, schemaVersion);
+ }
} // class XSGrammarPool
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,66 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.xs.util;
+
+
+import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+import com.sun.org.apache.xerces.internal.xs.XSObject;
+
+/**
+ * @xerces.internal
+ *
+ * @version $Id: XSInputSource.java,v 1.2 2010-10-26 23:01:05 joehw Exp $
+ */
+public final class XSInputSource extends XMLInputSource {
+
+ private SchemaGrammar[] fGrammars;
+ private XSObject[] fComponents;
+
+ public XSInputSource(SchemaGrammar[] grammars) {
+ super(null, null, null);
+ fGrammars = grammars;
+ fComponents = null;
+ }
+
+ public XSInputSource(XSObject[] component) {
+ super(null, null, null);
+ fGrammars = null;
+ fComponents = component;
+ }
+
+ public SchemaGrammar[] getGrammars() {
+ return fGrammars;
+ }
+
+ public void setGrammars(SchemaGrammar[] grammars) {
+ fGrammars = grammars;
+ }
+
+ public XSObject[] getComponents() {
+ return fComponents;
+ }
+
+ public void setComponents(XSObject[] components) {
+ fComponents = components;
+ }
+}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,25 +20,27 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.xs.XSObject;
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
-import com.sun.org.apache.xerces.internal.util.SymbolHash;
+
/**
* Containts the map between qnames and XSObject's.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSNamedMap4Types.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
-public class XSNamedMap4Types extends XSNamedMapImpl {
+public final class XSNamedMap4Types extends XSNamedMapImpl {
// the type of component stored here: complex or simple type
- short fType;
+ private final short fType;
/**
- * Construct an XSNamedMap implmentation for one namespace
+ * Construct an XSNamedMap implementation for one namespace
*
* @param namespace the namespace to which the components belong
* @param map the map from local names to components
@@ -50,7 +52,7 @@
}
/**
- * Construct an XSNamedMap implmentation for a list of namespaces
+ * Construct an XSNamedMap implementation for a list of namespaces
*
* @param namespaces the namespaces to which the components belong
* @param maps the maps from local names to components
@@ -71,8 +73,9 @@
if (fLength == -1) {
// first get the number of components for all types
int length = 0;
- for (int i = 0; i < fNSNum; i++)
+ for (int i = 0; i < fNSNum; i++) {
length += fMaps[i].getLength();
+ }
// then copy all types to an temporary array
int pos = 0;
XSObject[] array = new XSObject[length];
@@ -105,14 +108,13 @@
* identify any XSObject
in this map.
*/
public XSObject itemByName(String namespace, String localName) {
- if (namespace != null)
- namespace = namespace.intern();
for (int i = 0; i < fNSNum; i++) {
- if (namespace == fNamespaces[i]) {
+ if (isEqual(namespace, fNamespaces[i])) {
XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName);
- // only return it if it mataches the required type
- if (type.getTypeCategory() == fType)
+ // only return it if it matches the required type
+ if (type != null && type.getTypeCategory() == fType) {
return type;
+ }
return null;
}
}
@@ -133,8 +135,9 @@
if (fArray == null) {
getLength();
}
- if (index < 0 || index >= fLength)
+ if (index < 0 || index >= fLength) {
return null;
+ }
return fArray[index];
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,52 +20,53 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
import com.sun.org.apache.xerces.internal.util.SymbolHash;
-import com.sun.org.apache.xerces.internal.xni.QName;
-import com.sun.org.apache.xerces.internal.xs.*;
+import com.sun.org.apache.xerces.internal.xs.XSNamedMap;
+import com.sun.org.apache.xerces.internal.xs.XSObject;
/**
* Containts the map between qnames and XSObject's.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSNamedMapImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
-public class XSNamedMapImpl implements XSNamedMap {
+public class XSNamedMapImpl extends AbstractMap implements XSNamedMap {
/**
* An immutable empty map.
*/
- public static final XSNamedMap EMPTY_MAP = new XSNamedMap () {
- public int getLength() {
- return 0;
- }
- public XSObject itemByName(String namespace, String localName) {
- return null;
- }
- public XSObject item(int index) {
- return null;
- }
- };
+ public static final XSNamedMapImpl EMPTY_MAP = new XSNamedMapImpl(new XSObject[0], 0);
// components of these namespaces are stored in this map
- String[] fNamespaces;
+ final String[] fNamespaces;
// number of namespaces
- int fNSNum;
+ final int fNSNum;
// each entry contains components in one namespace
- SymbolHash[] fMaps;
+ final SymbolHash[] fMaps;
// store all components from all namespace.
// used when this map is accessed as a list.
- XSObject[] fArray = null;
- // store the number of componetns.
+ XSObject[] fArray = null;
+ // store the number of components.
// used when this map is accessed as a list.
- int fLength = -1;
- // temprory QName object
- QName fName = new QName();
+ int fLength = -1;
+ // Set of Map.Entry for the java.util.Map methods
+ private Set fEntrySet = null;
/**
- * Construct an XSNamedMap implmentation for one namespace
+ * Construct an XSNamedMap implementation for one namespace
*
* @param namespace the namespace to which the components belong
* @param map the map from local names to components
@@ -77,7 +78,7 @@
}
/**
- * Construct an XSNamedMap implmentation for a list of namespaces
+ * Construct an XSNamedMap implementation for a list of namespaces
*
* @param namespaces the namespaces to which the components belong
* @param maps the maps from local names to components
@@ -90,14 +91,17 @@
}
/**
- * Construct an XSNamedMap implmentation one namespace from an array
+ * Construct an XSNamedMap implementation one namespace from an array
*
* @param array containing all components
* @param length number of components
*/
public XSNamedMapImpl(XSObject[] array, int length) {
if (length == 0) {
+ fNamespaces = null;
+ fMaps = null;
fNSNum = 0;
+ fArray = array;
fLength = 0;
return;
}
@@ -112,45 +116,51 @@
}
/**
- * The number of XSObjects
in the XSObjectList
. The
- * range of valid child node indices is 0 to length-1
+ * The number of XSObjects
in the XSObjectList
.
+ * The range of valid child object indices is 0 to length-1
* inclusive.
*/
public synchronized int getLength() {
if (fLength == -1) {
fLength = 0;
- for (int i = 0; i < fNSNum; i++)
+ for (int i = 0; i < fNSNum; i++) {
fLength += fMaps[i].getLength();
+ }
}
return fLength;
}
/**
- * Retrieves an XSObject
specified by local name and namespace
- * URI.
+ * Retrieves an XSObject
specified by local name and
+ * namespace URI.
+ *
Per XML Namespaces, applications must use the value null
as the
+ * namespace
parameter for methods if they wish to specify
+ * no namespace.
* @param namespace The namespace URI of the XSObject
to
+ * retrieve, or null
if the XSObject
has no
+ * namespace.
+ * @param localName The local name of the XSObject
to
* retrieve.
- * @param localName The local name of the XSObject
to retrieve.
* @return A XSObject
(of any type) with the specified local
* name and namespace URI, or null
if they do not
- * identify any XSObject
in this map.
+ * identify any object in this map.
*/
public XSObject itemByName(String namespace, String localName) {
- if (namespace != null)
- namespace = namespace.intern();
for (int i = 0; i < fNSNum; i++) {
- if (namespace == fNamespaces[i]) {
+ if (isEqual(namespace, fNamespaces[i])) {
// when this map is created from SymbolHash's
// get the component from SymbolHash
- if (fMaps != null)
+ if (fMaps != null) {
return (XSObject)fMaps[i].get(localName);
+ }
// Otherwise (it's created from an array)
- // go through the array to find a matcing name
+ // go through the array to find a matching name
XSObject ret;
for (int j = 0; j < fLength; j++) {
ret = fArray[j];
- if (ret.getName().equals(localName))
+ if (ret.getName().equals(localName)) {
return ret;
+ }
}
return null;
}
@@ -159,14 +169,13 @@
}
/**
- * Returns the index
th item in the map. The index starts at
- * 0. If index
is greater than or equal to the number of
- * nodes in the list, this returns null
.
- * @param index The position in the map from which the item is to be
- * retrieved.
- * @return The XSObject
at the index
th position
- * in the XSNamedMap
, or null
if that is
- * not a valid index.
+ * Returns the index
th item in the collection or
+ * null
if index
is greater than or equal to
+ * the number of objects in the list. The index starts at 0.
+ * @param index index into the collection.
+ * @return The XSObject
at the index
th
+ * position in the XSObjectList
, or null
if
+ * the index specified is not valid.
*/
public synchronized XSObject item(int index) {
if (fArray == null) {
@@ -174,14 +183,120 @@
getLength();
fArray = new XSObject[fLength];
int pos = 0;
- // get components from all SymbolHash's
+ // get components from all SymbolHashes
for (int i = 0; i < fNSNum; i++) {
pos += fMaps[i].getValues(fArray, pos);
}
}
- if (index < 0 || index >= fLength)
+ if (index < 0 || index >= fLength) {
return null;
+ }
return fArray[index];
}
+ static boolean isEqual(String one, String two) {
+ return (one != null) ? one.equals(two) : (two == null);
+ }
+
+ /*
+ * java.util.Map methods
+ */
+
+ public boolean containsKey(Object key) {
+ return (get(key) != null);
+ }
+
+ public Object get(Object key) {
+ if (key instanceof QName) {
+ final QName name = (QName) key;
+ String namespaceURI = name.getNamespaceURI();
+ if (XMLConstants.NULL_NS_URI.equals(namespaceURI)) {
+ namespaceURI = null;
+ }
+ String localPart = name.getLocalPart();
+ return itemByName(namespaceURI, localPart);
+ }
+ return null;
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public synchronized Set entrySet() {
+ // Defer creation of the entry set until it is actually needed.
+ if (fEntrySet == null) {
+ final int length = getLength();
+ final XSNamedMapEntry[] entries = new XSNamedMapEntry[length];
+ for (int i = 0; i < length; ++i) {
+ XSObject xso = item(i);
+ entries[i] = new XSNamedMapEntry(new QName(xso.getNamespace(), xso.getName()), xso);
+ }
+ // Create a view of this immutable map.
+ fEntrySet = new AbstractSet() {
+ public Iterator iterator() {
+ return new Iterator() {
+ private int index = 0;
+ public boolean hasNext() {
+ return (index < length);
+ }
+ public Object next() {
+ if (index < length) {
+ return entries[index++];
+ }
+ throw new NoSuchElementException();
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ public int size() {
+ return length;
+ }
+ };
+ }
+ return fEntrySet;
+ }
+
+ /** An entry in the XSNamedMap. **/
+ private static final class XSNamedMapEntry implements Map.Entry {
+ private final QName key;
+ private final XSObject value;
+ public XSNamedMapEntry(QName key, XSObject value) {
+ this.key = key;
+ this.value = value;
+ }
+ public Object getKey() {
+ return key;
+ }
+ public Object getValue() {
+ return value;
+ }
+ public Object setValue(Object value) {
+ throw new UnsupportedOperationException();
+ }
+ public boolean equals(Object o) {
+ if (o instanceof Map.Entry) {
+ Map.Entry e = (Map.Entry) o;
+ Object otherKey = e.getKey();
+ Object otherValue = e.getValue();
+ return (key == null ? otherKey == null : key.equals(otherKey)) &&
+ (value == null ? otherValue == null : value.equals(otherValue));
+ }
+ return false;
+ }
+ public int hashCode() {
+ return (key == null ? 0 : key.hashCode())
+ ^ (value == null ? 0 : value.hashCode());
+ }
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(String.valueOf(key));
+ buffer.append('=');
+ buffer.append(String.valueOf(value));
+ return buffer.toString();
+ }
+ }
+
} // class XSNamedMapImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,28 +20,57 @@
package com.sun.org.apache.xerces.internal.impl.xs.util;
+import java.lang.reflect.Array;
+import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
import com.sun.org.apache.xerces.internal.xs.XSObject;
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
/**
* Containts a list of XSObject's.
*
- * @xerces.internal
+ * @xerces.internal
*
* @author Sandy Gao, IBM
*
+ * @version $Id: XSObjectListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
-public class XSObjectListImpl implements XSObjectList {
+public class XSObjectListImpl extends AbstractList implements XSObjectList {
/**
* An immutable empty list.
*/
- public static final XSObjectList EMPTY_LIST = new XSObjectList () {
- public int getLength() {
+ public static final XSObjectListImpl EMPTY_LIST = new XSObjectListImpl(new XSObject[0], 0);
+ private static final ListIterator EMPTY_ITERATOR = new ListIterator() {
+ public boolean hasNext() {
+ return false;
+ }
+ public Object next() {
+ throw new NoSuchElementException();
+ }
+ public boolean hasPrevious() {
+ return false;
+ }
+ public Object previous() {
+ throw new NoSuchElementException();
+ }
+ public int nextIndex() {
return 0;
}
- public XSObject item(int index) {
- return null;
+ public int previousIndex() {
+ return -1;
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ public void set(Object object) {
+ throw new UnsupportedOperationException();
+ }
+ public void add(Object object) {
+ throw new UnsupportedOperationException();
}
};
@@ -52,8 +81,6 @@
// Number of elements in this list
private int fLength = 0;
-
-
public XSObjectListImpl() {
fArray = new XSObject[DEFAULT_SIZE];
fLength = 0;
@@ -88,13 +115,14 @@
* valid index.
*/
public XSObject item(int index) {
- if (index < 0 || index >= fLength)
+ if (index < 0 || index >= fLength) {
return null;
+ }
return fArray[index];
}
// clear this object
- public void clear() {
+ public void clearXSObjectList() {
for (int i=0; i= 0 && index < fLength) {
+ return fArray[index];
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ public int size() {
+ return getLength();
+ }
+
+ public Iterator iterator() {
+ return listIterator0(0);
}
- public void add (int index, XSObject object){
- fArray [index] = object;
+
+ public ListIterator listIterator() {
+ return listIterator0(0);
+ }
+
+ public ListIterator listIterator(int index) {
+ if (index >= 0 && index < fLength) {
+ return listIterator0(index);
+ }
+ throw new IndexOutOfBoundsException("Index: " + index);
+ }
+
+ private ListIterator listIterator0(int index) {
+ return fLength == 0 ? EMPTY_ITERATOR : new XSObjectListIterator(index);
+ }
+
+ private boolean containsObject(Object value) {
+ for (int i = fLength - 1; i >= 0; --i) {
+ if (value.equals(fArray[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean containsNull() {
+ for (int i = fLength - 1; i >= 0; --i) {
+ if (fArray[i] == null) {
+ return true;
+ }
+ }
+ return false;
}
-} // class XSObjectList
+ public Object[] toArray() {
+ Object[] a = new Object[fLength];
+ toArray0(a);
+ return a;
+ }
+
+ public Object[] toArray(Object[] a) {
+ if (a.length < fLength) {
+ Class arrayClass = a.getClass();
+ Class componentType = arrayClass.getComponentType();
+ a = (Object[]) Array.newInstance(componentType, fLength);
+ }
+ toArray0(a);
+ if (a.length > fLength) {
+ a[fLength] = null;
+ }
+ return a;
+ }
+
+ private void toArray0(Object[] a) {
+ if (fLength > 0) {
+ System.arraycopy(fArray, 0, a, 0, fLength);
+ }
+ }
+
+ private final class XSObjectListIterator implements ListIterator {
+ private int index;
+ public XSObjectListIterator(int index) {
+ this.index = index;
+ }
+ public boolean hasNext() {
+ return (index < fLength);
+ }
+ public Object next() {
+ if (index < fLength) {
+ return fArray[index++];
+ }
+ throw new NoSuchElementException();
+ }
+ public boolean hasPrevious() {
+ return (index > 0);
+ }
+ public Object previous() {
+ if (index > 0) {
+ return fArray[--index];
+ }
+ throw new NoSuchElementException();
+ }
+ public int nextIndex() {
+ return index;
+ }
+ public int previousIndex() {
+ return index - 1;
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ public void set(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ public void add(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+} // class XSObjectListImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,8 +21,9 @@
package com.sun.org.apache.xerces.internal.jaxp;
import java.io.IOException;
-import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.validation.Schema;
@@ -39,7 +40,6 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDFilter;
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import org.w3c.dom.DOMImplementation;
@@ -54,7 +54,7 @@
/**
* @author Rajiv Mordani
* @author Edwin Goei
- * @version $Id: DocumentBuilderImpl.java,v 1.5 2007/07/20 14:11:20 spericas Exp $
+ * @version $Id: DocumentBuilderImpl.java,v 1.8 2010-11-01 04:40:06 joehw Exp $
*/
public class DocumentBuilderImpl extends DocumentBuilder
implements JAXPConstants
@@ -62,52 +62,53 @@
/** Feature identifier: namespaces. */
private static final String NAMESPACES_FEATURE =
Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
-
+
/** Feature identifier: include ignorable white space. */
private static final String INCLUDE_IGNORABLE_WHITESPACE =
Constants.XERCES_FEATURE_PREFIX + Constants.INCLUDE_IGNORABLE_WHITESPACE;
-
+
/** Feature identifier: create entiry ref nodes feature. */
private static final String CREATE_ENTITY_REF_NODES_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.CREATE_ENTITY_REF_NODES_FEATURE;
-
+
/** Feature identifier: include comments feature. */
private static final String INCLUDE_COMMENTS_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.INCLUDE_COMMENTS_FEATURE;
-
+
/** Feature identifier: create cdata nodes feature. */
private static final String CREATE_CDATA_NODES_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.CREATE_CDATA_NODES_FEATURE;
-
+
/** Feature identifier: XInclude processing */
- private static final String XINCLUDE_FEATURE =
+ private static final String XINCLUDE_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FEATURE;
/** feature identifier: XML Schema validation */
private static final String XMLSCHEMA_VALIDATION_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
-
+
/** Feature identifier: validation */
private static final String VALIDATION_FEATURE =
Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
-
+
/** Property identifier: security manager. */
private static final String SECURITY_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
-
- private DOMParser domParser = null;
+
+ private final DOMParser domParser;
private final Schema grammar;
-
- private XMLComponent fSchemaValidator;
- private XMLComponentManager fSchemaValidatorComponentManager;
- private ValidationManager fSchemaValidationManager;
-
+
+ private final XMLComponent fSchemaValidator;
+ private final XMLComponentManager fSchemaValidatorComponentManager;
+ private final ValidationManager fSchemaValidationManager;
+ private final UnparsedEntityHandler fUnparsedEntityHandler;
+
/** Initial ErrorHandler */
private final ErrorHandler fInitErrorHandler;
-
+
/** Initial EntityResolver */
private final EntityResolver fInitEntityResolver;
-
+
DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Hashtable dbfAttrs, Hashtable features)
throws SAXNotRecognizedException, SAXNotSupportedException {
this(dbf, dbfAttrs, features, false);
@@ -135,7 +136,7 @@
domParser.setFeature(NAMESPACES_FEATURE, dbf.isNamespaceAware());
// Set various parameters obtained from DocumentBuilderFactory
- domParser.setFeature(INCLUDE_IGNORABLE_WHITESPACE,
+ domParser.setFeature(INCLUDE_IGNORABLE_WHITESPACE,
!dbf.isIgnoringElementContentWhitespace());
domParser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE,
!dbf.isExpandEntityReferences());
@@ -143,19 +144,19 @@
!dbf.isIgnoringComments());
domParser.setFeature(CREATE_CDATA_NODES_FEATURE,
!dbf.isCoalescing());
-
+
// Avoid setting the XInclude processing feature if the value is false.
// This will keep the configuration from throwing an exception if it
// does not support XInclude.
if (dbf.isXIncludeAware()) {
domParser.setFeature(XINCLUDE_FEATURE, true);
}
-
+
// If the secure processing feature is on set a security manager.
if (secureProcessing) {
domParser.setProperty(SECURITY_MANAGER, new SecurityManager());
}
-
+
this.grammar = dbf.getSchema();
if (grammar != null) {
XMLParserConfiguration config = domParser.getXMLParserConfiguration();
@@ -164,16 +165,18 @@
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
fSchemaValidationManager = new ValidationManager();
- XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
- config.setDTDHandler(entityHandler);
- entityHandler.setDTDHandler(domParser);
- domParser.setDTDSource(entityHandler);
- fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
+ fUnparsedEntityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
+ config.setDTDHandler(fUnparsedEntityHandler);
+ fUnparsedEntityHandler.setDTDHandler(domParser);
+ domParser.setDTDSource(fUnparsedEntityHandler);
+ fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
(XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler());
+ fSchemaValidationManager = null;
+ fUnparsedEntityHandler = null;
fSchemaValidatorComponentManager = config;
}
config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures());
@@ -185,22 +188,28 @@
fSchemaValidator = validatorComponent;
}
else {
- setFeatures(features);
+ fSchemaValidationManager = null;
+ fUnparsedEntityHandler = null;
+ fSchemaValidatorComponentManager = null;
+ fSchemaValidator = null;
+ setFeatures(features);
}
-
+
// Set attributes
setDocumentBuilderFactoryAttributes(dbfAttrs);
-
+
// Initial EntityResolver
fInitEntityResolver = domParser.getEntityResolver();
}
-
+
private void setFeatures(Hashtable features)
throws SAXNotSupportedException, SAXNotRecognizedException {
if (features != null) {
- for (Enumeration e = features.keys(); e.hasMoreElements();) {
- String feature = (String)e.nextElement();
- boolean value = ((Boolean)features.get(feature)).booleanValue();
+ Iterator entries = features.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String feature = (String) entry.getKey();
+ boolean value = ((Boolean) entry.getValue()).booleanValue();
domParser.setFeature(feature, value);
}
}
@@ -221,9 +230,11 @@
return;
}
- for (Enumeration e = dbfAttrs.keys(); e.hasMoreElements();) {
- String name = (String)e.nextElement();
- Object val = dbfAttrs.get(name);
+ Iterator entries = dbfAttrs.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String name = (String) entry.getKey();
+ Object val = entry.getValue();
if (val instanceof Boolean) {
// Assume feature
domParser.setFeature(name, ((Boolean)val).booleanValue());
@@ -231,11 +242,11 @@
// Assume property
if (JAXP_SCHEMA_LANGUAGE.equals(name)) {
// JAXP 1.2 support
- //None of the properties will take effect till the setValidating(true) has been called
+ //None of the properties will take effect till the setValidating(true) has been called
if ( W3C_XML_SCHEMA.equals(val) ) {
if( isValidating() ) {
domParser.setFeature(XMLSCHEMA_VALIDATION_FEATURE, true);
- // this should allow us not to emit DTD errors, as expected by the
+ // this should allow us not to emit DTD errors, as expected by the
// spec when schema validation is enabled
domParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
}
@@ -247,7 +258,7 @@
domParser.setProperty(name, val);
}else{
throw new IllegalArgumentException(
- DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"jaxp-order-not-supported",
new Object[] {JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE}));
}
@@ -276,23 +287,26 @@
public Document parse(InputSource is) throws SAXException, IOException {
if (is == null) {
throw new IllegalArgumentException(
- DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"jaxp-null-input-source", null));
}
if (fSchemaValidator != null) {
if (fSchemaValidationManager != null) {
fSchemaValidationManager.reset();
+ fUnparsedEntityHandler.reset();
}
resetSchemaValidator();
}
domParser.parse(is);
- return domParser.getDocument();
+ Document doc = domParser.getDocument();
+ domParser.dropDocumentReferences();
+ return doc;
}
public boolean isNamespaceAware() {
try {
return domParser.getFeature(NAMESPACES_FEATURE);
- }
+ }
catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
@@ -301,12 +315,12 @@
public boolean isValidating() {
try {
return domParser.getFeature(VALIDATION_FEATURE);
- }
+ }
catch (SAXException x) {
throw new IllegalStateException(x.getMessage());
}
}
-
+
/**
* Gets the XInclude processing mode for this parser
* @return the state of XInclude processing mode
@@ -327,11 +341,11 @@
public void setErrorHandler(ErrorHandler eh) {
domParser.setErrorHandler(eh);
}
-
+
public Schema getSchema() {
return grammar;
}
-
+
public void reset() {
/** Restore the initial error handler. **/
if (domParser.getErrorHandler() != fInitErrorHandler) {
@@ -347,7 +361,7 @@
DOMParser getDOMParser() {
return domParser;
}
-
+
private void resetSchemaValidator() throws SAXException {
try {
fSchemaValidator.reset(fSchemaValidatorComponentManager);
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,7 +21,6 @@
package com.sun.org.apache.xerces.internal.jaxp;
import java.io.IOException;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -33,7 +32,6 @@
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
-import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.SecurityManager;
@@ -41,7 +39,6 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDFilter;
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
@@ -49,20 +46,23 @@
import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
/**
* This is the implementation specific class for the
* javax.xml.parsers.SAXParser
.
- *
+ *
* @author Rajiv Mordani
* @author Edwin Goei
- *
+ *
+ * @version $Id: SAXParserImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $
*/
public class SAXParserImpl extends javax.xml.parsers.SAXParser
implements JAXPConstants, PSVIProvider {
@@ -91,13 +91,14 @@
private static final String SECURITY_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
- private JAXPSAXParser xmlReader;
+ private final JAXPSAXParser xmlReader;
private String schemaLanguage = null; // null means DTD
private final Schema grammar;
- private XMLComponent fSchemaValidator;
- private XMLComponentManager fSchemaValidatorComponentManager;
- private ValidationManager fSchemaValidationManager;
+ private final XMLComponent fSchemaValidator;
+ private final XMLComponentManager fSchemaValidatorComponentManager;
+ private final ValidationManager fSchemaValidationManager;
+ private final UnparsedEntityHandler fUnparsedEntityHandler;
/** Initial ErrorHandler */
private final ErrorHandler fInitErrorHandler;
@@ -170,16 +171,18 @@
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
fSchemaValidationManager = new ValidationManager();
- XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
- config.setDTDHandler(entityHandler);
- entityHandler.setDTDHandler(xmlReader);
- xmlReader.setDTDSource(entityHandler);
+ fUnparsedEntityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
+ config.setDTDHandler(fUnparsedEntityHandler);
+ fUnparsedEntityHandler.setDTDHandler(xmlReader);
+ xmlReader.setDTDSource(fUnparsedEntityHandler);
fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
(XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler());
+ fSchemaValidationManager = null;
+ fUnparsedEntityHandler = null;
fSchemaValidatorComponentManager = config;
}
config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures());
@@ -189,6 +192,12 @@
xmlReader.setDocumentSource((XMLDocumentSource) validatorComponent);
fSchemaValidator = validatorComponent;
}
+ else {
+ fSchemaValidationManager = null;
+ fUnparsedEntityHandler = null;
+ fSchemaValidatorComponentManager = null;
+ fSchemaValidator = null;
+ }
// Initial EntityResolver
fInitEntityResolver = xmlReader.getEntityResolver();
@@ -204,9 +213,11 @@
private void setFeatures(Hashtable features)
throws SAXNotSupportedException, SAXNotRecognizedException {
if (features != null) {
- for (Enumeration e = features.keys(); e.hasMoreElements();) {
- String feature = (String)e.nextElement();
- boolean value = ((Boolean)features.get(feature)).booleanValue();
+ Iterator entries = features.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String feature = (String) entry.getKey();
+ boolean value = ((Boolean) entry.getValue()).booleanValue();
xmlReader.setFeature0(feature, value);
}
}
@@ -275,6 +286,36 @@
return xmlReader.getProperty(name);
}
+ public void parse(InputSource is, DefaultHandler dh)
+ throws SAXException, IOException {
+ if (is == null) {
+ throw new IllegalArgumentException();
+ }
+ if (dh != null) {
+ xmlReader.setContentHandler(dh);
+ xmlReader.setEntityResolver(dh);
+ xmlReader.setErrorHandler(dh);
+ xmlReader.setDTDHandler(dh);
+ xmlReader.setDocumentHandler(null);
+ }
+ xmlReader.parse(is);
+ }
+
+ public void parse(InputSource is, HandlerBase hb)
+ throws SAXException, IOException {
+ if (is == null) {
+ throw new IllegalArgumentException();
+ }
+ if (hb != null) {
+ xmlReader.setDocumentHandler(hb);
+ xmlReader.setEntityResolver(hb);
+ xmlReader.setErrorHandler(hb);
+ xmlReader.setDTDHandler(hb);
+ xmlReader.setContentHandler(null);
+ }
+ xmlReader.parse(is);
+ }
+
public Schema getSchema() {
return grammar;
}
@@ -323,12 +364,12 @@
*/
public static class JAXPSAXParser extends com.sun.org.apache.xerces.internal.parsers.SAXParser {
- private HashMap fInitFeatures = new HashMap();
- private HashMap fInitProperties = new HashMap();
- private SAXParserImpl fSAXParser;
+ private final HashMap fInitFeatures = new HashMap();
+ private final HashMap fInitProperties = new HashMap();
+ private final SAXParserImpl fSAXParser;
public JAXPSAXParser() {
- super();
+ this(null);
}
JAXPSAXParser(SAXParserImpl saxParser) {
@@ -519,6 +560,7 @@
if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
if (fSAXParser.fSchemaValidationManager != null) {
fSAXParser.fSchemaValidationManager.reset();
+ fSAXParser.fUnparsedEntityHandler.reset();
}
resetSchemaValidator();
}
@@ -530,6 +572,7 @@
if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
if (fSAXParser.fSchemaValidationManager != null) {
fSAXParser.fSchemaValidationManager.reset();
+ fSAXParser.fUnparsedEntityHandler.reset();
}
resetSchemaValidator();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java Wed Sep 28 17:36:24 2011 +0100
@@ -37,8 +37,9 @@
* This filter records which unparsed entities have been
* declared in the DTD and provides this information to a ValidationManager.
* Events are forwarded to the registered XMLDTDHandler without modification.
- *
+ *
* @author Michael Glavassevich, IBM
+ * @version $Id: UnparsedEntityHandler.java,v 1.6 2010-11-01 04:40:07 joehw Exp $
*/
final class UnparsedEntityHandler implements XMLDTDFilter, EntityState {
@@ -63,10 +64,6 @@
public void startDTD(XMLLocator locator, Augmentations augmentations)
throws XNIException {
fValidationManager.setEntityState(this);
- if (fUnparsedEntities != null && !fUnparsedEntities.isEmpty()) {
- // should only clear this if the last document contained unparsed entities
- fUnparsedEntities.clear();
- }
if (fDTDHandler != null) {
fDTDHandler.startDTD(locator, augmentations);
}
@@ -252,4 +249,14 @@
return false;
}
+ /*
+ * Other methods
+ */
+
+ public void reset() {
+ if (fUnparsedEntities != null && !fUnparsedEntities.isEmpty()) {
+ // should only clear this if the last document contained unparsed entities
+ fUnparsedEntities.clear();
+ }
+ }
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -119,8 +119,12 @@
* hour |
* {@link #getHour()} |
*
- * 0 to 24 or {@link DatatypeConstants#FIELD_UNDEFINED}
- * For a value of 24, the minute and second field must be zero.
+ * 0 to 23 or {@link DatatypeConstants#FIELD_UNDEFINED}.
+ * An hour value of 24 is allowed to be set in the lexical space provided the minute and second
+ * field values are zero. However, an hour value of 24 is not allowed in value space and will be
+ * transformed to represent the value of the first instance of the following day as per
+ *
+ * XML Schema Part 2: Datatypes Second Edition, 3.2 Primitive datatypes.
* |
*
*
@@ -182,7 +186,7 @@
* @author Kohsuke Kawaguchi
* @author Joseph Fialli
* @author Sunitha Reddy
- * @version $Revision: 1.12 $, $Date: 2010/07/07 04:24:52 $
+ * @version $Revision: 1.14 $, $Date: 2010-11-10 07:41:41 $
* @see javax.xml.datatype.Duration
* @since 1.5
*/
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,34 +20,68 @@
package com.sun.org.apache.xerces.internal.jaxp.validation;
+import java.util.HashMap;
+
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
import javax.xml.validation.ValidatorHandler;
/**
* Abstract implementation of Schema for W3C XML Schemas.
- *
+ *
* @author Michael Glavassevich, IBM
+ * @version $Id: AbstractXMLSchema.java,v 1.6 2010-11-01 04:40:07 joehw Exp $
*/
abstract class AbstractXMLSchema extends Schema implements
XSGrammarPoolContainer {
+ /**
+ * Map containing the initial values of features for
+ * validators created using this grammar pool container.
+ */
+ private final HashMap fFeatures;
+
+ public AbstractXMLSchema() {
+ fFeatures = new HashMap();
+ }
+
/*
* Schema methods
*/
- /*
+ /*
* @see javax.xml.validation.Schema#newValidator()
*/
public final Validator newValidator() {
return new ValidatorImpl(this);
}
- /*
+ /*
* @see javax.xml.validation.Schema#newValidatorHandler()
*/
public final ValidatorHandler newValidatorHandler() {
return new ValidatorHandlerImpl(this);
}
+
+ /*
+ * XSGrammarPoolContainer methods
+ */
+ /**
+ * Returns the initial value of a feature for validators created
+ * using this grammar pool container or null if the validators
+ * should use the default value.
+ */
+ public final Boolean getFeature(String featureId) {
+ return (Boolean) fFeatures.get(featureId);
+ }
+
+ /*
+ * Other methods
+ */
+
+ final void setFeature(String featureId, boolean state) {
+ fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
+ }
+
} // AbstractXMLSchema
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java Wed Sep 28 17:36:24 2011 +0100
@@ -27,23 +27,17 @@
/**
* Implementation of Schema for W3C XML Schemas
* which contains no schema components.
- *
+ *
* @author Michael Glavassevich, IBM
+ * @version $Id: EmptyXMLSchema.java,v 1.6 2010-11-01 04:40:08 joehw Exp $
*/
final class EmptyXMLSchema extends AbstractXMLSchema implements XMLGrammarPool {
-
- private static EmptyXMLSchema EMPTY_XML_SCHEMA_INSTANCE = new EmptyXMLSchema();
-
+
/** Zero length grammar array. */
private static final Grammar [] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar [0];
-
- /** Returns the one and only instance of this class. */
- public static EmptyXMLSchema getInstance() {
- return EMPTY_XML_SCHEMA_INSTANCE;
- }
-
- private EmptyXMLSchema() {}
-
+
+ public EmptyXMLSchema() {}
+
/*
* XMLGrammarPool methods
*/
@@ -63,7 +57,7 @@
public void unlockPool() {}
public void clear() {}
-
+
/*
* XSGrammarPoolContainer methods
*/
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Wed Sep 28 17:36:24 2011 +0100
@@ -25,9 +25,11 @@
import java.io.Reader;
import javax.xml.XMLConstants;
+import javax.xml.stream.XMLEventReader;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -40,6 +42,7 @@
import com.sun.org.apache.xerces.internal.util.SAXInputSource;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.util.StAXInputSource;
import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
@@ -60,7 +63,7 @@
* {@link SchemaFactory} for XML Schema.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
- * @version $Id: XMLSchemaFactory.java,v 1.8 2010/07/23 02:23:47 joehw Exp $
+ * @version $Id: XMLSchemaFactory.java,v 1.11 2010-11-01 04:40:08 joehw Exp $
*/
public final class XMLSchemaFactory extends SchemaFactory {
@@ -198,6 +201,16 @@
String systemID = domSource.getSystemId();
xmlInputSources[i] = new DOMInputSource(node, systemID);
}
+ else if (source instanceof StAXSource) {
+ StAXSource staxSource = (StAXSource) source;
+ XMLEventReader eventReader = staxSource.getXMLEventReader();
+ if (eventReader != null) {
+ xmlInputSources[i] = new StAXInputSource(eventReader);
+ }
+ else {
+ xmlInputSources[i] = new StAXInputSource(staxSource.getXMLStreamReader());
+ }
+ }
else if (source == null) {
throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
"SchemaSourceArrayMemberNull", null));
@@ -228,21 +241,26 @@
// Select Schema implementation based on grammar count.
final int grammarCount = pool.getGrammarCount();
+ AbstractXMLSchema schema = null;
if (grammarCount > 1) {
- return new XMLSchema(new ReadOnlyGrammarPool(pool));
+ schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
}
else if (grammarCount == 1) {
Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
- return new SimpleXMLSchema(grammars[0]);
+ schema = new SimpleXMLSchema(grammars[0]);
}
else {
- return EmptyXMLSchema.getInstance();
+ schema = new EmptyXMLSchema();
}
+ propagateFeatures(schema);
+ return schema;
}
public Schema newSchema() throws SAXException {
// Use a Schema that uses the system id as the equality source.
- return new WeakReferenceXMLSchema();
+ AbstractXMLSchema schema = new WeakReferenceXMLSchema();
+ propagateFeatures(schema);
+ return schema;
}
public boolean getFeature(String name)
@@ -371,6 +389,15 @@
}
}
}
+
+ private void propagateFeatures(AbstractXMLSchema schema) {
+ schema.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fSecurityManager != null);
+ String[] features = fXMLSchemaLoader.getRecognizedFeatures();
+ for (int i = 0; i < features.length; ++i) {
+ boolean state = fXMLSchemaLoader.getFeature(features[i]);
+ schema.setFeature(features[i], state);
+ }
+ }
/**
* Extension of XMLGrammarPoolImpl which exposes the number of
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Wed Sep 28 17:36:24 2011 +0100
@@ -22,6 +22,8 @@
import java.util.HashMap;
import java.util.Locale;
+import java.util.Iterator;
+import java.util.Map;
import javax.xml.XMLConstants;
@@ -49,7 +51,7 @@
* An implementation of XMLComponentManager for a schema validator.
*
* @author Michael Glavassevich, IBM
- * @version $Id: XMLSchemaValidatorComponentManager.java,v 1.7 2010/07/23 02:09:26 joehw Exp $
+ * @version $Id: XMLSchemaValidatorComponentManager.java,v 1.9 2010-11-01 04:40:08 joehw Exp $
*/
final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettings implements
XMLComponentManager {
@@ -159,6 +161,19 @@
/** Validation manager. */
private ValidationManager fValidationManager;
+
+ //
+ // Configuration
+ //
+
+ /** Stores initial feature values for validator reset. */
+ private final HashMap fInitFeatures = new HashMap();
+
+ /** Stores initial property values for validator reset. */
+ private final HashMap fInitProperties = new HashMap();
+
+ /** Stores the initial security manager. */
+ private final SecurityManager fInitSecurityManager;
//
// User Objects
@@ -211,9 +226,20 @@
fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
// add all recognized features and properties and apply their defaults
- addRecognizedParamsAndSetDefaults(fEntityManager);
- addRecognizedParamsAndSetDefaults(fErrorReporter);
- addRecognizedParamsAndSetDefaults(fSchemaValidator);
+ addRecognizedParamsAndSetDefaults(fEntityManager, grammarContainer);
+ addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer);
+ addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer);
+
+ // if the secure processing feature is set to true, add a security manager to the configuration
+ Boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
+ if (Boolean.TRUE.equals(secureProcessing)) {
+ fInitSecurityManager = new SecurityManager();
+ }
+ else {
+ fInitSecurityManager = null;
+ }
+ fComponents.put(SECURITY_MANAGER, fInitSecurityManager);
+
}
/**
@@ -266,7 +292,6 @@
else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) {
throw new XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, featureId);
}
- fConfigUpdated = true;
if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
if (_isSecureMode && !value) {
throw new XMLConfigurationException(XMLConfigurationException.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
@@ -274,9 +299,14 @@
setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
return;
}
+ fConfigUpdated = true;
fEntityManager.setFeature(featureId, value);
fErrorReporter.setFeature(featureId, value);
fSchemaValidator.setFeature(featureId, value);
+ if (!fInitFeatures.containsKey(featureId)) {
+ boolean current = super.getFeature(featureId);
+ fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE);
+ }
super.setFeature(featureId, value);
}
@@ -336,6 +366,9 @@
fComponents.put(propertyId, value);
return;
}
+ if (!fInitProperties.containsKey(propertyId)) {
+ fInitProperties.put(propertyId, super.getProperty(propertyId));
+ }
super.setProperty(propertyId, value);
}
@@ -348,7 +381,7 @@
* @param component The component whose recognized features
* and properties will be added to the configuration
*/
- public void addRecognizedParamsAndSetDefaults(XMLComponent component) {
+ public void addRecognizedParamsAndSetDefaults(XMLComponent component, XSGrammarPoolContainer grammarContainer) {
// register component's recognized features
final String[] recognizedFeatures = component.getRecognizedFeatures();
@@ -359,7 +392,7 @@
addRecognizedProperties(recognizedProperties);
// set default values
- setFeatureDefaults(component, recognizedFeatures);
+ setFeatureDefaults(component, recognizedFeatures, grammarContainer);
setPropertyDefaults(component, recognizedProperties);
}
@@ -406,10 +439,6 @@
void restoreInitialState() {
fConfigUpdated = true;
- // Clear feature and property tables.
- fFeatures.clear();
- fProperties.clear();
-
// Remove error resolver and error handler
fComponents.put(ENTITY_RESOLVER, null);
fComponents.put(ERROR_HANDLER, null);
@@ -418,21 +447,46 @@
setLocale(null);
fComponents.put(LOCALE, null);
- // Restore component defaults.
- setFeatureDefaults(fEntityManager, fEntityManager.getRecognizedFeatures());
- setPropertyDefaults(fEntityManager, fEntityManager.getRecognizedProperties());
- setFeatureDefaults(fErrorReporter, fErrorReporter.getRecognizedFeatures());
- setPropertyDefaults(fErrorReporter, fErrorReporter.getRecognizedProperties());
- setFeatureDefaults(fSchemaValidator, fSchemaValidator.getRecognizedFeatures());
- setPropertyDefaults(fSchemaValidator, fSchemaValidator.getRecognizedProperties());
+ // Restore initial security manager
+ fComponents.put(SECURITY_MANAGER, fInitSecurityManager);
+
+ // Set the Locale back to null.
+ setLocale(null);
+ fComponents.put(LOCALE, null);
+
+ // Reset feature and property values to their initial values
+ if (!fInitFeatures.isEmpty()) {
+ Iterator iter = fInitFeatures.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ boolean value = ((Boolean) entry.getValue()).booleanValue();
+ super.setFeature(name, value);
+ }
+ fInitFeatures.clear();
+ }
+ if (!fInitProperties.isEmpty()) {
+ Iterator iter = fInitProperties.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ Object value = entry.getValue();
+ super.setProperty(name, value);
+ }
+ fInitProperties.clear();
+ }
}
/** Sets feature defaults for the given component on this configuration. */
- private void setFeatureDefaults(final XMLComponent component, final String [] recognizedFeatures) {
+ private void setFeatureDefaults(final XMLComponent component,
+ final String [] recognizedFeatures, XSGrammarPoolContainer grammarContainer) {
if (recognizedFeatures != null) {
for (int i = 0; i < recognizedFeatures.length; ++i) {
String featureId = recognizedFeatures[i];
- Boolean state = component.getFeatureDefault(featureId);
+ Boolean state = grammarContainer.getFeature(featureId);
+ if (state == null) {
+ state = component.getFeatureDefault(featureId);
+ }
if (state != null) {
// Do not overwrite values already set on the configuration.
if (!fFeatures.containsKey(featureId)) {
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java Wed Sep 28 17:36:24 2011 +0100
@@ -24,27 +24,35 @@
/**
* A container for grammar pools which only contain schema grammars.
- *
+ *
* @author Michael Glavassevich, IBM
+ * @version $Id: XSGrammarPoolContainer.java,v 1.6 2010-11-01 04:40:08 joehw Exp $
*/
public interface XSGrammarPoolContainer {
-
+
/**
* Returns the grammar pool contained inside the container.
- *
+ *
* @return the grammar pool contained inside the container
*/
public XMLGrammarPool getGrammarPool();
-
+
/**
* Returns whether the schema components contained in this object
* can be considered to be a fully composed schema and should be
* used to the exclusion of other schema components which may be
* present elsewhere.
- *
+ *
* @return whether the schema components contained in this object
* can be considered to be a fully composed schema
*/
public boolean isFullyComposed();
+ /**
+ * Returns the initial value of a feature for validators created
+ * using this grammar pool container or null if the validators
+ * should use the default value.
+ */
+ public Boolean getFeature(String featureId);
+
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java Wed Sep 28 17:36:24 2011 +0100
@@ -59,9 +59,9 @@
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
+import org.w3c.dom.DOMError;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
-import org.w3c.dom.DOMError;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.NamedNodeMap;
@@ -84,7 +84,7 @@
* @author Andy Clark, IBM
* @author Elena Litani, IBM
*
- * @version $Id: AbstractDOMParser.java,v 1.5 2009/12/01 06:12:03 joehw Exp $
+ * @version $Id: AbstractDOMParser.java,v 1.10 2010-11-01 04:40:09 joehw Exp $
*/
public class AbstractDOMParser extends AbstractXMLDocumentParser {
@@ -162,7 +162,14 @@
/**
* If the user stops the process, this exception will be thrown.
*/
- public static final RuntimeException abort = new RuntimeException();
+ static final class Abort extends RuntimeException {
+ private static final long serialVersionUID = 1687848994976808490L;
+ static final Abort INSTANCE = new Abort();
+ private Abort() {}
+ public Throwable fillInStackTrace() {
+ return this;
+ }
+ }
// debugging
@@ -224,7 +231,7 @@
/** Internal subset buffer. */
protected StringBuilder fInternalSubset;
- // deferred expansion datfInternalSubseta
+ // deferred expansion data
protected boolean fDeferNodeExpansion;
protected boolean fNamespaceAware;
@@ -239,8 +246,8 @@
/** True if inside DTD external subset. */
protected boolean fInDTDExternalSubset;
- /** Root element name */
- protected QName fRoot = new QName();
+ /** Root element node. */
+ protected Node fRoot;
/** True if inside CDATA section. */
protected boolean fInCDATASection;
@@ -256,20 +263,22 @@
// data
/** Base uri stack*/
- protected Stack fBaseURIStack = new Stack ();
-
+ protected final Stack fBaseURIStack = new Stack ();
- /** LSParserFilter: the QNAME of rejected element*/
- protected final QName fRejectedElement = new QName ();
+ /** LSParserFilter: tracks the element depth within a rejected subtree. */
+ protected int fRejectedElementDepth = 0;
- /** LSParserFilter: store qnames of skipped elements*/
+ /** LSParserFilter: store depth of skipped elements */
protected Stack fSkippedElemStack = null;
/** LSParserFilter: true if inside entity reference */
protected boolean fInEntityRef = false;
/** Attribute QName. */
- private QName fAttrQName = new QName ();
+ private final QName fAttrQName = new QName();
+
+ /** Document locator. */
+ private XMLLocator fLocator;
// handlers
@@ -371,6 +380,20 @@
return fDocument;
} // getDocument():Document
+ /**
+ * Drops all references to the last DOM which was built by this parser.
+ */
+ public final void dropDocumentReferences() {
+ fDocument = null;
+ fDocumentImpl = null;
+ fDeferredDocumentImpl = null;
+ fDocumentType = null;
+ fCurrentNode = null;
+ fCurrentCDATASection = null;
+ fCurrentEntityDecl = null;
+ fRoot = null;
+ } // dropDocumentReferences()
+
//
// XMLDocumentParser methods
//
@@ -417,7 +440,7 @@
fStringBuilder.setLength (0);
// reset state information
- fRoot.clear();
+ fRoot = null;
fInDTD = false;
fInDTDExternalSubset = false;
fInCDATASection = false;
@@ -581,9 +604,11 @@
public void comment (XMLString text, Augmentations augs) throws XNIException {
if (fInDTD) {
if (fInternalSubset != null && !fInDTDExternalSubset) {
- fInternalSubset.append ("");
+ fInternalSubset.append ("");
}
return;
}
@@ -600,7 +625,7 @@
short code = fDOMFilter.acceptNode (comment);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// REVISIT: the constant FILTER_REJECT should be changed when new
@@ -656,10 +681,10 @@
if (fInternalSubset != null && !fInDTDExternalSubset) {
fInternalSubset.append ("");
fInternalSubset.append (target);
- fInternalSubset.append (' ');
- fInternalSubset.append (data.toString ());
+ if (data.length > 0) {
+ fInternalSubset.append (' ').append (data.ch, data.offset, data.length);
+ }
fInternalSubset.append ("?>");
-
}
return;
}
@@ -682,7 +707,7 @@
short code = fDOMFilter.acceptNode (pi);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since PI has no children.
@@ -734,6 +759,7 @@
NamespaceContext namespaceContext, Augmentations augs)
throws XNIException {
+ fLocator = locator;
if (!fDeferNodeExpansion) {
if (fDocumentClassName.equals (DEFAULT_DOCUMENT_CLASS_NAME)) {
fDocument = new DocumentImpl ();
@@ -906,10 +932,12 @@
}
if (!fDeferNodeExpansion) {
if (fFilterReject) {
+ ++fRejectedElementDepth;
return;
}
Element el = createElementNode (element);
int attrCount = attributes.getLength ();
+ boolean seenSchemaDefault = false;
for (int i = 0; i < attrCount; i++) {
attributes.getName (i, fAttrQName);
Attr attr = createAttrNode (fAttrQName);
@@ -921,9 +949,19 @@
((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
}
-
attr.setValue (attrValue);
- el.setAttributeNode (attr);
+ boolean specified = attributes.isSpecified(i);
+ // Take special care of schema defaulted attributes. Calling the
+ // non-namespace aware setAttributeNode() method could overwrite
+ // another attribute with the same local name.
+ if (!specified && (seenSchemaDefault || (fAttrQName.uri != null &&
+ fAttrQName.uri != NamespaceContext.XMLNS_URI && fAttrQName.prefix == null))) {
+ el.setAttributeNodeNS(attr);
+ seenSchemaDefault = true;
+ }
+ else {
+ el.setAttributeNode(attr);
+ }
// NOTE: The specified value MUST be set after you set
// the node value because that turns the "specified"
// flag to "true" which may overwrite a "false"
@@ -970,7 +1008,7 @@
((ElementImpl) el).setIdAttributeNode (attr, true);
}
- attrImpl.setSpecified (attributes.isSpecified (i));
+ attrImpl.setSpecified (specified);
// REVISIT: Handle entities in attribute value.
}
}
@@ -990,28 +1028,39 @@
// filter nodes
if (fDOMFilter != null && !fInEntityRef) {
- if (fRoot.rawname == null) {
+ if (fRoot == null) {
// fill value of the root element
- fRoot.setValues(element);
+ fRoot = el;
} else {
short code = fDOMFilter.startElement(el);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT :
{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT :
{
fFilterReject = true;
- fRejectedElement.setValues(element);
+ fRejectedElementDepth = 0;
return;
}
case LSParserFilter.FILTER_SKIP :
{
- fSkippedElemStack.push(element.clone());
+ // make sure that if any char data is available
+ // the fFirstChunk is true, so that if the next event
+ // is characters(), and the last node is text, we will copy
+ // the value already in the text node to fStringBuffer
+ // (not to lose it).
+ fFirstChunk = true;
+ fSkippedElemStack.push(Boolean.TRUE);
return;
}
- default : {}
+ default :
+ {
+ if (!fSkippedElemStack.isEmpty()) {
+ fSkippedElemStack.push(Boolean.FALSE);
+ }
+ }
}
}
}
@@ -1019,24 +1068,14 @@
fCurrentNode = el;
}
else {
+ int el = fDeferredDocumentImpl.createDeferredElement (fNamespaceAware ?
+ element.uri : null, element.rawname);
Object type = null;
- if (augs != null) {
- ElementPSVI elementPSVI = (ElementPSVI)augs.getItem (Constants.ELEMENT_PSVI);
- if (elementPSVI != null) {
- type = elementPSVI.getMemberTypeDefinition ();
- if (type == null) {
- type = elementPSVI.getTypeDefinition ();
- }
- }
- }
+ int attrCount = attributes.getLength ();
+ // Need to loop in reverse order so that the attributes
+ // are processed in document order when the DOM is expanded.
+ for (int i = attrCount - 1; i >= 0; --i) {
- int el =
- fDeferredDocumentImpl.createDeferredElement (fNamespaceAware ?
- element.uri : null,
- element.rawname,
- type);
- int attrCount = attributes.getLength ();
- for (int i = 0; i < attrCount; i++) {
// set type information
AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations (i).getItem (Constants.ATTRIBUTE_PSVI);
boolean id = false;
@@ -1142,7 +1181,6 @@
return;
}
- String value = text.toString ();
Node child = fCurrentNode.getLastChild ();
if (child != null && child.getNodeType () == Node.TEXT_NODE) {
// collect all the data into the string buffer.
@@ -1155,11 +1193,13 @@
}
fFirstChunk = false;
}
- fStringBuilder.append (value);
+ if (text.length > 0) {
+ fStringBuilder.append (text.ch, text.offset, text.length);
+ }
}
else {
fFirstChunk = true;
- Text textNode = fDocument.createTextNode (value);
+ Text textNode = fDocument.createTextNode (text.toString());
fCurrentNode.appendChild (textNode);
}
@@ -1277,23 +1317,22 @@
if (fDOMFilter != null) {
if (fFilterReject) {
- if (element.equals (fRejectedElement)) {
+ if (fRejectedElementDepth-- == 0) {
fFilterReject = false;
}
return;
}
- if (!fSkippedElemStack.isEmpty ()) {
- if (fSkippedElemStack.peek ().equals (element)) {
- fSkippedElemStack.pop ();
+ if (!fSkippedElemStack.isEmpty()) {
+ if (fSkippedElemStack.pop() == Boolean.TRUE) {
return;
}
}
setCharacterData (false);
- if (!fRoot.equals(element) && !fInEntityRef && (fDOMFilter.getWhatToShow () & NodeFilter.SHOW_ELEMENT)!=0) {
+ if ((fCurrentNode != fRoot) && !fInEntityRef && (fDOMFilter.getWhatToShow () & NodeFilter.SHOW_ELEMENT)!=0) {
short code = fDOMFilter.acceptNode (fCurrentNode);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
Node parent = fCurrentNode.getParentNode ();
@@ -1306,7 +1345,7 @@
// the fFirstChunk is true, so that if the next event
// is characters(), and the last node is text, we will copy
// the value already in the text node to fStringBuffer
- // (not to loose it).
+ // (not to lose it).
fFirstChunk = true;
// replace children
@@ -1336,8 +1375,21 @@
}
else {
+ if (augs != null) {
+ ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI);
+ if (elementPSVI != null) {
+ // Setting TypeInfo. If the declared type is a union the
+ // [member type definition] will only be available at the
+ // end of an element.
+ XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
+ if (type == null) {
+ type = elementPSVI.getTypeDefinition();
+ }
+ fDeferredDocumentImpl.setTypeInfo(fCurrentNodeIndex, type);
+ }
+ }
fCurrentNodeIndex =
- fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
+ fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
}
@@ -1385,7 +1437,7 @@
short code = fDOMFilter.acceptNode (fCurrentCDATASection);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since CDATA section has no children.
@@ -1428,13 +1480,22 @@
if (!fDeferNodeExpansion) {
// REVISIT: when DOM Level 3 is REC rely on Document.support
// instead of specific class
- // set DOM error checking back on
+ // set the actual encoding and set DOM error checking back on
if (fDocumentImpl != null) {
+ if (fLocator != null) {
+ if (fLocator.getEncoding() != null)
+ fDocumentImpl.setInputEncoding (fLocator.getEncoding());
+ }
fDocumentImpl.setStrictErrorChecking (true);
}
fCurrentNode = null;
}
else {
+ // set the actual encoding
+ if (fLocator != null) {
+ if (fLocator.getEncoding() != null)
+ fDeferredDocumentImpl.setInputEncoding (fLocator.getEncoding());
+ }
fCurrentNodeIndex = -1;
}
@@ -1497,7 +1558,7 @@
short code = fDOMFilter.acceptNode (fCurrentNode);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
Node parent = fCurrentNode.getParentNode ();
@@ -1652,7 +1713,7 @@
baseURI = ((EntityReferenceImpl)fCurrentNode).getBaseURI ();
if (baseURI !=null && !baseURI.equals (fDocumentImpl.getDocumentURI ())) {
if (fNamespaceAware) {
- ((Element)node).setAttributeNS ("http://www.w3.org/XML/1998/namespace","base", baseURI);
+ ((Element)node).setAttributeNS ("http://www.w3.org/XML/1998/namespace", "xml:base", baseURI);
} else {
((Element)node).setAttribute ("xml:base", baseURI);
}
@@ -2054,6 +2115,11 @@
System.out.println (" baseURI:"+ identifier.getBaseSystemId ());
}
}
+ if (augs != null && fInternalSubset != null &&
+ !fInDTDExternalSubset &&
+ Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
+ fInternalSubset.append(name).append(";\n");
+ }
fBaseURIStack.push (identifier.getExpandedSystemId ());
}
@@ -2364,8 +2430,23 @@
fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, elementDefIndex);
}
// add default attribute
+ boolean nsEnabled = fNamespaceAware;
+ String namespaceURI = null;
+ if (nsEnabled) {
+ // DOM Level 2 wants all namespace declaration attributes
+ // to be bound to "http://www.w3.org/2000/xmlns/"
+ // So as long as the XML parser doesn't do it, it needs to
+ // done here.
+ if (attributeName.startsWith("xmlns:") ||
+ attributeName.equals("xmlns")) {
+ namespaceURI = NamespaceContext.XMLNS_URI;
+ }
+ else if (attributeName.startsWith("xml:")) {
+ namespaceURI = NamespaceContext.XML_URI;
+ }
+ }
int attrIndex = fDeferredDocumentImpl.createDeferredAttribute (
- attributeName, defaultValue.toString (), false);
+ attributeName, namespaceURI, defaultValue.toString(), false);
if ("ID".equals (type)) {
fDeferredDocumentImpl.setIdAttribute (attrIndex);
}
@@ -2400,10 +2481,13 @@
// to be bound to "http://www.w3.org/2000/xmlns/"
// So as long as the XML parser doesn't do it, it needs to
// done here.
- if (attributeName.startsWith ("xmlns:") ||
- attributeName.equals ("xmlns")) {
+ if (attributeName.startsWith("xmlns:") ||
+ attributeName.equals("xmlns")) {
namespaceURI = NamespaceContext.XMLNS_URI;
}
+ else if (attributeName.startsWith("xml:")) {
+ namespaceURI = NamespaceContext.XML_URI;
+ }
attr = (AttrImpl)fDocumentImpl.createAttributeNS (namespaceURI,
attributeName);
}
@@ -2546,7 +2630,7 @@
short code = fDOMFilter.acceptNode (child);
switch (code) {
case LSParserFilter.FILTER_INTERRUPT:{
- throw abort;
+ throw Abort.INSTANCE;
}
case LSParserFilter.FILTER_REJECT:{
// fall through to SKIP since Comment has no children.
@@ -2570,7 +2654,7 @@
* @see org.w3c.dom.ls.LSParser#abort()
*/
public void abort () {
- throw abort;
+ throw Abort.INSTANCE;
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,6 +32,7 @@
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper;
import com.sun.org.apache.xerces.internal.util.DOMErrorHandlerWrapper;
+import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
@@ -77,6 +78,7 @@
* @author Pavani Mukthipudi, Sun Microsystems Inc.
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
+ * @version $Id: DOMParserImpl.java,v 1.8 2010-11-01 04:40:09 joehw Exp $
*/
@@ -98,10 +100,10 @@
/** XML Schema validation */
protected static final String XMLSCHEMA =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
-
+
/** XML Schema full checking */
protected static final String XMLSCHEMA_FULL_CHECKING =
- Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
+ Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
/** Dynamic validation */
protected static final String DYNAMIC_VALIDATION =
@@ -115,6 +117,14 @@
protected static final String DISALLOW_DOCTYPE_DECL_FEATURE =
Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
// internal properties
protected static final String SYMBOL_TABLE =
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
@@ -129,24 +139,24 @@
/** Include namespace declaration attributes in the document. **/
protected boolean fNamespaceDeclarations = true;
-
+
// REVISIT: this value should be null by default and should be set during creation of
// LSParser
protected String fSchemaType = null;
protected boolean fBusy = false;
-
+
private boolean abortNow = false;
-
+
private Thread currentThread;
protected final static boolean DEBUG = false;
private Vector fSchemaLocations = new Vector ();
private String fSchemaLocation = null;
- private DOMStringList fRecognizedParameters;
-
- private AbortHandler abortHandler = new AbortHandler();
+ private DOMStringList fRecognizedParameters;
+
+ private AbortHandler abortHandler = null;
//
// Constructors
@@ -163,10 +173,10 @@
if (schemaType != null) {
if (schemaType.equals (Constants.NS_DTD)) {
//Schema validation is false by default and hence there is no
- //need to set it to false here. Also, schema validation is
- //not a recognized feature for DTDConfiguration's and so
- //setting this feature here would result in a Configuration
- //Exception.
+ //need to set it to false here. Also, schema validation is
+ //not a recognized feature for DTDConfiguration's and so
+ //setting this feature here would result in a Configuration
+ //Exception.
fConfiguration.setProperty (
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
Constants.NS_DTD);
@@ -221,7 +231,7 @@
fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
fConfiguration.setFeature(NAMESPACES, true);
-
+
fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
@@ -244,7 +254,7 @@
fConfiguration.setFeature ( NORMALIZE_DATA, false );
}
catch (XMLConfigurationException exc) {}
-
+
} // (XMLParserConfiguration)
/**
@@ -286,17 +296,17 @@
*/
public void reset () {
super.reset ();
-
+
// get state of namespace-declarations parameter.
- fNamespaceDeclarations =
+ fNamespaceDeclarations =
fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
-
+
// DOM Filter
if (fSkippedElemStack!=null) {
fSkippedElemStack.removeAllElements ();
}
fSchemaLocations.clear ();
- fRejectedElement.clear ();
+ fRejectedElementDepth = 0;
fFilterReject = false;
fSchemaType = null;
@@ -345,7 +355,7 @@
*/
public void setParameter (String name, Object value) throws DOMException {
// set features
-
+
if(value instanceof Boolean){
boolean state = ((Boolean)value).booleanValue ();
try {
@@ -381,7 +391,7 @@
else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
// Setting false has no effect.
if (state) {
- // true: namespaces, namespace-declarations,
+ // true: namespaces, namespace-declarations,
// comments, element-content-whitespace
fConfiguration.setFeature(NAMESPACES, true);
fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
@@ -445,7 +455,17 @@
// Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING feature,
// Constants.DOM_SPLIT_CDATA feature,
// or any Xerces feature
- fConfiguration.setFeature (name.toLowerCase(Locale.ENGLISH), state);
+ String normalizedName;
+ if (name.equals(NAMESPACE_GROWTH)) {
+ normalizedName = NAMESPACE_GROWTH;
+ }
+ else if (name.equals(TOLERATE_DUPLICATES)) {
+ normalizedName = TOLERATE_DUPLICATES;
+ }
+ else {
+ normalizedName = name.toLowerCase(Locale.ENGLISH);
+ }
+ fConfiguration.setFeature (normalizedName, state);
}
}
@@ -590,14 +610,30 @@
fConfiguration.setProperty (DOCUMENT_CLASS_NAME, value);
}
else {
- // REVISIT: check if this is a boolean parameter -- type mismatch should be thrown.
- //parameter is not recognized
- String msg =
- DOMMessageFormatter.formatMessage (
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_FOUND",
- new Object[] { name });
- throw new DOMException (DOMException.NOT_FOUND_ERR, msg);
+ // Try to set the property.
+ String normalizedName = name.toLowerCase(Locale.ENGLISH);
+ try {
+ fConfiguration.setProperty(normalizedName, value);
+ return;
+ }
+ catch (XMLConfigurationException e) {}
+
+ // If this is a boolean parameter a type mismatch should be thrown.
+ try {
+ if (name.equals(NAMESPACE_GROWTH)) {
+ normalizedName = NAMESPACE_GROWTH;
+ }
+ else if (name.equals(TOLERATE_DUPLICATES)) {
+ normalizedName = TOLERATE_DUPLICATES;
+ }
+ fConfiguration.getFeature(normalizedName);
+ throw newTypeMismatchError(name);
+
+ }
+ catch (XMLConfigurationException e) {}
+
+ // Parameter is not recognized
+ throw newFeatureNotFoundError(name);
}
}
}
@@ -712,21 +748,40 @@
return fConfiguration.getProperty (DOCUMENT_CLASS_NAME);
}
else {
- String msg =
- DOMMessageFormatter.formatMessage (
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_FOUND",
- new Object[] { name });
- throw new DOMException (DOMException.NOT_FOUND_ERR, msg);
+ // This could be a recognized feature or property.
+ String normalizedName;
+
+ if (name.equals(NAMESPACE_GROWTH)) {
+ normalizedName = NAMESPACE_GROWTH;
+ }
+ else if (name.equals(TOLERATE_DUPLICATES)) {
+ normalizedName = TOLERATE_DUPLICATES;
+ }
+ else {
+ normalizedName = name.toLowerCase(Locale.ENGLISH);
+ }
+ try {
+ return fConfiguration.getFeature(normalizedName)
+ ? Boolean.TRUE : Boolean.FALSE;
+ }
+ catch (XMLConfigurationException e) {}
+
+ // This isn't a feature; perhaps it's a property
+ try {
+ return fConfiguration.getProperty(normalizedName);
+ }
+ catch (XMLConfigurationException e) {}
+
+ throw newFeatureNotFoundError(name);
}
return null;
}
public boolean canSetParameter (String name, Object value) {
- if (value == null){
- return true;
- }
-
+ if (value == null){
+ return true;
+ }
+
if(value instanceof Boolean){
boolean state = ((Boolean)value).booleanValue ();
if ( name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
@@ -759,7 +814,17 @@
// Recognize Xerces features.
try {
- fConfiguration.getFeature(name.toLowerCase(Locale.ENGLISH));
+ String normalizedName;
+ if (name.equalsIgnoreCase(NAMESPACE_GROWTH)) {
+ normalizedName = NAMESPACE_GROWTH;
+ }
+ else if (name.equalsIgnoreCase(TOLERATE_DUPLICATES)) {
+ normalizedName = TOLERATE_DUPLICATES;
+ }
+ else {
+ normalizedName = name.toLowerCase(Locale.ENGLISH);
+ }
+ fConfiguration.getFeature(normalizedName);
return true;
}
catch (XMLConfigurationException e) {
@@ -810,40 +875,40 @@
public DOMStringList getParameterNames () {
if (fRecognizedParameters == null){
Vector parameters = new Vector();
-
+
// REVISIT: add Xerces recognized properties/features
parameters.add(Constants.DOM_NAMESPACES);
parameters.add(Constants.DOM_CDATA_SECTIONS);
parameters.add(Constants.DOM_CANONICAL_FORM);
parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
parameters.add(Constants.DOM_SPLIT_CDATA);
-
+
parameters.add(Constants.DOM_ENTITIES);
parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
parameters.add(Constants.DOM_VALIDATE);
parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
-
+
parameters.add(Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING);
parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
parameters.add(Constants.DOM_SUPPORTED_MEDIATYPES_ONLY);
parameters.add(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS);
-
+
parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
parameters.add(Constants.DOM_WELLFORMED);
parameters.add(Constants.DOM_INFOSET);
parameters.add(Constants.DOM_DISALLOW_DOCTYPE);
parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
parameters.add(Constants.DOM_COMMENTS);
-
+
parameters.add(Constants.DOM_ERROR_HANDLER);
parameters.add(Constants.DOM_RESOURCE_RESOLVER);
parameters.add(Constants.DOM_SCHEMA_LOCATION);
parameters.add(Constants.DOM_SCHEMA_TYPE);
-
+
fRecognizedParameters = new DOMStringListImpl(parameters);
-
+
}
-
+
return fRecognizedParameters;
}
@@ -867,11 +932,11 @@
XMLInputSource source = new XMLInputSource (null, uri, null);
try {
currentThread = Thread.currentThread();
- fBusy = true;
+ fBusy = true;
parse (source);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
- //reset interrupt state
+ //reset interrupt state
abortNow = false;
Thread.interrupted();
}
@@ -887,7 +952,7 @@
}
// Consume this exception if the user
// issued an interrupt or an abort.
- if (e != abort) {
+ if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
@@ -898,10 +963,12 @@
if (DEBUG) {
e.printStackTrace ();
}
- throw new LSException(LSException.PARSE_ERR, e.getMessage());
+ throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
- return getDocument ();
+ Document doc = getDocument();
+ dropDocumentReferences();
+ return doc;
}
/**
@@ -922,11 +989,11 @@
try {
currentThread = Thread.currentThread();
- fBusy = true;
+ fBusy = true;
parse (xmlInputSource);
- fBusy = false;
+ fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
- //reset interrupt state
+ //reset interrupt state
abortNow = false;
Thread.interrupted();
}
@@ -942,7 +1009,7 @@
}
// Consume this exception if the user
// issued an interrupt or an abort.
- if (e != abort) {
+ if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
@@ -953,10 +1020,12 @@
if (DEBUG) {
e.printStackTrace ();
}
- throw new LSException(LSException.PARSE_ERR, e.getMessage());
+ throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
- return getDocument ();
+ Document doc = getDocument();
+ dropDocumentReferences();
+ return doc;
}
@@ -1022,12 +1091,12 @@
"UTF-16");
}
// otherwise, just use the public/system/base Ids
- else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
+ else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
(is.getPublicId() != null && is.getPublicId().length() > 0)) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI ());
}
- else {
+ else {
// all inputs are null
if (fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
@@ -1064,16 +1133,18 @@
fBusy = false;
if(currentThread != null) {
abortNow = true;
-
+ if (abortHandler == null) {
+ abortHandler = new AbortHandler();
+ }
fConfiguration.setDocumentHandler(abortHandler);
fConfiguration.setDTDHandler(abortHandler);
fConfiguration.setDTDContentModelHandler(abortHandler);
-
+
if(currentThread == Thread.currentThread())
- throw abort;
-
+ throw Abort.INSTANCE;
+
currentThread.interrupt();
- }
+ }
}
return; // If not busy then this is noop
}
@@ -1103,7 +1174,7 @@
}
super.startElement(element, attributes, augs);
}
-
+
private class AbortHandler implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
private XMLDocumentSource documentSource;
@@ -1111,67 +1182,67 @@
private XMLDTDSource dtdSource;
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void comment(XMLString text, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void characters(XMLString text, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endElement(QName element, Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startCDATA(Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endCDATA(Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endDocument(Augmentations augs) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void setDocumentSource(XMLDocumentSource source) {
@@ -1183,71 +1254,71 @@
}
public void startDTD(XMLLocator locator, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endParameterEntity(String name, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endExternalSubset(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void elementDecl(String name, String contentModel, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startAttlist(String elementName, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endAttlist(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startConditional(short type, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void ignoredCharacters(XMLString text, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endConditional(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endDTD(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void setDTDSource(XMLDTDSource source) {
@@ -1259,43 +1330,43 @@
}
public void startContentModel(String elementName, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void any(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void empty(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void startGroup(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void pcdata(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void element(String elementName, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void separator(short separator, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void occurrence(short occurrence, Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endGroup(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void endContentModel(Augmentations augmentations) throws XNIException {
- throw abort;
+ throw Abort.INSTANCE;
}
public void setDTDContentModelSource(XMLDTDContentModelSource source) {
@@ -1305,7 +1376,25 @@
public XMLDTDContentModelSource getDTDContentModelSource() {
return dtdContentSource;
}
-
+
}
+ private static DOMException newFeatureNotFoundError(String name) {
+ String msg =
+ DOMMessageFormatter.formatMessage (
+ DOMMessageFormatter.DOM_DOMAIN,
+ "FEATURE_NOT_FOUND",
+ new Object[] { name });
+ return new DOMException (DOMException.NOT_FOUND_ERR, msg);
+ }
+
+ private static DOMException newTypeMismatchError(String name) {
+ String msg =
+ DOMMessageFormatter.formatMessage (
+ DOMMessageFormatter.DOM_DOMAIN,
+ "TYPE_MISMATCH_ERR",
+ new Object[] { name });
+ return new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
+ }
+
} // class DOMParserImpl
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java Wed Sep 28 17:36:24 2011 +0100
@@ -30,13 +30,13 @@
/**
* This is the "standard" parser configuration. It extends the DTD
- * configuration with the standard set of parser components.
+ * configuration with the standard set of parser components.
* The standard set of parser components include those needed
* to parse and validate with DTD's, and those needed for XML
* Schema.
*
* In addition to the features and properties recognized by the base
- * parser configuration, this class recognizes these additional
+ * parser configuration, this class recognizes these additional
* features and properties:
*
* - Features
@@ -61,6 +61,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
+ * @version $Id: StandardParserConfiguration.java,v 1.7 2010-11-01 04:40:10 joehw Exp $
*/
public class StandardParserConfiguration
extends DTDConfiguration {
@@ -87,25 +88,33 @@
/** feature identifier: XML Schema validation */
- protected static final String XMLSCHEMA_VALIDATION =
+ protected static final String XMLSCHEMA_VALIDATION =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
/** feature identifier: XML Schema validation -- full checking */
- protected static final String XMLSCHEMA_FULL_CHECKING =
+ protected static final String XMLSCHEMA_FULL_CHECKING =
Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
-
+
/** Feature: generate synthetic annotations */
- protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =
+ protected static final String GENERATE_SYNTHETIC_ANNOTATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;
-
+
/** Feature identifier: validate annotations */
protected static final String VALIDATE_ANNOTATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE;
-
+
/** Feature identifier: honour all schemaLocations */
- protected static final String HONOUR_ALL_SCHEMALOCATIONS =
+ protected static final String HONOUR_ALL_SCHEMALOCATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
// property identifiers
/** Property identifier: XML Schema validator. */
@@ -120,6 +129,10 @@
protected static final String SCHEMA_NONS_LOCATION =
Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION;
+ /** Property identifier: Schema DV Factory */
+ protected static final String SCHEMA_DV_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
+
//
// Data
//
@@ -138,8 +151,8 @@
this(null, null, null);
} // ()
- /**
- * Constructs a parser configuration using the specified symbol table.
+ /**
+ * Constructs a parser configuration using the specified symbol table.
*
* @param symbolTable The symbol table to use.
*/
@@ -151,7 +164,7 @@
* Constructs a parser configuration using the specified symbol table and
* grammar pool.
*
- * REVISIT:
+ * REVISIT:
* Grammar pool will be updated when the new validation engine is
* implemented.
*
@@ -167,7 +180,7 @@
* Constructs a parser configuration using the specified symbol table,
* grammar pool, and parent settings.
*
- * REVISIT:
+ * REVISIT:
* Grammar pool will be updated when the new validation engine is
* implemented.
*
@@ -188,6 +201,8 @@
GENERATE_SYNTHETIC_ANNOTATIONS,
VALIDATE_ANNOTATIONS,
HONOUR_ALL_SCHEMALOCATIONS,
+ NAMESPACE_GROWTH,
+ TOLERATE_DUPLICATES,
// NOTE: These shouldn't really be here but since the XML Schema
// validator is constructed dynamically, its recognized
// features might not have been set and it would cause a
@@ -204,9 +219,11 @@
setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false);
setFeature(VALIDATE_ANNOTATIONS, false);
setFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
+ setFeature(NAMESPACE_GROWTH, false);
+ setFeature(TOLERATE_DUPLICATES, false);
// add default recognized properties
-
+
final String[] recognizedProperties = {
// NOTE: These shouldn't really be here but since the XML Schema
// validator is constructed dynamically, its recognized
@@ -214,9 +231,10 @@
// not-recognized exception to be thrown. -Ac
SCHEMA_LOCATION,
SCHEMA_NONS_LOCATION,
+ SCHEMA_DV_FACTORY,
};
- addRecognizedProperties(recognizedProperties);
+ addRecognizedProperties(recognizedProperties);
} // (SymbolTable,XMLGrammarPool)
@@ -230,8 +248,8 @@
if ( getFeature(XMLSCHEMA_VALIDATION )) {
// If schema validator was not in the pipeline insert it.
if (fSchemaValidator == null) {
- fSchemaValidator = new XMLSchemaValidator();
-
+ fSchemaValidator = new XMLSchemaValidator();
+
// add schema component
fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator);
addComponent(fSchemaValidator);
@@ -244,10 +262,10 @@
}
fLastComponent = fSchemaValidator;
fNamespaceBinder.setDocumentHandler(fSchemaValidator);
-
+
fSchemaValidator.setDocumentHandler(fDocumentHandler);
fSchemaValidator.setDocumentSource(fNamespaceBinder);
- }
+ }
} // configurePipeline()
@@ -275,12 +293,12 @@
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
-
+
//
// http://apache.org/xml/features/validation/schema
// Lets the user turn Schema validation support on/off.
//
- if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() &&
+ if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() &&
featureId.endsWith(Constants.SCHEMA_VALIDATION_FEATURE)) {
return;
}
@@ -289,15 +307,15 @@
featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) {
return;
}
- // Feature identifier: expose schema normalized value
+ // Feature identifier: expose schema normalized value
// http://apache.org/xml/features/validation/schema/normalized-value
- if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&
+ if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&
featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) {
return;
- }
- // Feature identifier: send element default value via characters()
+ }
+ // Feature identifier: send element default value via characters()
// http://apache.org/xml/features/validation/schema/element-default
- if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&
+ if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&
featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) {
return;
}
@@ -333,12 +351,12 @@
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
-
- if (suffixLength == Constants.SCHEMA_LOCATION.length() &&
+
+ if (suffixLength == Constants.SCHEMA_LOCATION.length() &&
propertyId.endsWith(Constants.SCHEMA_LOCATION)) {
return;
}
- if (suffixLength == Constants.SCHEMA_NONS_LOCATION.length() &&
+ if (suffixLength == Constants.SCHEMA_NONS_LOCATION.length() &&
propertyId.endsWith(Constants.SCHEMA_NONS_LOCATION)) {
return;
}
@@ -346,8 +364,8 @@
if (propertyId.startsWith(Constants.JAXP_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.JAXP_PROPERTY_PREFIX.length();
-
- if (suffixLength == Constants.SCHEMA_SOURCE.length() &&
+
+ if (suffixLength == Constants.SCHEMA_SOURCE.length() &&
propertyId.endsWith(Constants.SCHEMA_SOURCE)) {
return;
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Wed Sep 28 17:36:24 2011 +0100
@@ -73,7 +73,7 @@
* @author Neil Graham, IBM
* @author Michael Glavassevich, IBM
*
- * @version $Id: XML11Configuration.java,v 1.7 2010/07/23 02:09:28 joehw Exp $
+ * @version $Id: XML11Configuration.java,v 1.9 2010-11-01 04:40:10 joehw Exp $
*/
public class XML11Configuration extends ParserConfigurationSettings
implements XMLPullParserConfiguration, XML11Configurable {
@@ -149,7 +149,15 @@
/** Feature identifier: honour all schemaLocations */
protected static final String HONOUR_ALL_SCHEMALOCATIONS =
Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
-
+
+ /** Feature identifier: namespace growth */
+ protected static final String NAMESPACE_GROWTH =
+ Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
+
+ /** Feature identifier: tolerate duplicates */
+ protected static final String TOLERATE_DUPLICATES =
+ Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
+
/** Feature identifier: use grammar pool only */
protected static final String USE_GRAMMAR_POOL_ONLY =
Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
@@ -259,6 +267,10 @@
protected static final String LOCALE =
Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+ /** Property identifier: Schema DV Factory */
+ protected static final String SCHEMA_DV_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
+
// debugging
/** Set to true and recompile to print exception stack trace. */
@@ -454,7 +466,9 @@
NAMESPACES,
NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
- HONOUR_ALL_SCHEMALOCATIONS, USE_GRAMMAR_POOL_ONLY,
+ HONOUR_ALL_SCHEMALOCATIONS, NAMESPACE_GROWTH,
+ TOLERATE_DUPLICATES,
+ USE_GRAMMAR_POOL_ONLY,
// NOTE: These shouldn't really be here but since the XML Schema
// validator is constructed dynamically, its recognized
// features might not have been set and it would cause a
@@ -478,6 +492,8 @@
fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
+ fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE);
+ fFeatures.put(TOLERATE_DUPLICATES, Boolean.FALSE);
fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
@@ -507,6 +523,7 @@
SCHEMA_LOCATION,
SCHEMA_NONS_LOCATION,
LOCALE,
+ SCHEMA_DV_FACTORY,
};
addRecognizedProperties(recognizedProperties);
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java Wed Sep 28 17:36:24 2011 +0100
@@ -25,13 +25,13 @@
import com.sun.org.apache.xerces.internal.dom.AttrImpl;
import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl;
-
import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
-import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.ls.LSException;
/**
* Some useful utility methods.
@@ -42,6 +42,7 @@
* (such as a DTM), we should easily be able to convert our schema
* parsing to utilize it.
*
+ * @version $Id: DOMUtil.java,v 1.7 2010-11-01 04:40:14 joehw Exp $
*/
public class DOMUtil {
@@ -121,7 +122,7 @@
default: {
throw new IllegalArgumentException("can't copy node type, "+
type+" ("+
- node.getNodeName()+')');
+ place.getNodeName()+')');
}
}
dest.appendChild(node);
@@ -319,12 +320,12 @@
// set this Node as being hidden, overloaded method
public static void setHidden(Node node, Hashtable hiddenNodes) {
- if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)
+ if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(true, false);
- else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl)
- ((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).setReadOnly(true, false);
- else
- hiddenNodes.put(node, "");
+ }
+ else {
+ hiddenNodes.put(node, "");
+ }
} // setHidden(node):void
// set this Node as being visible
@@ -337,12 +338,12 @@
// set this Node as being visible, overloaded method
public static void setVisible(Node node, Hashtable hiddenNodes) {
- if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)
+ if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(false, false);
- else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl)
- ((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).setReadOnly(false, false);
- else
- hiddenNodes.remove(node);
+ }
+ else {
+ hiddenNodes.remove(node);
+ }
} // setVisible(node):void
// is this node hidden?
@@ -356,12 +357,12 @@
// is this node hidden? overloaded method
public static boolean isHidden(Node node, Hashtable hiddenNodes) {
- if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)
+ if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) {
return ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).getReadOnly();
- else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl)
- return ((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).getReadOnly();
- else
- return hiddenNodes.containsKey(node);
+ }
+ else {
+ return hiddenNodes.containsKey(node);
+ }
} // isHidden(Node):boolean
/** Finds and returns the first child node with the given name. */
@@ -824,11 +825,78 @@
return node.getNamespaceURI();
}
- //return synthetic annotation
+ // return annotation
+ public static String getAnnotation(Node node) {
+ if (node instanceof ElementImpl) {
+ return ((ElementImpl)node).getAnnotation();
+ }
+ return null;
+ }
+
+ // return synthetic annotation
public static String getSyntheticAnnotation(Node node) {
- if(node instanceof ElementImpl) {
+ if (node instanceof ElementImpl) {
return ((ElementImpl)node).getSyntheticAnnotation();
}
return null;
}
-} // class XUtil
+
+ /**
+ * Creates a DOMException. On J2SE 1.4 and above the cause for the exception will be set.
+ */
+ public static DOMException createDOMException(short code, Throwable cause) {
+ DOMException de = new DOMException(code, cause != null ? cause.getMessage() : null);
+ if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
+ try {
+ ThrowableMethods.fgThrowableInitCauseMethod.invoke(de, new Object [] {cause});
+ }
+ // Something went wrong. There's not much we can do about it.
+ catch (Exception e) {}
+ }
+ return de;
+ }
+
+ /**
+ * Creates an LSException. On J2SE 1.4 and above the cause for the exception will be set.
+ */
+ public static LSException createLSException(short code, Throwable cause) {
+ LSException lse = new LSException(code, cause != null ? cause.getMessage() : null);
+ if (cause != null && ThrowableMethods.fgThrowableMethodsAvailable) {
+ try {
+ ThrowableMethods.fgThrowableInitCauseMethod.invoke(lse, new Object [] {cause});
+ }
+ // Something went wrong. There's not much we can do about it.
+ catch (Exception e) {}
+ }
+ return lse;
+ }
+
+ /**
+ * Holder of methods from java.lang.Throwable.
+ */
+ static class ThrowableMethods {
+
+ // Method: java.lang.Throwable.initCause(java.lang.Throwable)
+ private static java.lang.reflect.Method fgThrowableInitCauseMethod = null;
+
+ // Flag indicating whether or not Throwable methods available.
+ private static boolean fgThrowableMethodsAvailable = false;
+
+ private ThrowableMethods() {}
+
+ // Attempt to get methods for java.lang.Throwable on class initialization.
+ static {
+ try {
+ fgThrowableInitCauseMethod = Throwable.class.getMethod("initCause", new Class [] {Throwable.class});
+ fgThrowableMethodsAvailable = true;
+ }
+ // ClassNotFoundException, NoSuchMethodException or SecurityException
+ // Whatever the case, we cannot use java.lang.Throwable.initCause(java.lang.Throwable).
+ catch (Exception exc) {
+ fgThrowableInitCauseMethod = null;
+ fgThrowableMethodsAvailable = false;
+ }
+ }
+ }
+
+} // class DOMUtil
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,150 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.util;
+
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import javax.xml.XMLConstants;
+
+import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+
+/**
+ * A read-only XNI wrapper around a JAXP NamespaceContext.
+ *
+ * @author Michael Glavassevich, IBM
+ *
+ * @version $Id: JAXPNamespaceContextWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $
+ */
+public final class JAXPNamespaceContextWrapper implements NamespaceContext {
+
+ private javax.xml.namespace.NamespaceContext fNamespaceContext;
+ private SymbolTable fSymbolTable;
+ private List fPrefixes;
+ private final Vector fAllPrefixes = new Vector();
+
+ private int[] fContext = new int[8];
+ private int fCurrentContext;
+
+ public JAXPNamespaceContextWrapper(SymbolTable symbolTable) {
+ setSymbolTable(symbolTable);
+ }
+
+ public void setNamespaceContext(javax.xml.namespace.NamespaceContext context) {
+ fNamespaceContext = context;
+ }
+
+ public javax.xml.namespace.NamespaceContext getNamespaceContext() {
+ return fNamespaceContext;
+ }
+
+ public void setSymbolTable(SymbolTable symbolTable) {
+ fSymbolTable = symbolTable;
+ }
+
+ public SymbolTable getSymbolTable() {
+ return fSymbolTable;
+ }
+
+ public void setDeclaredPrefixes(List prefixes) {
+ fPrefixes = prefixes;
+ }
+
+ public List getDeclaredPrefixes() {
+ return fPrefixes;
+ }
+
+ /*
+ * NamespaceContext methods
+ */
+
+ public String getURI(String prefix) {
+ if (fNamespaceContext != null) {
+ String uri = fNamespaceContext.getNamespaceURI(prefix);
+ if (uri != null && !XMLConstants.NULL_NS_URI.equals(uri)) {
+ return (fSymbolTable != null) ? fSymbolTable.addSymbol(uri) : uri.intern();
+ }
+ }
+ return null;
+ }
+
+ public String getPrefix(String uri) {
+ if (fNamespaceContext != null) {
+ if (uri == null) {
+ uri = XMLConstants.NULL_NS_URI;
+ }
+ String prefix = fNamespaceContext.getPrefix(uri);
+ if (prefix == null) {
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+ }
+ return (fSymbolTable != null) ? fSymbolTable.addSymbol(prefix) : prefix.intern();
+ }
+ return null;
+ }
+
+ public Enumeration getAllPrefixes() {
+ // There may be duplicate prefixes in the list so we
+ // first transfer them to a set to ensure uniqueness.
+ return Collections.enumeration(new TreeSet(fAllPrefixes));
+ }
+
+ public void pushContext() {
+ // extend the array, if necessary
+ if (fCurrentContext + 1 == fContext.length) {
+ int[] contextarray = new int[fContext.length * 2];
+ System.arraycopy(fContext, 0, contextarray, 0, fContext.length);
+ fContext = contextarray;
+ }
+ // push context
+ fContext[++fCurrentContext] = fAllPrefixes.size();
+ if (fPrefixes != null) {
+ fAllPrefixes.addAll(fPrefixes);
+ }
+ }
+
+ public void popContext() {
+ fAllPrefixes.setSize(fContext[fCurrentContext--]);
+ }
+
+ public boolean declarePrefix(String prefix, String uri) {
+ return true;
+ }
+
+ public int getDeclaredPrefixCount() {
+ return (fPrefixes != null) ? fPrefixes.size() : 0;
+ }
+
+ public String getDeclaredPrefixAt(int index) {
+ return (String) fPrefixes.get(index);
+ }
+
+ public void reset() {
+ fCurrentContext = 0;
+ fContext[fCurrentContext] = 0;
+ fAllPrefixes.clear();
+ }
+
+} // JAXPNamespaceContextWrapper
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,95 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.util;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+
+/**
+ * An XMLInputSource
analogue to javax.xml.transform.stax.StAXSource
.
+ *
+ * @version $Id: StAXInputSource.java,v 1.2 2010-10-26 23:01:17 joehw Exp $
+ */
+public final class StAXInputSource extends XMLInputSource {
+
+ private final XMLStreamReader fStreamReader;
+ private final XMLEventReader fEventReader;
+ private final boolean fConsumeRemainingContent;
+
+ public StAXInputSource(XMLStreamReader source) {
+ this(source, false);
+ }
+
+ public StAXInputSource(XMLStreamReader source, boolean consumeRemainingContent) {
+ super(null, source.getLocation().getSystemId(), null);
+ if (source == null) {
+ throw new IllegalArgumentException("XMLStreamReader parameter cannot be null.");
+ }
+ fStreamReader = source;
+ fEventReader = null;
+ fConsumeRemainingContent = consumeRemainingContent;
+ }
+
+ public StAXInputSource(XMLEventReader source) {
+ this(source, false);
+ }
+
+ public StAXInputSource(XMLEventReader source, boolean consumeRemainingContent) {
+ super(null, getEventReaderSystemId(source), null);
+ if (source == null) {
+ throw new IllegalArgumentException("XMLEventReader parameter cannot be null.");
+ }
+ fStreamReader = null;
+ fEventReader = source;
+ fConsumeRemainingContent = consumeRemainingContent;
+ }
+
+ public XMLStreamReader getXMLStreamReader() {
+ return fStreamReader;
+ }
+
+ public XMLEventReader getXMLEventReader() {
+ return fEventReader;
+ }
+
+ public boolean shouldConsumeRemainingContent() {
+ return fConsumeRemainingContent;
+ }
+
+ public void setSystemId(String systemId){
+ throw new UnsupportedOperationException("Cannot set the system ID on a StAXInputSource");
+ }
+
+ private static String getEventReaderSystemId(XMLEventReader reader) {
+ try {
+ if (reader != null) {
+ return reader.peek().getLocation().getSystemId();
+ }
+ }
+ catch (XMLStreamException e) {}
+ return null;
+ }
+
+} // StAXInputSource
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java Wed Sep 28 17:36:24 2011 +0100
@@ -0,0 +1,106 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.util;
+
+
+import javax.xml.stream.Location;
+
+import com.sun.org.apache.xerces.internal.xni.XMLLocator;
+
+/**
+ * A light wrapper around a StAX location. This is useful
+ * when bridging between StAX and XNI components.
+ *
+ * @author Michael Glavassevich, IBM
+ *
+ * @version $Id: StAXLocationWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $
+ */
+public final class StAXLocationWrapper implements XMLLocator {
+
+ private Location fLocation = null;
+
+ public StAXLocationWrapper() {}
+
+ public void setLocation(Location location) {
+ fLocation = location;
+ }
+
+ public Location getLocation() {
+ return fLocation;
+ }
+
+ /*
+ * XMLLocator methods
+ */
+
+ public String getPublicId() {
+ if (fLocation != null) {
+ return fLocation.getPublicId();
+ }
+ return null;
+ }
+
+ public String getLiteralSystemId() {
+ if (fLocation != null) {
+ return fLocation.getSystemId();
+ }
+ return null;
+ }
+
+ public String getBaseSystemId() {
+ return null;
+ }
+
+ public String getExpandedSystemId() {
+ return getLiteralSystemId();
+ }
+
+ public int getLineNumber() {
+ if (fLocation != null) {
+ return fLocation.getLineNumber();
+ }
+ return -1;
+ }
+
+ public int getColumnNumber() {
+ if (fLocation != null) {
+ return fLocation.getColumnNumber();
+ }
+ return -1;
+ }
+
+ public int getCharacterOffset() {
+ if (fLocation != null) {
+ return fLocation.getCharacterOffset();
+ }
+ return -1;
+ }
+
+ public String getEncoding() {
+ return null;
+ }
+
+ public String getXMLVersion() {
+ return null;
+ }
+
+} // StAXLocationWrapper
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java Wed Sep 28 17:36:24 2011 +0100
@@ -26,8 +26,9 @@
* to Object mapping.
*
* The hash code uses the same algorithm as SymbolTable class.
- *
+ *
* @author Elena Litani
+ * @version $Id: SymbolHash.java,v 1.7 2010-11-01 04:40:14 joehw Exp $
*/
public class SymbolHash {
@@ -137,6 +138,21 @@
}
/**
+ * Return key/value pairs of all entries in the map
+ */
+ public Object[] getEntries() {
+ Object[] entries = new Object[fNum << 1];
+ for (int i=0, j=0; i 1 && isXML11NameHighSurrogate(ch) ) {
+ if (!isXML11NameStart(ch)) {
+ if (length > 1 && isXML11NameHighSurrogate(ch)) {
char ch2 = name.charAt(1);
- if ( !XMLChar.isLowSurrogate(ch2) ||
- !isXML11NameStart(XMLChar.supplemental(ch, ch2)) ) {
+ if (!XMLChar.isLowSurrogate(ch2) ||
+ !isXML11NameStart(XMLChar.supplemental(ch, ch2))) {
return false;
}
i = 2;
@@ -310,11 +312,11 @@
}
while (i < length) {
ch = name.charAt(i);
- if ( !isXML11Name(ch) ) {
- if ( ++i < length && isXML11NameHighSurrogate(ch) ) {
+ if (!isXML11Name(ch)) {
+ if (++i < length && isXML11NameHighSurrogate(ch)) {
char ch2 = name.charAt(i);
- if ( !XMLChar.isLowSurrogate(ch2) ||
- !isXML11Name(XMLChar.supplemental(ch, ch2)) ) {
+ if (!XMLChar.isLowSurrogate(ch2) ||
+ !isXML11Name(XMLChar.supplemental(ch, ch2))) {
return false;
}
}
@@ -327,7 +329,6 @@
return true;
} // isXML11ValidName(String):boolean
-
/*
* from the namespace 1.1 rec
* [4] NCName ::= NCNameStartChar NCNameChar*
@@ -340,16 +341,17 @@
* @return true if name is a valid NCName
*/
public static boolean isXML11ValidNCName(String ncName) {
- int length = ncName.length();
- if (length == 0)
+ final int length = ncName.length();
+ if (length == 0) {
return false;
+ }
int i = 1;
char ch = ncName.charAt(0);
- if( !isXML11NCNameStart(ch) ) {
- if ( length > 1 && isXML11NameHighSurrogate(ch) ) {
+ if (!isXML11NCNameStart(ch)) {
+ if (length > 1 && isXML11NameHighSurrogate(ch)) {
char ch2 = ncName.charAt(1);
- if ( !XMLChar.isLowSurrogate(ch2) ||
- !isXML11NCNameStart(XMLChar.supplemental(ch, ch2)) ) {
+ if (!XMLChar.isLowSurrogate(ch2) ||
+ !isXML11NCNameStart(XMLChar.supplemental(ch, ch2))) {
return false;
}
i = 2;
@@ -360,11 +362,11 @@
}
while (i < length) {
ch = ncName.charAt(i);
- if ( !isXML11NCName(ch) ) {
- if ( ++i < length && isXML11NameHighSurrogate(ch) ) {
+ if (!isXML11NCName(ch)) {
+ if (++i < length && isXML11NameHighSurrogate(ch)) {
char ch2 = ncName.charAt(i);
- if ( !XMLChar.isLowSurrogate(ch2) ||
- !isXML11NCName(XMLChar.supplemental(ch, ch2)) ) {
+ if (!XMLChar.isLowSurrogate(ch2) ||
+ !isXML11NCName(XMLChar.supplemental(ch, ch2))) {
return false;
}
}
@@ -388,16 +390,17 @@
* @return true if nmtoken is a valid Nmtoken
*/
public static boolean isXML11ValidNmtoken(String nmtoken) {
- int length = nmtoken.length();
- if (length == 0)
+ final int length = nmtoken.length();
+ if (length == 0) {
return false;
- for (int i = 0; i < length; ++i ) {
+ }
+ for (int i = 0; i < length; ++i) {
char ch = nmtoken.charAt(i);
- if( !isXML11Name(ch) ) {
- if ( ++i < length && isXML11NameHighSurrogate(ch) ) {
+ if (!isXML11Name(ch)) {
+ if (++i < length && isXML11NameHighSurrogate(ch)) {
char ch2 = nmtoken.charAt(i);
- if ( !XMLChar.isLowSurrogate(ch2) ||
- !isXML11Name(XMLChar.supplemental(ch, ch2)) ) {
+ if (!XMLChar.isLowSurrogate(ch2) ||
+ !isXML11Name(XMLChar.supplemental(ch, ch2))) {
return false;
}
}
@@ -410,3 +413,4 @@
} // isXML11ValidName(String):boolean
} // class XML11Char
+
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/XMLChar.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/XMLChar.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/XMLChar.java Wed Sep 28 17:36:24 2011 +0100
@@ -44,6 +44,7 @@
* @author Michael Glavassevich, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
+ * @version $Id: XMLChar.java,v 1.7 2010-11-01 04:40:15 joehw Exp $
*/
public class XMLChar {
@@ -897,21 +898,23 @@
* @return true if name is a valid Name
*/
public static boolean isValidName(String name) {
- if (name.length() == 0)
+ final int length = name.length();
+ if (length == 0) {
return false;
+ }
char ch = name.charAt(0);
- if( isNameStart(ch) == false)
- return false;
- for (int i = 1; i < name.length(); i++ ) {
- ch = name.charAt(i);
- if( isName( ch ) == false ){
- return false;
- }
+ if (!isNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < length; ++i) {
+ ch = name.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
}
return true;
} // isValidName(String):boolean
-
/*
* from the namespace rec
* [4] NCName ::= (Letter | '_') (NCNameChar)*
@@ -924,16 +927,19 @@
* @return true if name is a valid NCName
*/
public static boolean isValidNCName(String ncName) {
- if (ncName.length() == 0)
+ final int length = ncName.length();
+ if (length == 0) {
return false;
+ }
char ch = ncName.charAt(0);
- if( isNCNameStart(ch) == false)
- return false;
- for (int i = 1; i < ncName.length(); i++ ) {
- ch = ncName.charAt(i);
- if( isNCName( ch ) == false ){
- return false;
- }
+ if (!isNCNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < length; ++i) {
+ ch = ncName.charAt(i);
+ if (!isNCName(ch)) {
+ return false;
+ }
}
return true;
} // isValidNCName(String):boolean
@@ -949,13 +955,15 @@
* @return true if nmtoken is a valid Nmtoken
*/
public static boolean isValidNmtoken(String nmtoken) {
- if (nmtoken.length() == 0)
+ final int length = nmtoken.length();
+ if (length == 0) {
return false;
- for (int i = 0; i < nmtoken.length(); i++ ) {
- char ch = nmtoken.charAt(i);
- if( ! isName( ch ) ){
- return false;
- }
+ }
+ for (int i = 0; i < length; ++i) {
+ char ch = nmtoken.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
}
return true;
} // isValidName(String):boolean
@@ -1021,5 +1029,37 @@
return false;
} // isValidIANAEncoding(String):boolean
+ // other methods
+
+ /**
+ * Trims space characters as defined by production [3] in
+ * the XML 1.0 specification from both ends of the given string.
+ *
+ * @param value the string to be trimmed
+ * @return the given string with the space characters trimmed
+ * from both ends
+ */
+ public static String trim(String value) {
+ int start;
+ int end;
+ final int lengthMinusOne = value.length() - 1;
+ for (start = 0; start <= lengthMinusOne; ++start) {
+ if (!isSpace(value.charAt(start))) {
+ break;
+ }
+ }
+ for (end = lengthMinusOne; end >= start; --end) {
+ if (!isSpace(value.charAt(end))) {
+ break;
+ }
+ }
+ if (start == 0 && end == lengthMinusOne) {
+ return value;
+ }
+ if (start > lengthMinusOne) {
+ return "";
+ }
+ return value.substring(start, end + 1);
+ } // trim(String):String
} // class XMLChar
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/LSInputList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/LSInputList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/LSInputList.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,8 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.List;
+
import org.w3c.dom.ls.LSInput;
/**
@@ -27,7 +29,7 @@
* ordered collection of LSInput
s, without defining or
* constraining how this collection is implemented.
*/
-public interface LSInputList {
+public interface LSInputList extends List {
/**
* The number of LSInput
s in the list. The range of valid
* child object indices is 0 to length-1
inclusive.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/ShortList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/ShortList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/ShortList.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,11 +20,13 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.List;
+
/**
* The ShortList
is an immutable ordered collection of
* unsigned short
.
*/
-public interface ShortList {
+public interface ShortList extends List {
/**
* The number of unsigned short
s in the list. The range of
* valid child object indices is 0 to length-1
inclusive.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/StringList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/StringList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/StringList.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,11 +20,13 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.List;
+
/**
* The StringList
is an immutable ordered collection of
* GenericString
.
*/
-public interface StringList {
+public interface StringList extends List {
/**
* The number of GenericString
s in the list. The range of
* valid child object indices is 0 to length-1
inclusive.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeDeclaration.java Wed Sep 28 17:36:24 2011 +0100
@@ -100,7 +100,12 @@
/**
* An annotation if it exists, otherwise null
.
+ * If not null then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeGroupDefinition.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeGroupDefinition.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeGroupDefinition.java Wed Sep 28 17:36:24 2011 +0100
@@ -36,8 +36,13 @@
public XSWildcard getAttributeWildcard();
/**
- * An [annotation] if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSAttributeUse.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,7 +21,7 @@
package com.sun.org.apache.xerces.internal.xs;
/**
- * This interface represents the Attribute Use schema component.
+ * This interface represents the Attribute Use schema component.
*/
public interface XSAttributeUse extends XSObject {
/**
@@ -92,4 +92,8 @@
public ShortList getItemValueTypes()
throws XSException;
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSComplexTypeDefinition.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSComplexTypeDefinition.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSComplexTypeDefinition.java Wed Sep 28 17:36:24 2011 +0100
@@ -109,8 +109,7 @@
public short getProhibitedSubstitutions();
/**
- * A set of [annotations] if it exists, otherwise an empty
- * XSObjectList
.
+ * A sequence of [annotations] or an empty XSObjectList
.
*/
public XSObjectList getAnnotations();
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSElementDeclaration.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,7 +21,7 @@
package com.sun.org.apache.xerces.internal.xs;
/**
- * The interface represents the Element Declaration schema component.
+ * The interface represents the Element Declaration schema component.
*/
public interface XSElementDeclaration extends XSTerm {
/**
@@ -168,8 +168,13 @@
public boolean getAbstract();
/**
- * An annotation if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSFacet.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSFacet.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSFacet.java Wed Sep 28 17:36:24 2011 +0100
@@ -42,8 +42,13 @@
public boolean getFixed();
/**
- * An annotation if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSIDCDefinition.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSIDCDefinition.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSIDCDefinition.java Wed Sep 28 17:36:24 2011 +0100
@@ -65,8 +65,7 @@
public XSIDCDefinition getRefKey();
/**
- * A set of [annotations] if it exists, otherwise an empty
- * XSObjectList
.
+ * A sequence of [annotations] or an empty XSObjectList
.
*/
public XSObjectList getAnnotations();
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSLoader.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSLoader.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSLoader.java Wed Sep 28 17:36:24 2011 +0100
@@ -24,7 +24,7 @@
import org.w3c.dom.ls.LSInput;
/**
- * An interface that provides a method to load XML Schema documents. This
+ * An interface that provides a method to load XML Schema documents. This
* interface uses the DOM Level 3 Core and Load and Save interfaces.
*/
public interface XSLoader {
@@ -58,7 +58,7 @@
* Parses the content of XML Schema documents specified as the list of URI
* references. If the URI contains a fragment identifier, the behavior
* is not defined by this specification.
- * @param uri The list of URI locations.
+ * @param uriList The list of URI locations.
* @return An XSModel representing the schema documents.
*/
public XSModel loadURIList(StringList uriList);
@@ -84,7 +84,7 @@
/**
* Parse an XML Schema document from a resource identified by a
* LSInput
.
- * @param is The DOMInputSource
from which the source
+ * @param is The LSInput
from which the source
* document is to be read.
* @return An XSModel representing this schema.
*/
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModel.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModel.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModel.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,7 +21,7 @@
package com.sun.org.apache.xerces.internal.xs;
/**
- * This interface represents an XML Schema.
+ * This interface represents an XML Schema.
*/
public interface XSModel {
/**
@@ -145,4 +145,17 @@
public XSNotationDeclaration getNotationDeclaration(String name,
String namespace);
+ /**
+ * Convenience method. Returns a list containing the members of the
+ * substitution group for the given XSElementDeclaration
+ * or an empty XSObjectList
if the substitution group
+ * contains no members.
+ * @param head The substitution group head.
+ * @return A list containing the members of the substitution group
+ * for the given XSElementDeclaration
or an empty
+ * XSObjectList
if the substitution group contains
+ * no members.
+ */
+ public XSObjectList getSubstitutionGroup(XSElementDeclaration head);
+
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroup.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroup.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroup.java Wed Sep 28 17:36:24 2011 +0100
@@ -54,8 +54,13 @@
public XSObjectList getParticles();
/**
- * An [annotation] if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroupDefinition.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroupDefinition.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSModelGroupDefinition.java Wed Sep 28 17:36:24 2011 +0100
@@ -30,8 +30,13 @@
public XSModelGroup getModelGroup();
/**
- * An [annotation] if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSMultiValueFacet.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSMultiValueFacet.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSMultiValueFacet.java Wed Sep 28 17:36:24 2011 +0100
@@ -36,8 +36,7 @@
public StringList getLexicalFacetValues();
/**
- * A set of [annotations] if it exists, otherwise an empty
- * XSObjectList
.
+ * A sequence of [annotations] or an empty XSObjectList
.
*/
public XSObjectList getAnnotations();
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamedMap.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamedMap.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamedMap.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,6 +20,8 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.Map;
+
/**
* Objects implementing the XSNamedMap
interface are used to
* represent immutable collections of XML Schema components that can be
@@ -27,7 +29,7 @@
* XSObjectList
. The XSObject
s in
* XSNamedMap
s are not maintained in any particular order.
*/
-public interface XSNamedMap {
+public interface XSNamedMap extends Map {
/**
* The number of XSObjects
in the XSObjectList
.
* The range of valid child object indices is 0 to length-1
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamespaceItemList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamespaceItemList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNamespaceItemList.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,12 +20,14 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.List;
+
/**
* The XSNamesaceItemList
interface provides the abstraction of
* an immutable ordered collection of XSNamespaceItem
s, without
* defining or constraining how this collection is implemented.
*/
-public interface XSNamespaceItemList {
+public interface XSNamespaceItemList extends List {
/**
* The number of XSNamespaceItem
s in the list. The range of
* valid child object indices is 0 to length-1
inclusive.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNotationDeclaration.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNotationDeclaration.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSNotationDeclaration.java Wed Sep 28 17:36:24 2011 +0100
@@ -21,7 +21,7 @@
package com.sun.org.apache.xerces.internal.xs;
/**
- * This interface represents the Notation Declaration schema component.
+ * This interface represents the Notation Declaration schema component.
*/
public interface XSNotationDeclaration extends XSObject {
/**
@@ -37,8 +37,13 @@
public String getPublicId();
/**
- * An [annotation] if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSObjectList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSObjectList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSObjectList.java Wed Sep 28 17:36:24 2011 +0100
@@ -20,12 +20,14 @@
package com.sun.org.apache.xerces.internal.xs;
+import java.util.List;
+
/**
* The XSObjectList
interface provides the abstraction of an
* immutable ordered collection of XSObject
s, without defining
* or constraining how this collection is implemented.
*/
-public interface XSObjectList {
+public interface XSObjectList extends List {
/**
* The number of XSObjects
in the list. The range of valid
* child object indices is 0 to length-1
inclusive.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSParticle.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSParticle.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSParticle.java Wed Sep 28 17:36:24 2011 +0100
@@ -48,4 +48,8 @@
*/
public XSTerm getTerm();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSSimpleTypeDefinition.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSSimpleTypeDefinition.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSSimpleTypeDefinition.java Wed Sep 28 17:36:24 2011 +0100
@@ -235,8 +235,7 @@
public XSObjectList getMultiValueFacets();
/**
- * [annotations]: a set of annotations for this simple type component if
- * it exists, otherwise an empty XSObjectList
.
+ * A sequence of [annotations] or an empty XSObjectList
.
*/
public XSObjectList getAnnotations();
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSWildcard.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSWildcard.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/XSWildcard.java Wed Sep 28 17:36:24 2011 +0100
@@ -78,8 +78,13 @@
public short getProcessContents();
/**
- * An [annotation] if it exists, otherwise null
.
+ * An annotation if it exists, otherwise null
. If not null
+ * then the first [annotation] from the sequence of annotations.
*/
public XSAnnotation getAnnotation();
+ /**
+ * A sequence of [annotations] or an empty XSObjectList
.
+ */
+ public XSObjectList getAnnotations();
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java Wed Sep 28 17:36:24 2011 +0100
@@ -19,16 +19,19 @@
*/
package com.sun.org.apache.xerces.internal.xs.datatypes;
+import java.util.List;
+
import com.sun.org.apache.xerces.internal.xs.XSException;
/**
- * The ByteList
is an immutable ordered collection of
+ *
The ByteList
is an immutable ordered collection of
* byte
.
- *
+ *
* @author Ankit Pasricha, IBM
- *
+ *
+ * @version $Id: ByteList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $
*/
-public interface ByteList {
+public interface ByteList extends List {
/**
* The number of byte
s in the list. The range of
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java Wed Sep 28 17:36:24 2011 +0100
@@ -19,14 +19,17 @@
*/
package com.sun.org.apache.xerces.internal.xs.datatypes;
+import java.util.List;
+
/**
- * The ObjectList
is an immutable ordered collection of
- * Object
.
- *
+ * The ObjectList
is an immutable ordered collection of
+ * Object
.
+ *
* @author Ankit Pasricha, IBM
- *
+ *
+ * @version $Id: ObjectList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $
*/
-public interface ObjectList {
+public interface ObjectList extends List {
/**
* The number of Object
s in the list. The range of
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java
--- a/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java Wed Sep 28 17:36:24 2011 +0100
@@ -45,6 +45,7 @@
import org.w3c.dom.DOMStringList;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
+import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XML11Char;
@@ -76,7 +77,7 @@
* @author Gopal Sharma, Sun Microsystems
* @author Arun Yadav, Sun Microsystems
* @author Sunitha Reddy, Sun Microsystems
- * @version $Id: DOMSerializerImpl.java,v 1.8 2009/09/03 18:56:50 joehw Exp $
+ * @version $Id: DOMSerializerImpl.java,v 1.11 2010-11-01 04:40:36 joehw Exp $
*/
public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
@@ -840,7 +841,7 @@
// stopped at user request
return false;
}
- throw new LSException(LSException.SERIALIZE_ERR, e.toString());
+ throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
} catch (Exception e) {
if (ser.fDOMErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
@@ -851,7 +852,7 @@
}
e.printStackTrace();
- throw new LSException(LSException.SERIALIZE_ERR, e.toString());
+ throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
}
return true;
@@ -997,7 +998,7 @@
// stopped at user request
return false;
}
- throw new LSException(LSException.SERIALIZE_ERR, e.toString());
+ throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
} catch (Exception e) {
if (ser.fDOMErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
@@ -1006,7 +1007,7 @@
error.fSeverity = DOMError.SEVERITY_ERROR;
ser.fDOMErrorHandler.handleError(error);
}
- throw new LSException(LSException.SERIALIZE_ERR, e.toString());
+ throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
}
return true;
} //writeURI
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/xml/internal/stream/EventFilterSupport.java
--- a/sources/jaxp_src/src/com/sun/xml/internal/stream/EventFilterSupport.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/xml/internal/stream/EventFilterSupport.java Wed Sep 28 17:36:24 2011 +0100
@@ -38,7 +38,7 @@
*
*/
public class EventFilterSupport extends EventReaderDelegate {
-
+
//maintain a reference to EventFilter
EventFilter fEventFilter ;
/** Creates a new instance of EventFilterSupport */
@@ -46,7 +46,7 @@
setParent(eventReader);
fEventFilter = eventFilter;
}
-
+
public Object next(){
try{
return nextEvent();
@@ -54,7 +54,7 @@
throw new NoSuchElementException();
}
}
-
+
public boolean hasNext(){
try{
return peek() != null ? true : false ;
@@ -62,12 +62,12 @@
return false;
}
}
-
+
public XMLEvent nextEvent()throws XMLStreamException{
if(super.hasNext()){
//get the next event by calling XMLEventReader
XMLEvent event = super.nextEvent();
-
+
//if this filter accepts this event then return this event
if(fEventFilter.accept(event)){
return event;
@@ -79,7 +79,7 @@
throw new NoSuchElementException();
}
}//nextEvent()
-
+
public XMLEvent nextTag() throws XMLStreamException{
if(super.hasNext()){
XMLEvent event = super.nextTag();
@@ -89,26 +89,23 @@
}
else{
return nextTag();
- }
+ }
}else{
throw new NoSuchElementException();
+ }
+ }
+
+ public XMLEvent peek() throws XMLStreamException{
+ while (true) {
+ XMLEvent event = super.peek();
+ if(event == null)return null;
+ //if the filter accepts this event return this event.
+ if(fEventFilter.accept(event)){
+ return event;
+ }
+ //call super.next(), and then peek again.
+ super.next();
}
}
-
- public XMLEvent peek() throws XMLStreamException{
-
- XMLEvent event = super.peek();
- if(event == null)return null;
- //if the filter accepts this event return this event.
- if(fEventFilter.accept(event)){
- return event;
- }
- else{
- //call super.next(), and then peek again.
- super.next();
- return peek();
- }
-
- }
-
+
}//EventFilterSupport
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/com/sun/xml/internal/stream/StaxErrorReporter.java
--- a/sources/jaxp_src/src/com/sun/xml/internal/stream/StaxErrorReporter.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/xml/internal/stream/StaxErrorReporter.java Wed Sep 28 17:36:24 2011 +0100
@@ -45,16 +45,16 @@
*/
public class StaxErrorReporter extends XMLErrorReporter {
-
+
protected XMLReporter fXMLReporter = null ;
-
+
/** Creates a new instance of StaxErrorReporter */
public StaxErrorReporter(PropertyManager propertyManager) {
super();
putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, new XMLMessageFormatter());
reset(propertyManager);
}
-
+
/** Creates a new instance of StaxErrorReporter
* If this constructor is used to create the object, one must invoke reset() on this object.
*/
@@ -62,7 +62,7 @@
super();
putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, new XMLMessageFormatter());
}
-
+
/**
*One must call reset before using any of the function.
*/
@@ -83,7 +83,7 @@
* @see #SEVERITY_ERROR
* @see #SEVERITY_FATAL_ERROR
*/
- public void reportError(XMLLocator location,
+ public String reportError(XMLLocator location,
String domain, String key, Object[] arguments,
short severity) throws XNIException {
// format error message and create parse exception
@@ -109,16 +109,16 @@
}
message = str.toString();
}
-
-
-
+
+
+
//no reporter was specified
/**
* if (reporter == null) {
* reporter = new DefaultStaxErrorReporter();
* }
*/
-
+
// call error handler
switch (severity) {
case SEVERITY_WARNING: {
@@ -152,36 +152,36 @@
break;
}
}
-
+ return message;
}
-
-
+
+
Location convertToStaxLocation(final XMLLocator location){
return new Location(){
public int getColumnNumber(){
return location.getColumnNumber();
}
-
+
public int getLineNumber(){
return location.getLineNumber();
}
-
+
public String getPublicId(){
return location.getPublicId();
}
-
+
public String getSystemId(){
return location.getLiteralSystemId();
}
-
+
public int getCharacterOffset(){
return location.getCharacterOffset();
}
public String getLocationURI(){
return "";
}
-
+
};
}
-
+
}
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/javax/xml/parsers/FactoryConfigurationError.java
--- a/sources/jaxp_src/src/javax/xml/parsers/FactoryConfigurationError.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/javax/xml/parsers/FactoryConfigurationError.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,11 +32,12 @@
* or instantiated.
*
* @author Jeff Suttor
- * @version $Revision: 1.5 $, $Date: 2010/02/03 07:34:04 $
+ * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:09 $
*/
public class FactoryConfigurationError extends Error {
-
+ private static final long serialVersionUID = -827108682472263355L;
+
/**
*Exception
that represents the error.
*/
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/javax/xml/stream/FactoryConfigurationError.java
--- a/sources/jaxp_src/src/javax/xml/stream/FactoryConfigurationError.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/javax/xml/stream/FactoryConfigurationError.java Wed Sep 28 17:36:24 2011 +0100
@@ -36,6 +36,7 @@
* @since 1.6
*/
public class FactoryConfigurationError extends Error {
+ private static final long serialVersionUID = -2994412584589975744L;
Exception nested;
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/javax/xml/transform/TransformerFactoryConfigurationError.java
--- a/sources/jaxp_src/src/javax/xml/transform/TransformerFactoryConfigurationError.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/javax/xml/transform/TransformerFactoryConfigurationError.java Wed Sep 28 17:36:24 2011 +0100
@@ -32,7 +32,8 @@
* or instantiated.
*/
public class TransformerFactoryConfigurationError extends Error {
-
+ private static final long serialVersionUID = -6527718720676281516L;
+
/**
* Exception
for the
* TransformerFactoryConfigurationError
.
diff -r 44f4743bbd56 -r fa1d0a3d616f sources/jaxp_src/src/org/w3c/dom/DOMImplementationSource.java
--- a/sources/jaxp_src/src/org/w3c/dom/DOMImplementationSource.java Wed Sep 28 17:10:18 2011 +0100
+++ b/sources/jaxp_src/src/org/w3c/dom/DOMImplementationSource.java Wed Sep 28 17:36:24 2011 +0100
@@ -42,44 +42,45 @@
package org.w3c.dom;
/**
- * This interface permits a DOM implementer to supply one or more
- * implementations, based upon requested features and versions, as specified
- * in . Each implemented DOMImplementationSource
object is
- * listed in the binding-specific list of available sources so that its
+ * This interface permits a DOM implementer to supply one or more
+ * implementations, based upon requested features and versions, as specified
+ * in DOM
+ * Features. Each implemented DOMImplementationSource
object is
+ * listed in the binding-specific list of available sources so that its
* DOMImplementation
objects are made available.
* See also the Document Object Model (DOM) Level 3 Core Specification.
* @since DOM Level 3
*/
public interface DOMImplementationSource {
/**
- * A method to request the first DOM implementation that supports the
- * specified features.
- * @param features A string that specifies which features and versions
- * are required. This is a space separated list in which each feature
- * is specified by its name optionally followed by a space and a
- * version number. This method returns the first item of the list
- * returned by getDOMImplementationList
. As an example,
- * the string "XML 3.0 Traversal +Events 2.0"
will
- * request a DOM implementation that supports the module "XML" for its
- * 3.0 version, a module that support of the "Traversal" module for
- * any version, and the module "Events" for its 2.0 version. The
- * module "Events" must be accessible using the method
- * Node.getFeature()
and
- * DOMImplementation.getFeature()
.
- * @return The first DOM implementation that support the desired
+ * A method to request the first DOM implementation that supports the
+ * specified features.
+ * @param features A string that specifies which features and versions
+ * are required. This is a space separated list in which each feature
+ * is specified by its name optionally followed by a space and a
+ * version number. This method returns the first item of the list
+ * returned by getDOMImplementationList
. As an example,
+ * the string "XML 3.0 Traversal +Events 2.0"
will
+ * request a DOM implementation that supports the module "XML" for its
+ * 3.0 version, a module that support of the "Traversal" module for
+ * any version, and the module "Events" for its 2.0 version. The
+ * module "Events" must be accessible using the method
+ * Node.getFeature()
and
+ * DOMImplementation.getFeature()
.
+ * @return The first DOM implementation that support the desired
* features, or null
if this source has none.
*/
public DOMImplementation getDOMImplementation(String features);
/**
- * A method to request a list of DOM implementations that support the
+ * A method to request a list of DOM implementations that support the
* specified features and versions, as specified in .
- * @param features A string that specifies which features and versions
- * are required. This is a space separated list in which each feature
- * is specified by its name optionally followed by a space and a
- * version number. This is something like: "XML 3.0 Traversal +Events
+ * @param features A string that specifies which features and versions
+ * are required. This is a space separated list in which each feature
+ * is specified by its name optionally followed by a space and a
+ * version number. This is something like: "XML 3.0 Traversal +Events
* 2.0"
- * @return A list of DOM implementations that support the desired
+ * @return A list of DOM implementations that support the desired
* features.
*/
public DOMImplementationList getDOMImplementationList(String features);