You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2010/09/30 03:45:02 UTC
svn commit: r1002925 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti:
SchemaConditionalIncludeHelper.java SchemaDOMParser.java
SchemaVersioningHelper.java
Author: mukulg
Date: Thu Sep 30 01:45:01 2010
New Revision: 1002925
URL: http://svn.apache.org/viewvc?rev=1002925&view=rev
Log:
doing little refactoring of the code-base (specifically for schema 1.1 conditional inclusion functionality). improving few of javadocs as well.
Added:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java
- copied, changed from r999311, xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaVersioningHelper.java
Removed:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaVersioningHelper.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
Copied: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java (from r999311, xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaVersioningHelper.java)
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java?p2=xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java&p1=xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaVersioningHelper.java&r1=999311&r2=1002925&rev=1002925&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaVersioningHelper.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java Thu Sep 30 01:45:01 2010
@@ -26,9 +26,8 @@ import org.apache.xerces.impl.xs.SchemaS
import org.apache.xerces.xni.QName;
/**
- * This class provides supporting functionality for schema versioning
- * pre-processing, during conditional inclusion of schema components (newly
- * introduced in XML Schema 1.1).
+ * This class provides supporting functionality for XML Schema conditional
+ * include pre-processing (newly introduced in XML Schema 1.1).
*
*
* ref: http://www.w3.org/TR/xmlschema11-1/#cip
@@ -37,27 +36,36 @@ import org.apache.xerces.xni.QName;
*
* @version $Id$
*/
-public class SchemaVersioningHelper {
+public class SchemaConditionalIncludeHelper {
- // list variables holding 'natively supported' XML Schema types and facets
- // by Xerces-J XML Schema 1.1 engine.
+ // instance variables holding "natively supported" XML Schema types and
+ // facets by Xerces-J XML Schema 1.1 engine.
List typesSupported = null;
List facetsSupported = null;
- // class constructor
- public SchemaVersioningHelper() {
+
+ /*
+ * Class constructor.
+ */
+ public SchemaConditionalIncludeHelper() {
typesSupported = new ArrayList();
facetsSupported = new ArrayList();
initialize();
}
- // initializing the supported XML Schema types and facets
+
+ /*
+ * Initializing the supported XML Schema types and facets.
+ */
private void initialize() {
initSupportedTypes();
initSupportedFacets();
}
- // initializing the supported XML Schema types
+
+ /*
+ * Initializing the supported XML Schema types.
+ */
private void initSupportedTypes() {
typesSupported.add(new QName(null, SchemaSymbols.ATTVAL_ANYTYPE,
@@ -166,7 +174,9 @@ public class SchemaVersioningHelper {
} // initSupportedTypes
- // initializing the supported XML Schema facets
+ /*
+ * Initializing the supported XML Schema facets.
+ */
private void initSupportedFacets() {
facetsSupported.add(new QName(null, SchemaSymbols.ELT_LENGTH,
@@ -205,8 +215,9 @@ public class SchemaVersioningHelper {
} // initSupportedFacets
- // Method to check if the schema type specified by method arguments (the QName
- // components of the schema type) is supported by Xerces-J natively.
+ /* Method to check if a schema type specified by method arguments (the
+ * QName components of the schema type) is supported by Xerces-J natively.
+ */
public boolean isTypeSupported(String localName, String uri) {
boolean typeSupported = false;
@@ -224,8 +235,9 @@ public class SchemaVersioningHelper {
} // isTypeSupported
- // Method to check if the schema facet specified by method arguments (the QName
- // components of a schema facet) is supported by Xerces-J natively.
+ /* Method to check if a schema facet specified by method arguments (the
+ * QName components of a schema facet) is supported by Xerces-J natively.
+ */
public boolean isFacetSupported(String localName, String uri) {
boolean facetSupported = false;
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java?rev=1002925&r1=1002924&r2=1002925&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java Thu Sep 30 01:45:01 2010
@@ -110,7 +110,11 @@ public class SchemaDOMParser extends Def
private XSDecimal fSupportedVersion;
private int fIgnoreDepth = -1;
private boolean fPerformConditionalInclusion = true; //REVISIT: use feature
- private SchemaVersioningHelper schemaVersioningHelper = new SchemaVersioningHelper();
+
+ // instance variable to support XML Schema 1.1 conditional include
+ // processing.
+ private SchemaConditionalIncludeHelper schemaCondlInclHelper = new
+ SchemaConditionalIncludeHelper();
//
// XMLDocumentHandler methods
@@ -325,7 +329,8 @@ public class SchemaDOMParser extends Def
if (fDepth > -1) {
// perform conditional exclusion checks for schema versioning
// namespace.
- boolean ignoreElement = checkVersionControlAttributes(element, attributes);
+ boolean ignoreElement = checkVersionControlAttributes(element,
+ attributes);
if (fIgnoreDepth > -1) {
if (ignoreElement) {
fIgnoreDepth--;
@@ -603,13 +608,12 @@ public class SchemaDOMParser extends Def
/*
- * Method to check if any attributes of schema versioning namespace should
- * cause exclusion of a schema component along with it's descendant
+ * Method to check if any of attributes of schema versioning namespace
+ * should cause exclusion of a schema component along with it's descendant
* instructions.
- *
- * ref: http://www.w3.org/TR/xmlschema11-1/#cip
*/
- private boolean checkVersionControlAttributes(QName element, XMLAttributes attributes) {
+ private boolean checkVersionControlAttributes(QName element,
+ XMLAttributes attributes) {
boolean ignoreSchemaComponent = false;
@@ -621,7 +625,8 @@ public class SchemaDOMParser extends Def
List facetAvailableList = null;
List facetUnavailableList = null;
- // iterate all attributes of an element, and get values of schema versioning attributes
+ // iterate all attributes of an element, and get values of schema
+ // versioning attributes.
final int length = attributes.getLength();
for (int attrIdx = 0; attrIdx < length; ++attrIdx) {
@@ -638,8 +643,8 @@ public class SchemaDOMParser extends Def
catch (NumberFormatException nfe) {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"s4s-att-invalid-value",
- new Object[] {element.localpart, attrLocalName, nfe.getMessage()},
- XMLErrorReporter.SEVERITY_ERROR);
+ new Object[] {element.localpart, attrLocalName,
+ nfe.getMessage()}, XMLErrorReporter.SEVERITY_ERROR);
}
}
else if (SchemaSymbols.ATT_MAXVERSION.equals(attrLocalName)) {
@@ -649,21 +654,23 @@ public class SchemaDOMParser extends Def
catch (NumberFormatException nfe) {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"s4s-att-invalid-value",
- new Object[] {element.localpart, attrLocalName, nfe.getMessage()},
- XMLErrorReporter.SEVERITY_ERROR);
+ new Object[] {element.localpart, attrLocalName,
+ nfe.getMessage()}, XMLErrorReporter.SEVERITY_ERROR);
}
}
+ // '\\s+' is regex denoting longest sequence of consecutive
+ // white-space characters.
else if (SchemaSymbols.ATT_TYPEAVAILABLE.equals(attrLocalName)) {
- typeAvailableList = tokenizeString(attrValue, "\\s");
+ typeAvailableList = tokenizeString(attrValue, "\\s+");
}
else if (SchemaSymbols.ATT_TYPEUNAVAILABLE.equals(attrLocalName)) {
- typeUnavailableList = tokenizeString(attrValue, "\\s");
+ typeUnavailableList = tokenizeString(attrValue, "\\s+");
}
else if (SchemaSymbols.ATT_FACETAVAILABLE.equals(attrLocalName)) {
- facetAvailableList = tokenizeString(attrValue, "\\s");
+ facetAvailableList = tokenizeString(attrValue, "\\s+");
}
else if (SchemaSymbols.ATT_FACETUNAVAILABLE.equals(attrLocalName)) {
- facetUnavailableList = tokenizeString(attrValue, "\\s");
+ facetUnavailableList = tokenizeString(attrValue, "\\s+");
}
else {
// report a warning
@@ -675,7 +682,7 @@ public class SchemaDOMParser extends Def
}
}
- } // end attributes iteration
+ }
// perform checks for attributes vc:minVersion, vc:maxVersion, vc:typeAvailable,
// vc:typeUnavailable, vc:facetAvailable & vc:facetUnavailable.
@@ -713,7 +720,7 @@ public class SchemaDOMParser extends Def
return ignoreSchemaComponent;
- } //checkSupportedVersion
+ } // checkVersionControlAttributes
/*
@@ -722,8 +729,8 @@ public class SchemaDOMParser extends Def
* on the values of vc:minVersion & vc:maxVersion attributes from schema
* versioning namespace.
*/
- public boolean schemaVersionAllowsExclude(BigDecimal minVer,
- BigDecimal maxVer) {
+ private boolean schemaVersionAllowsExclude(BigDecimal minVer,
+ BigDecimal maxVer) {
boolean minMaxSchemaVerAllowsIgnore = false;
@@ -732,7 +739,8 @@ public class SchemaDOMParser extends Def
// Here value of "V" is an instance variable fSupportedVersion.
if (minVer != null && maxVer != null) {
- // if both vc:minVersion & vc:maxVersion attributes are present on a schema component
+ // if both vc:minVersion & vc:maxVersion attributes are present on a
+ // schema component.
if (!(minVer.compareTo(fSupportedVersion.getBigDecimal()) <= 0 &&
maxVer.compareTo(fSupportedVersion.getBigDecimal()) == 1)) {
fIgnoreDepth++;
@@ -783,9 +791,9 @@ public class SchemaDOMParser extends Def
String typeOrFacetUri = null;
if (typeOrFacetRawValue.indexOf(':') != -1) {
typeOrFacetLocalName = typeOrFacetRawValue.substring(
- typeOrFacetRawValue.indexOf(':') + 1);
+ typeOrFacetRawValue.indexOf(':') + 1);
String typeOrFacetPrefix = typeOrFacetRawValue.substring(0,
- typeOrFacetRawValue.indexOf(':'));
+ typeOrFacetRawValue.indexOf(':'));
typeOrFacetUri = fNamespaceContext.getURI(typeOrFacetPrefix.intern());
}
else {
@@ -795,14 +803,14 @@ public class SchemaDOMParser extends Def
if (typeOrFacet == Constants.IS_TYPE) {
// check for availability of schema types
if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_AVAILABILITY &&
- !schemaVersioningHelper.isTypeSupported(typeOrFacetLocalName,
+ !schemaCondlInclHelper.isTypeSupported(typeOrFacetLocalName,
typeOrFacetUri)) {
fIgnoreDepth++;
typeOrFacetAvlAllowsIgnore = true;
break;
}
else if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_UNAVAILABILITY &&
- !schemaVersioningHelper.isTypeSupported(typeOrFacetLocalName,
+ !schemaCondlInclHelper.isTypeSupported(typeOrFacetLocalName,
typeOrFacetUri)) {
typeOrFacetUnavlAllowsIgnore = false;
break;
@@ -811,21 +819,21 @@ public class SchemaDOMParser extends Def
else if (typeOrFacet == Constants.IS_FACET) {
// check for availability of schema facets
if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_AVAILABILITY &&
- !schemaVersioningHelper.isFacetSupported(typeOrFacetLocalName,
+ !schemaCondlInclHelper.isFacetSupported(typeOrFacetLocalName,
typeOrFacetUri)) {
fIgnoreDepth++;
typeOrFacetAvlAllowsIgnore = true;
break;
}
- else if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_UNAVAILABILITY &&
- !schemaVersioningHelper.isFacetSupported(typeOrFacetLocalName,
+ else if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_UNAVAILABILITY &&
+ !schemaCondlInclHelper.isFacetSupported(typeOrFacetLocalName,
typeOrFacetUri)) {
typeOrFacetUnavlAllowsIgnore = false;
break;
}
}
- } // end of list iteration
+ }
if (availaibilityUnavlCheck == Constants.TYPE_AND_FACET_AVAILABILITY) {
if (typeOrFacetAvlAllowsIgnore) {
@@ -844,21 +852,19 @@ public class SchemaDOMParser extends Def
/*
- * Method to tokenize a string value given a delimeter, and return a List
- * containing the string tokens.
+ * Method to tokenize a string value given a tokenizing delimiter, and
+ * return a List containing the string tokens.
*/
private List tokenizeString(String strValue, String delim) {
- List tokenizedList = new ArrayList();
+ List stringTokens = new ArrayList();
String[] strSplitValue = strValue.split(delim);
for (int strIdx = 0; strIdx < strSplitValue.length; strIdx++) {
- if (!(strSplitValue[strIdx].trim()).equals("")) {
- tokenizedList.add(strSplitValue[strIdx].trim());
- }
+ stringTokens.add(strSplitValue[strIdx]);
}
- return tokenizedList;
+ return stringTokens;
} // tokenizeString
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org