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 2024/07/13 06:03:33 UTC
(xerces-j) branch xml-schema-1.1-dev updated: committing latest svn revision from xerces-j svn branch xml-schema-1.1-dev
This is an automated email from the ASF dual-hosted git repository.
mukulg pushed a commit to branch xml-schema-1.1-dev
in repository https://gitbox.apache.org/repos/asf/xerces-j.git
The following commit(s) were added to refs/heads/xml-schema-1.1-dev by this push:
new 1034a167a committing latest svn revision from xerces-j svn branch xml-schema-1.1-dev
1034a167a is described below
commit 1034a167ac00e2c42e70db49e19d96cb6d16ab9b
Author: root <ro...@DESKTOP-JVNMK2U>
AuthorDate: Sat Jul 13 11:32:42 2024 +0530
committing latest svn revision from xerces-j svn branch xml-schema-1.1-dev
---
LICENSE.cupv10k-runtime.txt | 19 +
...org.eclipse.wst.xml.xpath2.processor_1.2.1.html | 258 +++
NOTICE | 12 +-
README | 9 +-
build.xml | 72 +-
docs/install.xml | 60 +
docs/releases.xml | 2 +-
docs/source-repository.xml | 2 +-
docs/style/stylesheets/document2html.xsl | 2 +-
samples/jaxp/InlineSchemaValidator.java | 8 +
samples/jaxp/SourceValidator.java | 122 +-
samples/jaxp/TypeInfoWriter.java | 8 +
samples/sax/Writer.java | 48 +-
samples/xni/PSVIWriter.java | 5 +
samples/xs/XSSerializer.java | 1182 ++++++++++
src/org/apache/xerces/dom/ElementImpl.java | 2 +-
src/org/apache/xerces/dom/NamedNodeMapImpl.java | 4 +-
src/org/apache/xerces/dom/NodeImpl.java | 2 +-
src/org/apache/xerces/dom/PSVIElementNSImpl.java | 49 +
src/org/apache/xerces/dom/ParentNode.java | 2 +-
src/org/apache/xerces/impl/Constants.java | 41 +-
.../apache/xerces/impl/dv/ValidationContext.java | 8 +
src/org/apache/xerces/impl/dv/XSFacets.java | 30 +-
src/org/apache/xerces/impl/dv/XSSimpleType.java | 21 +-
.../xerces/impl/dv/xs/AbstractDateTimeDV.java | 28 +-
src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java | 6 +-
src/org/apache/xerces/impl/dv/xs/AnySimpleDV.java | 5 -
src/org/apache/xerces/impl/dv/xs/AnyURIDV.java | 45 +-
.../apache/xerces/impl/dv/xs/Base64BinaryDV.java | 4 -
.../xerces/impl/dv/xs/BaseSchemaDVFactory.java | 12 +-
src/org/apache/xerces/impl/dv/xs/BooleanDV.java | 4 -
src/org/apache/xerces/impl/dv/xs/DateDV.java | 6 +-
src/org/apache/xerces/impl/dv/xs/DateTimeDV.java | 6 +-
.../dv/xs/{IDREFDV.java => DateTimeStampDV.java} | 40 +-
src/org/apache/xerces/impl/dv/xs/DayDV.java | 6 +-
src/org/apache/xerces/impl/dv/xs/DecimalDV.java | 4 -
src/org/apache/xerces/impl/dv/xs/DoubleDV.java | 13 +-
src/org/apache/xerces/impl/dv/xs/EntityDV.java | 10 +-
.../apache/xerces/impl/dv/xs/EqualityHelper.java | 219 ++
.../impl/dv/xs/{AnyAtomicDV.java => ErrorDV.java} | 20 +-
.../impl/dv/xs/ExtendedSchemaDVFactoryImpl.java | 4 +
src/org/apache/xerces/impl/dv/xs/FloatDV.java | 13 +-
src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java | 4 -
src/org/apache/xerces/impl/dv/xs/IDDV.java | 10 +-
src/org/apache/xerces/impl/dv/xs/IDREFDV.java | 10 +-
src/org/apache/xerces/impl/dv/xs/ListDV.java | 4 -
src/org/apache/xerces/impl/dv/xs/MonthDV.java | 6 +-
src/org/apache/xerces/impl/dv/xs/MonthDayDV.java | 6 +-
.../xerces/impl/dv/xs/PrecisionDecimalDV.java | 369 +--
src/org/apache/xerces/impl/dv/xs/QNameDV.java | 17 +-
...FactoryImpl.java => Schema11DVFactoryImpl.java} | 49 +-
.../xerces/impl/dv/xs/SchemaDVFactoryImpl.java | 39 +-
src/org/apache/xerces/impl/dv/xs/StringDV.java | 4 -
src/org/apache/xerces/impl/dv/xs/TimeDV.java | 13 +-
.../apache/xerces/impl/dv/xs/TypeValidator.java | 18 +-
.../xerces/impl/dv/xs/TypeValidatorHelper.java | 197 ++
src/org/apache/xerces/impl/dv/xs/UnionDV.java | 4 -
.../apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java | 778 +++++--
.../xerces/impl/dv/xs/XSSimpleTypeDelegate.java | 6 +-
src/org/apache/xerces/impl/dv/xs/YearDV.java | 6 +-
src/org/apache/xerces/impl/dv/xs/YearMonthDV.java | 6 +-
.../xerces/impl/msg/XMLSchemaMessages.properties | 63 +-
src/org/apache/xerces/impl/scd/Axis.java | 92 +
.../UniqueOrKey.java => scd/SCDException.java} | 46 +-
src/org/apache/xerces/impl/scd/SCDParser.java | 488 ++++
src/org/apache/xerces/impl/scd/SCDResolver.java | 1019 +++++++++
src/org/apache/xerces/impl/scd/Step.java | 80 +
.../validation/ConfigurableValidationState.java | 16 +-
.../xerces/impl/validation/ValidationState.java | 38 +-
.../apache/xerces/impl/xpath/SimpleCharStream.java | 461 ++++
src/org/apache/xerces/impl/xpath/Token.java | 150 ++
src/org/apache/xerces/impl/xpath/XPath20.java | 532 +++++
.../apache/xerces/impl/xpath/XPath20Parser.java | 409 ++++
.../impl/xpath/XPath20ParserTokenManager.java | 622 +++++
.../impl/xpath/regex/ParserForXMLSchema.java | 199 +-
.../xerces/impl/xpath/regex/REConstants.java | 131 ++
src/org/apache/xerces/impl/xpath/regex/REUtil.java | 17 +
.../regex/RangeTokenMap.java} | 9 +-
.../regex/RangeTokenMapFactory.java} | 26 +-
.../xerces/impl/xpath/regex/RegexParser.java | 18 +-
.../xerces/impl/xpath/regex/RegularExpression.java | 25 +-
src/org/apache/xerces/impl/xpath/regex/Token.java | 4 +
.../xerces/impl/xpath/regex/XML11TokenMap.java | 82 +
.../xerces/impl/xpath/regex/XMLTokenMap.java | 84 +
.../xerces/impl/xs/AbstractXPath2EngineImpl.java | 207 ++
src/org/apache/xerces/impl/xs/ElementPSVImpl.java | 52 +
src/org/apache/xerces/impl/xs/IDContext.java | 188 ++
src/org/apache/xerces/impl/xs/ObjectFactory.java | 543 +++++
src/org/apache/xerces/impl/xs/SchemaGrammar.java | 141 +-
src/org/apache/xerces/impl/xs/SchemaSymbols.java | 357 +--
src/org/apache/xerces/impl/xs/SecuritySupport.java | 141 ++
.../xerces/impl/xs/SubstitutionGroupHandler.java | 81 +-
.../xerces/impl/xs/XMLAssertXPath2EngineImpl.java | 1060 +++++++++
src/org/apache/xerces/impl/xs/XMLSchemaLoader.java | 126 +-
.../apache/xerces/impl/xs/XMLSchemaValidator.java | 2402 ++++----------------
.../xerces/impl/xs/XMLSchemaValidatorBase.java | 2020 ++++++++++++++++
.../{XSConstraints.java => XS10Constraints.java} | 923 +++-----
src/org/apache/xerces/impl/xs/XS11Constraints.java | 656 ++++++
src/org/apache/xerces/impl/xs/XSAttributeDecl.java | 33 +-
.../xerces/impl/xs/XSAttributeGroupDecl.java | 47 +-
.../apache/xerces/impl/xs/XSAttributeUseImpl.java | 10 +
.../apache/xerces/impl/xs/XSComplexTypeDecl.java | 56 +-
src/org/apache/xerces/impl/xs/XSConstraints.java | 1228 +++-------
.../xerces/impl/xs/XSDAssertionValidator.java | 479 ++++
src/org/apache/xerces/impl/xs/XSDDescription.java | 7 +
.../impl/xs/XSDTypeAlternativeValidator.java | 180 ++
.../apache/xerces/impl/xs/XSDeclarationPool.java | 6 +-
src/org/apache/xerces/impl/xs/XSElementDecl.java | 100 +-
.../apache/xerces/impl/xs/XSElementDeclHelper.java | 1 -
src/org/apache/xerces/impl/xs/XSModelImpl.java | 10 +-
.../apache/xerces/impl/xs/XSOpenContentDecl.java | 123 +
.../BooleanDV.java => xs/XSValidationState.java} | 47 +-
src/org/apache/xerces/impl/xs/XSWildcardDecl.java | 401 +---
.../apache/xerces/impl/xs/alternative/Test.java | 183 ++
.../impl/xs/alternative/XSTypeAlternativeImpl.java | 170 ++
src/org/apache/xerces/impl/xs/assertion/Test.java | 62 +
.../xerces/impl/xs/assertion/XMLAssertAdapter.java | 110 +
.../xerces/impl/xs/assertion/XMLAssertHandler.java | 110 +
.../xs/assertion/XSAssert.java} | 36 +-
.../XSAssertConstants.java} | 25 +-
.../xerces/impl/xs/assertion/XSAssertImpl.java | 242 ++
.../impl/xs/assertion/XSAssertionXPath2Value.java | 63 +
.../xs/assertion/XSAssertionXPath2ValueImpl.java | 357 +++
src/org/apache/xerces/impl/xs/identity/Field.java | 16 +-
.../impl/xs/identity/IdentityConstraint.java | 11 +-
src/org/apache/xerces/impl/xs/identity/KeyRef.java | 4 +-
.../apache/xerces/impl/xs/identity/Selector.java | 12 +-
.../xerces/impl/xs/identity/UniqueOrKey.java | 4 +-
.../apache/xerces/impl/xs/identity/ValueStore.java | 11 +
.../xerces/impl/xs/identity/XPathMatcher.java | 19 +-
.../apache/xerces/impl/xs/models/CMBuilder.java | 82 +-
.../xerces/impl/xs/models/CMNodeFactory.java | 8 +
.../apache/xerces/impl/xs/models/XS11AllCM.java | 626 +++++
.../xerces/impl/xs/models/XS11CMRestriction.java | 1355 +++++++++++
src/org/apache/xerces/impl/xs/models/XSAllCM.java | 28 +-
.../xerces/impl/xs/models/XSCMValidator.java | 11 +-
src/org/apache/xerces/impl/xs/models/XSDFACM.java | 622 +++--
.../apache/xerces/impl/xs/models/XSEmptyCM.java | 79 +-
.../xs/opti/SchemaConditionalIncludeHelper.java | 259 +++
.../xerces/impl/xs/opti/SchemaDOMParser.java | 357 ++-
.../xerces/impl/xs/opti/SchemaParsingConfig.java | 19 +-
.../xerces/impl/xs/traversers/DOMOverrideImpl.java | 344 +++
.../xs/traversers/OverrideTransformException.java | 49 +-
.../traversers/OverrideTransformationManager.java | 379 +++
.../impl/xs/traversers/OverrideTransformer.java | 49 +
.../impl/xs/traversers/XSAttributeChecker.java | 1071 +++++++--
.../XSDAbstractIDConstraintTraverser.java | 104 +-
.../traversers/XSDAbstractParticleTraverser.java | 79 +-
.../impl/xs/traversers/XSDAbstractTraverser.java | 311 ++-
.../xs/traversers/XSDAttributeGroupTraverser.java | 7 +-
.../impl/xs/traversers/XSDAttributeTraverser.java | 124 +-
.../xs/traversers/XSDComplexTypeTraverser.java | 1108 +++++++--
.../impl/xs/traversers/XSDElementTraverser.java | 129 +-
.../impl/xs/traversers/XSDGroupTraverser.java | 4 +-
.../xerces/impl/xs/traversers/XSDHandler.java | 765 +++++--
.../impl/xs/traversers/XSDKeyrefTraverser.java | 2 +-
.../impl/xs/traversers/XSDSimpleTypeTraverser.java | 124 +-
.../xs/traversers/XSDTypeAlternativeTraverser.java | 276 +++
.../xs/traversers/XSDUniqueOrKeyTraverser.java | 4 +-
.../impl/xs/traversers/XSDWildcardTraverser.java | 57 +-
.../xerces/impl/xs/traversers/XSDocumentInfo.java | 50 +-
.../apache/xerces/impl/xs/util/ObjectListImpl.java | 4 +-
.../apache/xerces/impl/xs/util/XS10TypeHelper.java | 62 -
.../apache/xerces/impl/xs/util/XS11TypeHelper.java | 338 +++
.../apache/xerces/impl/xs/util/XSGrammarPool.java | 4 +-
.../xerces/impl/xs/util/XSObjectListImpl.java | 2 +-
.../apache/xerces/jaxp/DocumentBuilderImpl.java | 10 +-
src/org/apache/xerces/jaxp/SAXParserImpl.java | 8 +
.../apache/xerces/jaxp/datatype/DurationImpl.java | 4 +-
.../xerces/jaxp/validation/AbstractXMLSchema.java | 12 +-
...MLSchemaFactory.java => BaseSchemaFactory.java} | 167 +-
.../xerces/jaxp/validation/DOMValidatorHelper.java | 47 +-
.../xerces/jaxp/validation/EmptyXMLSchema.java | 4 +-
.../xerces/jaxp/validation/SimpleXMLSchema.java | 3 +-
.../jaxp/validation/StAXValidatorHelper.java | 63 +-
.../jaxp/validation/ValidatorHandlerImpl.java | 104 +-
.../xerces/jaxp/validation/ValidatorImpl.java | 6 +-
.../jaxp/validation/WeakReferenceXMLSchema.java | 4 +-
.../apache/xerces/jaxp/validation/XMLSchema.java | 7 +-
.../xerces/jaxp/validation/XMLSchema11Factory.java | 49 +
.../xerces/jaxp/validation/XMLSchemaFactory.java | 482 +---
.../XMLSchemaValidatorComponentManager.java | 33 +-
.../jaxp/validation/XSGrammarPoolContainer.java | 8 +
.../validation/javax.xml.validation.SchemaFactory | 1 +
.../parsers/StandardParserConfiguration.java | 18 +
.../apache/xerces/parsers/XML11Configuration.java | 15 +
.../xerces/stax/events/StartElementImpl.java | 2 +-
src/org/apache/xerces/util/DOMUtil.java | 6 +
.../xerces/util/JAXPNamespaceContextWrapper.java | 4 +
src/org/apache/xerces/util/NamespaceSupport.java | 34 +
src/org/apache/xerces/util/XMLAttributesImpl.java | 1 +
src/org/apache/xerces/xni/NamespaceContext.java | 11 +
src/org/apache/xerces/xpointer/XPointerPart.java | 1 -
.../apache/xerces/xpointer/XPointerProcessor.java | 9 +-
src/org/apache/xerces/xs/ElementPSVI.java | 17 +
src/org/apache/xerces/xs/ItemPSVI.java | 9 -
.../apache/xerces/xs/XSAttributeDeclaration.java | 29 +-
src/org/apache/xerces/xs/XSAttributeUse.java | 13 +-
.../apache/xerces/xs/XSComplexTypeDefinition.java | 10 +
src/org/apache/xerces/xs/XSConstants.java | 20 +
src/org/apache/xerces/xs/XSElementDeclaration.java | 20 +-
src/org/apache/xerces/xs/XSFacet.java | 17 +-
src/org/apache/xerces/xs/XSMultiValueFacet.java | 7 +
.../xs/{ElementPSVI.java => XSOpenContent.java} | 36 +-
.../apache/xerces/xs/XSSimpleTypeDefinition.java | 22 +-
...MultiValueFacet.java => XSTypeAlternative.java} | 30 +-
src/org/apache/xerces/xs/XSTypeDefinition.java | 36 +-
.../apache/xml/serialize/DOMSerializerImpl.java | 2 +-
tests/idc/IDConstraintTests.java | 568 -----
tests/idc/idc_1.xsd | 62 -
tests/idc/idc_1_invalid_1.xml | 34 -
tests/idc/idc_1_invalid_2.xml | 34 -
tests/idc/idc_1_invalid_3.xml | 37 -
tests/idc/idc_1_valid_1.xml | 37 -
tests/idc/idc_2.xsd | 21 -
tests/idc/idc_2_invalid_1.xml | 14 -
tests/idc/idc_2_invalid_2.xml | 14 -
tests/idc/idc_2_valid_1.xml | 14 -
tests/idc/idc_2_valid_2.xml | 14 -
tests/idc/idc_3.xsd | 21 -
tests/idc/idc_3_invalid_1.xml | 14 -
tests/idc/idc_3_invalid_2.xml | 14 -
tests/idc/idc_3_valid_1.xml | 14 -
tests/idc/idc_4.xsd | 19 -
tests/idc/idc_4_invalid_1.xml | 6 -
tests/idc/idc_4_invalid_2.xml | 6 -
tests/idc/idc_4_valid_1.xml | 6 -
tests/idc/idc_4_valid_2.xml | 6 -
tests/idc/idc_5.xsd | 19 -
tests/idc/idc_5_invalid_1.xml | 6 -
tests/idc/idc_5_invalid_2.xml | 6 -
tests/idc/idc_5_valid_1.xml | 6 -
tests/idc/idc_6.xsd | 23 -
tests/idc/idc_6_invalid_1.xml | 11 -
tests/idc/idc_6_valid_1.xml | 11 -
tests/idc/invalid_1_1515.xml | 3 -
tests/idc/jira_1515.xsd | 25 -
tests/idc/jira_1585.xml | 10 -
tests/idc/jira_1585.xsd | 41 -
tests/idc/jira_1594.xml | 13 -
tests/idc/jira_1594.xsd | 29 -
tests/idc/jira_1714.xsd | 84 -
tests/idc/jira_1714_invalid.xml | 18 -
tests/idc/jira_1714_valid.xml | 24 -
tests/idc/valid_1_1515.xml | 4 -
tests/idc/valid_2_1515.xml | 3 -
tests/scd/BaseTest.java | 155 ++
tests/scd/HasDefaultNamespace.java | 59 +
tests/scd/HasTargetNamespace.java | 80 +
tests/scd/NoTargetNamespace.java | 129 ++
tests/scd/dd.xsd | 173 ++
tests/scd/po1.xsd | 56 +
tests/scd/po2.xsd | 75 +
tests/schema/config/BaseTest.java | 4 +-
tests/schema/override/BaseOverrideTest.java | 76 +
tests/schema/override/OverrideHandlerTest.java | 389 ++++
.../schema/override/OverrideIntegrationTest.java | 9 +-
.../override/OverrideTestSuite.java} | 18 +-
tests/schema/override/OverrideTransformTest.java | 87 +
.../override/XSDHandlerDelegate.java} | 31 +-
tests/schema/override/overridden.xsd | 17 +
tests/schema/override/overridden1.xsd | 28 +
tests/schema/override/overridden2.xsd | 18 +
tests/schema/override/overriding-copy.xsd | 18 +
tests/schema/override/overriding.xsd | 19 +
tests/schema/override/overriding1.xsd | 19 +
tests/schema/override/overriding2.xsd | 19 +
tests/schema/override/result.xsd | 14 +
tests/schema/override/result1.xsd | 26 +
tests/schema/override/result2.xsd | 24 +
tests/schema/override/scenario_1/A.xsd | 19 +
tests/schema/override/scenario_1/B.xsd | 10 +
tests/schema/override/scenario_1/C.xsd | 15 +
tests/schema/override/scenario_2/A.xsd | 19 +
tests/schema/override/scenario_2/B.xsd | 10 +
tests/schema/override/scenario_2/C.xsd | 16 +
tests/schema/override/scenario_3/A.xsd | 19 +
tests/schema/override/scenario_3/B.xsd | 10 +
tests/schema/override/scenario_3/C.xsd | 16 +
tests/schema/override/scenario_4/A.xsd | 18 +
tests/schema/override/scenario_4/B.xsd | 8 +
tests/schema/override/scenario_4/C.xsd | 18 +
tests/schema/override/scenario_5/A.xsd | 18 +
tests/schema/override/scenario_5/B.xsd | 9 +
tests/schema/override/scenario_5/C.xsd | 18 +
tests/schema/override/schemaA.xsd | 19 +
tests/schema/override/schemaA_1.xsd | 28 +
tests/schema/override/schemaA_2.xsd | 16 +
tests/util/XercesAbstractTestCase.java | 182 --
tools/bin/xjavac.jar | Bin 7053 -> 7239 bytes
tools/cupv10k-runtime.LICENSE.txt | 19 +
tools/cupv10k-runtime.jar | Bin 0 -> 8980 bytes
tools/icu4j.jar | Bin 519119 -> 13293711 bytes
...pse.wst.xml.xpath2.processor_1.2.1.LICENSE.html | 258 +++
.../org.eclipse.wst.xml.xpath2.processor_1.2.1.jar | Bin 0 -> 690199 bytes
tools/src/XJavac.java | 2 +
296 files changed, 27376 insertions(+), 8108 deletions(-)
diff --git a/LICENSE.cupv10k-runtime.txt b/LICENSE.cupv10k-runtime.txt
new file mode 100644
index 000000000..a21c9ca32
--- /dev/null
+++ b/LICENSE.cupv10k-runtime.txt
@@ -0,0 +1,19 @@
+CUP Parser Generator Copyright Notice, License, and Disclaimer
+
+Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both
+the copyright notice and this permission notice and warranty disclaimer
+appear in supporting documentation, and that the names of the authors
+or their employers not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior permission.
+
+The authors and their employers disclaim all warranties with regard to
+this software, including all implied warranties of merchantability
+and fitness. In no event shall the authors or their employers be liable
+for any special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether in an action
+of contract, negligence or other tortious action, arising out of or
+in connection with the use or performance of this software.
diff --git a/LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html b/LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html
new file mode 100644
index 000000000..b6b2aa1a3
--- /dev/null
+++ b/LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html
@@ -0,0 +1,258 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Eclipse Public License - Version 1.0</title>
+<style type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </style>
+
+</head><body lang="EN-US">
+
+<h2>Eclipse Public License - v 1.0</h2>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>"Contribution" means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>"Contributor" means any person or entity that distributes
+the Program.</p>
+
+<p>"Licensed Patents" mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>"Program" means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>"Recipient" means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and
+indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses")
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body></html>
\ No newline at end of file
diff --git a/NOTICE b/NOTICE
index 08695a259..338fa8450 100644
--- a/NOTICE
+++ b/NOTICE
@@ -14,4 +14,14 @@
- software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
- voluntary contributions made by Paul Eng on behalf of the
Apache Software Foundation that were originally developed at iClick, Inc.,
- software copyright (c) 1999.
\ No newline at end of file
+ software copyright (c) 1999.
+
+ This product includes/uses the PsychoPath XPath 2.0 Processor
+ (org.eclipse.wst.xml.xpath2.processor_1.2.1.jar) developed at
+ The Eclipse Foundation (http://www.eclipse.org) and made available under
+ the Eclipse Public License v1.0.
+
+ This product includes/uses the CUP Parser Generator (cupv10k-runtime.jar)
+ maintained at (http://www2.cs.tum.edu/projects/cup/)
+ Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian
+
\ No newline at end of file
diff --git a/README b/README
index 4fb7e1ef6..4282d9b21 100644
--- a/README
+++ b/README
@@ -56,4 +56,11 @@ building, these files will be located in the build/ directory.
If you want to build everything, including the documentation,
run the build batch file (or shell script) specifying the "all"
-target instead of "jars".
\ No newline at end of file
+target instead of "jars".
+
+Details about proprietary XML Schema 1.1 unit tests:
+The XercesJ XML Schema 1.1 deliverables, include a proprietary unit test suite located in the branch "xs-1.1-tests".
+This is in addition to the Xerces tests that are located at /xerces-java-xml-schema-1.1-dev/tests. It is advisable
+to always comply to tests in the branch "xs-1.1-tests" whenever changing the code (in addition to the tests /xerces-java-xml-schema-1.1-dev/tests),
+since the functionality these tests are testing are core part of Xerces deliverables (one of the important things the
+"xs-1.1-tests" tests test, are the error/warning messages generated during XML Schema 1.1 validation assessments.
\ No newline at end of file
diff --git a/build.xml b/build.xml
index 9062704c4..b79124303 100644
--- a/build.xml
+++ b/build.xml
@@ -40,12 +40,12 @@ Authors:
<!-- enable compilation under JDK 1.4 and above. -->
<!--
- Although, the Java component org.apache.xerces.util.XJavac
- is designed to support Java 1.4+ (and that's ok for Java 1.7+
- as well), starting with XercesJ v 2.12.2, XercesJ builds
- produce Java binaries that require Java language level 1.7+.
- Please see the definitions of Ant build properties javac.source
- and javac.target further below.
+ Although, the Java component org.apache.xerces.util.XJavac
+ is designed to support Java 1.4+ (and that's ok for Java 1.7+
+ as well), starting with XercesJ v 2.12.2, XercesJ builds
+ produce Java binaries that require Java language level 1.7+.
+ Please see the definitions of Ant build properties javac.source
+ and javac.target further below.
-->
<taskdef name="xjavac" classname="org.apache.xerces.util.XJavac">
<classpath>
@@ -65,9 +65,9 @@ Authors:
<property name='parser.Name' value='Xerces-J'/>
<property name='parser.name' value='xerces-j'/>
<property name='parser.shortname' value='xerces'/>
- <property name='parser.Version' value='2.12.3'/>
- <property name='parser.version' value='2.12.3'/>
- <property name='parser_version' value='2_12_3'/>
+ <property name='parser.Version' value='2.12.3-xml-schema-1.1'/>
+ <property name='parser.version' value='2.12.3-xml-schema-1.1'/>
+ <property name='parser_version' value='2_12_3-xml-schema-1.1'/>
<property name='deprecatedjar.parser' value='xerces.jar'/>
<property name='jar.apis' value='xml-apis.jar'/>
@@ -76,11 +76,14 @@ Authors:
<property name='jar.dv' value='xercesDV.jar'/>
<property name='jar.resolver' value='resolver.jar'/>
<property name='jar.serializer' value='serializer.jar'/>
+ <property name='jar.charnormalizer' value='icu4j.jar'/>
+ <property name='jar.xpath2' value='org.eclipse.wst.xml.xpath2.processor_1.2.1.jar'/>
+ <property name='jar.cup' value='cupv10k-runtime.jar'/>
<property name='jar.junit' value='junit.jar'/>
<property name='jar.ant' value='ant.jar'/>
<property name='jar.ant.nodeps' value='ant-nodeps.jar'/>
<property name='jar.xjavac' value='xjavac.jar'/>
-
+
<property name='default.parser.config.name' value='XIncludeAwareParserConfiguration'/>
<property name='default.parser.config.qualified' value='org.apache.xerces.parsers.XIncludeAwareParserConfiguration'/>
@@ -90,7 +93,7 @@ Authors:
<echo message= "---------------- ${parser.Name} ${parser.Version} [${year}] ---------------"/>
<!-- changed made to synchronize with a patch from Sam Ruby (<ru...@apache.org>) to Xerces1
<property name="build.compiler" value="classic"/> -->
- <property name="debug" value="true"/> <!-- make this 'false' during releases -->
+ <property name="debug" value="true"/> <!-- make this 'false' during releases -->
<property name="debuglevel" value="lines,source"/>
<property name="optimize" value="on"/>
<property name="deprecation" value="off"/>
@@ -301,7 +304,7 @@ Authors:
destdir="${build.dest}"
source="${javac.source}"
target="${javac.target}"
- classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
+ classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}:${tools.dir}/${jar.charnormalizer}:${tools.dir}/${jar.xpath2}:${tools.dir}/${jar.cup}"
debug="${debug}"
debuglevel="${debuglevel}"
deprecation="${deprecation}"
@@ -517,7 +520,7 @@ Authors:
org.apache.xerces.xpointer'
locale='en_US'
sourcepath='${build.src}' destdir='${build.dir}/docs/javadocs/xerces2'
- classpath='${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}'
+ classpath='${tools.dir}/${jar.xpath2}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}'
author='true' version='true'
windowtitle='Xerces2 Implementation'
doctitle='Xerces2 Implementation'
@@ -530,6 +533,7 @@ Authors:
org.apache.xml.serialize.*'
locale='en_US'
sourcepath='${build.src}' destdir='${build.dir}/docs/javadocs/other'
+ classpath='${tools.dir}/${jar.xpath2}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}'
author='true' version='true'
windowtitle='Other Classes' doctitle='Other Classes'
bottom='${copyright}'
@@ -586,10 +590,13 @@ Authors:
<copy file="NOTICE.resolver.txt" tofile="${distsrc.dir}/NOTICE.resolver.txt"/>
<copy file="NOTICE.serializer.txt" tofile="${distsrc.dir}/NOTICE.serializer.txt"/>
<copy file="LICENSE.DOM-documentation.html" tofile="${distsrc.dir}/LICENSE.DOM-documentation.html"/>
+ <copy file="LICENSE.icu4j.html" tofile="${distsrc.dir}/LICENSE.icu4j.html"/>
<copy file="LICENSE.DOM-software.html" tofile="${distsrc.dir}/LICENSE.DOM-software.html"/>
<copy file="LICENSE-SAX.html" tofile="${distsrc.dir}/LICENSE-SAX.html"/>
<copy file="LICENSE.resolver.txt" tofile="${distsrc.dir}/LICENSE.resolver.txt"/>
<copy file="LICENSE.serializer.txt" tofile="${distsrc.dir}/LICENSE.serializer.txt"/>
+ <copy file="LICENSE.cupv10k-runtime.txt" tofile="${distsrc.dir}/LICENSE.cupv10k-runtime.txt"/>
+ <copy file="LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html" tofile="${distsrc.dir}/LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html"/>
<copy file="README" tofile="${distsrc.dir}/README"/>
<copy file="Readme.html" tofile="${distsrc.dir}/Readme.html"/>
<copy file="build.xml" tofile="${distsrc.dir}/build.xml"/>
@@ -621,7 +628,7 @@ Authors:
<fileset
dir="${tools.dir}"
includes="**/*.txt, **/*.html, **/*.bat, **/*.jar, **/*.zip, **/*.opt"
- excludes="**/CVS*, **/.#*, **/*.class, **/icu4j*"
+ excludes="**/CVS*, **/.#*, **/*.class"
/>
</copy>
@@ -686,6 +693,9 @@ Authors:
<copy file="LICENSE-SAX.html" tofile="${distbin.dir}/LICENSE-SAX.html"/>
<copy file="LICENSE.resolver.txt" tofile="${distbin.dir}/LICENSE.resolver.txt"/>
<copy file="LICENSE.serializer.txt" tofile="${distsrc.dir}/LICENSE.serializer.txt"/>
+ <copy file="LICENSE.icu4j.html" tofile="${distsrc.dir}/LICENSE.icu4j.html"/>
+ <copy file="LICENSE.cupv10k-runtime.txt" tofile="${distsrc.dir}/LICENSE.cupv10k-runtime.txt"/>
+ <copy file="LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html" tofile="${distsrc.dir}/LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.1.html"/>
<copy file="Readme.html" tofile="${distbin.dir}/Readme.html"/>
<copy file="${build.dir}/${jar.samples}" tofile="${distbin.dir}/${jar.samples}"/>
@@ -711,6 +721,12 @@ Authors:
<copy file="${tools.dir}/${jar.resolver}" tofile="${distbin.dir}/${jar.resolver}"/>
<!-- include the Xalan Serializer -->
<copy file="${tools.dir}/${jar.serializer}" tofile="${distbin.dir}/${jar.serializer}"/>
+ <!-- include the ICU4J character normalizer -->
+ <copy file="${tools.dir}/${jar.charnormalizer}" tofile="${distbin.dir}/${jar.charnormalizer}"/>
+ <!-- include the XPath 2.0 processor -->
+ <copy file="${tools.dir}/${jar.xpath2}" tofile="${distbin.dir}/${jar.xpath2}"/>
+ <!-- include the Java Cup Runtime -->
+ <copy file="${tools.dir}/${jar.cup}" tofile="${distbin.dir}/${jar.cup}"/>
<zip zipfile="${build.dir}/${parser.Name}-bin.${parser.version}.zip"
basedir="${build.dir}"
@@ -737,6 +753,12 @@ Authors:
<copy file="${tools.dir}/${jar.resolver}" tofile="${distbin.dir}/${jar.resolver}"/>
<!-- include the Xalan Serializer -->
<copy file="${tools.dir}/${jar.serializer}" tofile="${distbin.dir}/${jar.serializer}"/>
+ <!-- include the ICU4J character normalizer -->
+ <copy file="${tools.dir}/${jar.charnormalizer}" tofile="${distbin.dir}/${jar.charnormalizer}"/>
+ <!-- include the XPath 2.0 processor -->
+ <copy file="${tools.dir}/${jar.xpath2}" tofile="${distbin.dir}/${jar.xpath2}"/>
+ <!-- include the Java Cup Runtime -->
+ <copy file="${tools.dir}/${jar.cup}" tofile="${distbin.dir}/${jar.cup}"/>
<zip zipfile="${build.dir}/deprecated${parser.Name}-bin.${parser.version}.zip"
basedir="${build.dir}"
@@ -931,12 +953,6 @@ Authors:
classname="dom.dom3.Test"
failOnError="yes">
<jvmarg value="-Xbootclasspath/p:${tools.dir}/${jar.apis}${path.separator}${tools.dir}/${jar.resolver}${path.separator}${tools.dir}/${jar.serializer}${path.separator}${build.dir}/classes"/>
- </java>
- <echo message="Running idc.AllTests ..." />
- <java fork="yes"
- classname="idc.AllTests"
- failOnError="yes">
- <jvmarg value="-Xbootclasspath/p:${tools.dir}/${jar.apis}${path.separator}${tools.dir}/${jar.resolver}${path.separator}${tools.dir}/${jar.serializer}${path.separator}${tools.dir}/${jar.junit}${path.separator}${build.dir}/classes${path.separator}${build.dir}/tests"/>
</java>
</target>
@@ -948,6 +964,12 @@ Authors:
<copy file="${tools.dir}/${jar.resolver}" tofile="${build.dir}/${jar.resolver}"/>
<!-- include the Xalan Serializer -->
<copy file="${tools.dir}/${jar.serializer}" tofile="${build.dir}/${jar.serializer}"/>
+ <!-- include the ICU4J character normalizer -->
+ <copy file="${tools.dir}/${jar.charnormalizer}" tofile="${build.dir}/${jar.charnormalizer}"/>
+ <!-- include the XPath 2.0 processor -->
+ <copy file="${tools.dir}/${jar.xpath2}" tofile="${build.dir}/${jar.xpath2}"/>
+ <!-- include the Java Cup Runtime -->
+ <copy file="${tools.dir}/${jar.cup}" tofile="${build.dir}/${jar.cup}"/>
</target>
<!-- =================================================================== -->
@@ -960,6 +982,12 @@ Authors:
<copy file="${tools.dir}/${jar.resolver}" tofile="${build.dir}/${jar.resolver}"/>
<!-- include the Xalan Serializer -->
<copy file="${tools.dir}/${jar.serializer}" tofile="${build.dir}/${jar.serializer}"/>
+ <!-- include the ICU4J character normalizer -->
+ <copy file="${tools.dir}/${jar.charnormalizer}" tofile="${build.dir}/${jar.charnormalizer}"/>
+ <!-- include the XPath 2.0 processor -->
+ <copy file="${tools.dir}/${jar.xpath2}" tofile="${build.dir}/${jar.xpath2}"/>
+ <!-- include the Java Cup Runtime -->
+ <copy file="${tools.dir}/${jar.cup}" tofile="${build.dir}/${jar.cup}"/>
</target>
<!-- =================================================================== -->
@@ -1290,6 +1318,8 @@ Authors:
<copy file="${tools.dir}/${jar.resolver}" tofile="${build.dir}/${jar.resolver}"/>
<!-- include the Xalan Serializer -->
<copy file="${tools.dir}/${jar.serializer}" tofile="${build.dir}/${jar.serializer}"/>
+ <!-- include the ICU4J character normalizer -->
+ <copy file="${tools.dir}/${jar.charnormalizer}" tofile="${build.dir}/${jar.charnormalizer}"/>
</target>
<!-- =================================================================== -->
@@ -1469,7 +1499,7 @@ Authors:
destdir="${build.dest}"
source="${javac.source}"
target="${javac.target}"
- classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
+ classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}:${tools.dir}/${jar.xpath2}"
debug="${debug}"
debuglevel="${debuglevel}"
deprecation="${deprecation}"
diff --git a/docs/install.xml b/docs/install.xml
index 69151682f..40ee8f357 100644
--- a/docs/install.xml
+++ b/docs/install.xml
@@ -44,6 +44,18 @@ jar xf &ParserName;-tools.&parserversion;.zip</source>
<td>NOTICE</td>
<td>NOTICE file for &ParserName;</td>
</tr>
+ <tr>
+ <td>LICENSE.cupv10k-runtime.txt</td>
+ <td>License for the CUP Parser Generator</td>
+ </tr>
+ <tr>
+ <td>LICENSE.icu4j.html</td>
+ <td>License file for ICU4J 4.2</td>
+ </tr>
+ <tr>
+ <td>LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.0.html</td>
+ <td>License for the Eclipse PsychoPath XPath 2.0 Processor</td>
+ </tr>
<tr>
<td>LICENSE.resolver.txt</td>
<td>License for the XML Commons Resolver</td>
@@ -76,6 +88,18 @@ jar xf &ParserName;-tools.&parserversion;.zip</source>
<td>Readme.html</td>
<td>Web page redirect to docs/html/index.html</td>
</tr>
+ <tr>
+ <td>cupv10k-runtime.jar</td>
+ <td>Jar file containing the CUP Parser Generator Runtime</td>
+ </tr>
+ <tr>
+ <td>icu4j.jar</td>
+ <td>Jar file containing ICU4J 4.2</td>
+ </tr>
+ <tr>
+ <td>org.eclipse.wst.xml.xpath2.processor_1.2.1.jar</td>
+ <td>Jar file containing the Eclipse PsychoPath XPath 2.0 Processor</td>
+ </tr>
<tr>
<td>resolver.jar</td>
<td>Jar file containing the XML Commons Resolver. Currently
@@ -143,6 +167,18 @@ jar xf &ParserName;-tools.&parserversion;.zip</source>
<td>NOTICE</td>
<td>NOTICE file for &ParserName;</td>
</tr>
+ <tr>
+ <td>LICENSE.cupv10k-runtime.txt</td>
+ <td>License for the CUP Parser Generator</td>
+ </tr>
+ <tr>
+ <td>LICENSE.icu4j.html</td>
+ <td>License file for ICU4J 4.2</td>
+ </tr>
+ <tr>
+ <td>LICENSE.org.eclipse.wst.xml.xpath2.processor_1.2.0.html</td>
+ <td>License for the Eclipse PsychoPath XPath 2.0 Processor</td>
+ </tr>
<tr>
<td>LICENSE.resolver.txt</td>
<td>License for the XML Commons Resolver</td>
@@ -236,6 +272,22 @@ jar xf &ParserName;-tools.&parserversion;.zip</source>
<td>ant*.NOTICE.txt</td>
<td>NOTICE file for Apache Ant 1.7.1</td>
</tr>
+ <tr>
+ <td>cupv10k-runtime.jar</td>
+ <td>Jar file containing the CUP Parser Generator Runtime</td>
+ </tr>
+ <tr>
+ <td>cupv10k-runtime.LICENSE.txt</td>
+ <td>License for the CUP Parser Generator</td>
+ </tr>
+ <tr>
+ <td>icu4j.jar</td>
+ <td>Jar file containing ICU4J 4.2</td>
+ </tr>
+ <tr>
+ <td>icu4j.LICENSE.html</td>
+ <td>License file for ICU4J 4.2</td>
+ </tr>
<tr>
<td>junit.jar</td>
<td>Jar file containing JUnit 3.8.1</td>
@@ -244,6 +296,14 @@ jar xf &ParserName;-tools.&parserversion;.zip</source>
<td>junit.LICENSE.html</td>
<td>License for JUnit 3.8.1</td>
</tr>
+ <tr>
+ <td>org.eclipse.wst.xml.xpath2.processor_1.2.1.jar</td>
+ <td>Jar file containing the Eclipse PsychoPath XPath 2.0 Processor</td>
+ </tr>
+ <tr>
+ <td>org.eclipse.wst.xml.xpath2.processor_1.2.0.LICENSE.html</td>
+ <td>License for the Eclipse PsychoPath XPath 2.0 Processor</td>
+ </tr>
<tr>
<td>resolver.jar</td>
<td>Jar file containing the XML Commons Resolver. Currently
diff --git a/docs/releases.xml b/docs/releases.xml
index 42eaa91d5..b6876e955 100644
--- a/docs/releases.xml
+++ b/docs/releases.xml
@@ -160,7 +160,7 @@
required by XercesJ.
</note>
<submitter name='XercesJ team'/>
- </add>
+ </add>
<add>
<note>
Re-built, "XML Commons External" and "XML Commons Resolver" codebases
diff --git a/docs/source-repository.xml b/docs/source-repository.xml
index 08c7bb89d..69037b887 100644
--- a/docs/source-repository.xml
+++ b/docs/source-repository.xml
@@ -60,6 +60,6 @@ svn co <jump href="https://svn.apache.org/repos/asf/xerces/java/tags/Xerces-J_2_
Tools Platform (WTP) project</jump>, has contributed to the development of an XPath 2.0 engine that is
used within XercesJ's XML Schema 1.1 processor. The XercesJ specific source code of this
XPath 2.0 engine, is located on following GitHub repository : <jump href="https://github.com/xercesj/xpath20">https://github.com/xercesj/xpath20</jump>.
- </p>
+ </p>
</s2>
</s1>
\ No newline at end of file
diff --git a/docs/style/stylesheets/document2html.xsl b/docs/style/stylesheets/document2html.xsl
index 4176714d8..d54554e43 100644
--- a/docs/style/stylesheets/document2html.xsl
+++ b/docs/style/stylesheets/document2html.xsl
@@ -33,7 +33,7 @@
<tr>
<xsl:choose>
<xsl:when test="$id = 'index'">
- <!-- revisit : get the value 'Xerces2 Java XML Parser' from file entities.ent -->
+ <!-- revisit : get the value 'Xerces2 Java XML Parser' from file entities.ent -->
<td align="center" bgcolor="#0086b2" colspan="4" height="35" valign="middle" width="456">
<font color="#f8fefd" face="arial,helvetica,sanserif" size="+2">Xerces2 Java XML Parser Readme</font>
</td>
diff --git a/samples/jaxp/InlineSchemaValidator.java b/samples/jaxp/InlineSchemaValidator.java
index 35e4fa22b..447047801 100644
--- a/samples/jaxp/InlineSchemaValidator.java
+++ b/samples/jaxp/InlineSchemaValidator.java
@@ -94,6 +94,9 @@ public class InlineSchemaValidator
/** Default schema language (http://www.w3.org/2001/XMLSchema). */
protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ /** XSD 1.1 schema language (http://www.w3.org/XML/XMLSchema/v1.1). */
+ protected static final String XSD11_SCHEMA_LANGUAGE = "http://www.w3.org/XML/XMLSchema/v1.1";
+
/** Default repetition (1). */
protected static final int DEFAULT_REPETITION = 1;
@@ -381,6 +384,10 @@ public class InlineSchemaValidator
}
continue;
}
+ if (option.equals("xsd11")) {
+ schemaLanguage = XSD11_SCHEMA_LANGUAGE;
+ continue;
+ }
if (option.equals("x")) {
if (++i == argv.length) {
System.err.println("error: Missing argument to -x option.");
@@ -659,6 +666,7 @@ public class InlineSchemaValidator
System.err.println(" -ga | -GA Turn on/off generation of synthetic schema annotations.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
System.err.println(" -m | -M Turn on/off memory usage report");
+ System.err.println(" -xsd11 Turn on XSD 1.1 support.");
System.err.println(" -h This help screen.");
System.err.println();
diff --git a/samples/jaxp/SourceValidator.java b/samples/jaxp/SourceValidator.java
index 504a262d5..153311a67 100644
--- a/samples/jaxp/SourceValidator.java
+++ b/samples/jaxp/SourceValidator.java
@@ -87,6 +87,18 @@ public class SourceValidator implements ErrorHandler {
/** Generate synthetic schema annotations feature id (http://apache.org/xml/features/generate-synthetic-annotations). */
protected static final String GENERATE_SYNTHETIC_ANNOTATIONS_ID = "http://apache.org/xml/features/generate-synthetic-annotations";
+ /** XSD 1.1 CTA full XPath 2.0 checking feature id (http://apache.org/xml/features/validation/cta-full-xpath-checking). */
+ protected static final String XS11_CTA_FULL_XPATH_CHECKING_ID = "http://apache.org/xml/features/validation/cta-full-xpath-checking";
+
+ /** SAX namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */
+ protected static final String SAX_NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes";
+
+ /** SAX namespace xmlns URIs feature id (http://xml.org/sax/features/xmlns-uris). */
+ protected static final String SAX_XMLNS_URIS_FEATURE_ID = "http://xml.org/sax/features/xmlns-uris";
+
+ /** XSD 1.1 assert comments and PI checking feature id (http://apache.org/xml/features/validation/assert-comments-and-pi-checking). */
+ protected static final String XS11_ASSERT_COMMENT_PI_CHECKING_ID = "http://apache.org/xml/features/validation/assert-comments-and-pi-checking";
+
// property ids
/** StAX support for reporting line and column numbers property id (javax.xml.stream.isSupportingLocationCoordinates). */
@@ -97,6 +109,9 @@ public class SourceValidator implements ErrorHandler {
/** Default schema language (http://www.w3.org/2001/XMLSchema). */
protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ /** XSD 1.1 schema language (http://www.w3.org/XML/XMLSchema/v1.1). */
+ protected static final String XSD11_SCHEMA_LANGUAGE = "http://www.w3.org/XML/XMLSchema/v1.1";
+
/** Default repetition (1). */
protected static final int DEFAULT_REPETITION = 1;
@@ -115,6 +130,18 @@ public class SourceValidator implements ErrorHandler {
/** Default generate synthetic schema annotations (false). */
protected static final boolean DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS = false;
+ /** Default sax namespace prefixes (true). */
+ protected static final boolean DEFAULT_SAX_NAMESPACE_PREFIXES = true;
+
+ /** Default sax xmlns uris (true). */
+ protected static final boolean DEFAULT_SAX_XMLNS_URIS = true;
+
+ /** Default XSD 1.1 CTA full XPath 2.0 checking (false). */
+ protected static final boolean DEFAULT_XS11_CTA_XPATH_FULL_CHECKING = false;
+
+ /** Default XSD 1.1 assert comments and PI checking (false). */
+ protected static final boolean DEFAULT_XS11_ASSERT_COMMENT_PI_CHECKING = false;
+
/** Default memory usage report (false). */
protected static final boolean DEFAULT_MEMORY_USAGE = false;
@@ -306,6 +333,10 @@ public class SourceValidator implements ErrorHandler {
boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS;
boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS;
boolean generateSyntheticAnnotations = DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS;
+ boolean saxNamespacePrefixes = DEFAULT_SAX_NAMESPACE_PREFIXES;
+ boolean saxXmlnsUris = DEFAULT_SAX_XMLNS_URIS;
+ boolean xs11CtaFullxpathchecking = DEFAULT_XS11_CTA_XPATH_FULL_CHECKING;
+ boolean xs11AssertCommentsAndPIchecking = DEFAULT_XS11_ASSERT_COMMENT_PI_CHECKING;
boolean memoryUsage = DEFAULT_MEMORY_USAGE;
// process arguments
@@ -323,6 +354,10 @@ public class SourceValidator implements ErrorHandler {
}
continue;
}
+ if (option.equals("xsd11")) {
+ schemaLanguage = XSD11_SCHEMA_LANGUAGE;
+ continue;
+ }
if (option.equals("x")) {
if (++i == argv.length) {
System.err.println("error: Missing argument to -x option.");
@@ -391,6 +426,14 @@ public class SourceValidator implements ErrorHandler {
generateSyntheticAnnotations = option.equals("ga");
continue;
}
+ if (option.equalsIgnoreCase("fx")) {
+ xs11CtaFullxpathchecking = option.equals("fx");
+ continue;
+ }
+ if (option.equalsIgnoreCase("acp")) {
+ xs11AssertCommentsAndPIchecking = option.equals("acp");
+ continue;
+ }
if (option.equalsIgnoreCase("m")) {
memoryUsage = option.equals("m");
continue;
@@ -449,6 +492,18 @@ public class SourceValidator implements ErrorHandler {
System.err.println("warning: SchemaFactory does not support feature ("+GENERATE_SYNTHETIC_ANNOTATIONS_ID+")");
}
+ if (XSD11_SCHEMA_LANGUAGE.equals(schemaLanguage)) {
+ try {
+ factory.setFeature(XS11_CTA_FULL_XPATH_CHECKING_ID, xs11CtaFullxpathchecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ System.err.println("warning: SchemaFactory does not recognize feature ("+XS11_CTA_FULL_XPATH_CHECKING_ID+")");
+ }
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: SchemaFactory does not support feature ("+XS11_CTA_FULL_XPATH_CHECKING_ID+")");
+ }
+ }
+
// Build Schema from sources
Schema schema;
if (schemas != null && schemas.size() > 0) {
@@ -503,14 +558,40 @@ public class SourceValidator implements ErrorHandler {
catch (SAXNotSupportedException e) {
System.err.println("warning: Validator does not support feature ("+GENERATE_SYNTHETIC_ANNOTATIONS_ID+")");
}
-
+
+ if (XSD11_SCHEMA_LANGUAGE.equals(schemaLanguage)) {
+ try {
+ validator.setFeature(XS11_CTA_FULL_XPATH_CHECKING_ID, xs11CtaFullxpathchecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ System.err.println("warning: Validator does not recognize feature ("+XS11_CTA_FULL_XPATH_CHECKING_ID+")");
+ }
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: Validator does not support feature ("+XS11_CTA_FULL_XPATH_CHECKING_ID+")");
+ }
+ }
+
+ if (XSD11_SCHEMA_LANGUAGE.equals(schemaLanguage)) {
+ try {
+ validator.setFeature(XS11_ASSERT_COMMENT_PI_CHECKING_ID, xs11AssertCommentsAndPIchecking);
+ }
+ catch (SAXNotRecognizedException e) {
+ System.err.println("warning: Validator does not recognize feature ("+XS11_ASSERT_COMMENT_PI_CHECKING_ID+")");
+ }
+ catch (SAXNotSupportedException e) {
+ System.err.println("warning: Validator does not support feature ("+XS11_ASSERT_COMMENT_PI_CHECKING_ID+")");
+ }
+ }
+
// Validate instance documents
if (instances != null && instances.size() > 0) {
final int length = instances.size();
if (validationSource.equals("sax")) {
// SAXSource
XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setErrorHandler(sourceValidator);
+ reader.setFeature(SAX_NAMESPACE_PREFIXES_FEATURE_ID, saxNamespacePrefixes);
+ reader.setFeature(SAX_XMLNS_URIS_FEATURE_ID, saxXmlnsUris);
+ reader.setErrorHandler(sourceValidator);
for (int j = 0; j < length; ++j) {
String systemId = (String) instances.elementAt(j);
SAXSource source = new SAXSource(reader, new InputSource(systemId));
@@ -585,32 +666,43 @@ public class SourceValidator implements ErrorHandler {
System.err.println(" -a uri ... Provide a list of schema documents");
System.err.println(" -i uri ... Provide a list of instance documents to validate");
System.err.println(" -vs source Select validation source (sax|dom|stax|stream)");
- System.err.println(" -f | -F Turn on/off Schema full checking.");
+ System.err.println(" -f | -F Turn on/off Schema full checking.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
- System.err.println(" -hs | -HS Turn on/off honouring of all schema locations.");
+ System.err.println(" -hs | -HS Turn on/off honouring of all schema locations.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
- System.err.println(" -va | -VA Turn on/off validation of schema annotations.");
+ System.err.println(" -va | -VA Turn on/off validation of schema annotations.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
- System.err.println(" -ga | -GA Turn on/off generation of synthetic schema annotations.");
+ System.err.println(" -ga | -GA Turn on/off generation of synthetic schema annotations.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
- System.err.println(" -m | -M Turn on/off memory usage report");
+ System.err.println(" -m | -M Turn on/off memory usage report");
+ System.err.println(" -xsd11 Turn on/off XSD 1.1 support.");
+ System.err.println(" -fx Turn on/off full XPath 2.0 checks with CTA when working");
+ System.err.println(" with XSD 1.1.");
+ System.err.println(" -acp Turn on/off assert comments and PI processing when working");
+ System.err.println(" with XSD 1.1.");
System.err.println(" -h This help screen.");
System.err.println();
System.err.println("defaults:");
- System.err.println(" Schema language: " + DEFAULT_SCHEMA_LANGUAGE);
- System.err.println(" Repetition: " + DEFAULT_REPETITION);
- System.err.println(" Validation source: " + DEFAULT_VALIDATION_SOURCE);
- System.err.print(" Schema full checking: ");
+ System.err.println(" Schema language: " + DEFAULT_SCHEMA_LANGUAGE);
+ System.err.println(" Repetition: " + DEFAULT_REPETITION);
+ System.err.println(" Validation source: " + DEFAULT_VALIDATION_SOURCE);
+ System.err.print(" Schema full checking: ");
System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
- System.err.print(" Honour all schema locations: ");
+ System.err.print(" Honour all schema locations: ");
System.err.println(DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS ? "on" : "off");
- System.err.print(" Validate annotations: ");
+ System.err.print(" Validate annotations: ");
System.err.println(DEFAULT_VALIDATE_ANNOTATIONS ? "on" : "off");
- System.err.print(" Generate synthetic annotations: ");
+ System.err.print(" Generate synthetic annotations: ");
System.err.println(DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS ? "on" : "off");
- System.err.print(" Memory: ");
+ System.err.print(" Memory: ");
System.err.println(DEFAULT_MEMORY_USAGE ? "on" : "off");
+ System.err.print(" XSD 1.1 [-xsd11 option]: ");
+ System.err.println("off");
+ System.err.print(" CTA XPath 2.0: ");
+ System.err.println(DEFAULT_XS11_CTA_XPATH_FULL_CHECKING ? "on" : "off");
+ System.err.print(" Assert comments and PI processing: ");
+ System.err.println(DEFAULT_XS11_ASSERT_COMMENT_PI_CHECKING ? "on" : "off");
System.err.println();
System.err.println("notes:");
diff --git a/samples/jaxp/TypeInfoWriter.java b/samples/jaxp/TypeInfoWriter.java
index a184ae78b..accf6c425 100644
--- a/samples/jaxp/TypeInfoWriter.java
+++ b/samples/jaxp/TypeInfoWriter.java
@@ -81,6 +81,9 @@ public class TypeInfoWriter
/** Default schema language (http://www.w3.org/2001/XMLSchema). */
protected static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ /** XSD 1.1 schema language (http://www.w3.org/XML/XMLSchema/v1.1). */
+ protected static final String XSD11_SCHEMA_LANGUAGE = "http://www.w3.org/XML/XMLSchema/v1.1";
+
/** Default parser name (org.apache.xerces.parsers.SAXParser). */
protected static final String DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
@@ -363,6 +366,10 @@ public class TypeInfoWriter
}
continue;
}
+ if (option.equals("xsd11")) {
+ schemaLanguage = XSD11_SCHEMA_LANGUAGE;
+ continue;
+ }
if (option.equals("p")) {
// get parser name
if (++i == argv.length) {
@@ -604,6 +611,7 @@ public class TypeInfoWriter
System.err.println(" NOTE: Not supported by all schema factories and validators.");
System.err.println(" -ga | -GA Turn on/off generation of synthetic schema annotations.");
System.err.println(" NOTE: Not supported by all schema factories and validators.");
+ System.err.println(" -xsd11 Turn on XSD 1.1 support.");
System.err.println(" -h This help screen.");
System.err.println();
diff --git a/samples/sax/Writer.java b/samples/sax/Writer.java
index b4f33792e..190bc760f 100644
--- a/samples/sax/Writer.java
+++ b/samples/sax/Writer.java
@@ -21,6 +21,7 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Method;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
@@ -31,7 +32,6 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.ParserAdapter;
import org.xml.sax.helpers.ParserFactory;
@@ -250,28 +250,21 @@ public class Writer
// Root Element
if (fElementDepth == 0) {
- String encoding = "UTF-8";
if (fLocator != null) {
- if (fLocator instanceof Locator2) {
- Locator2 locator2 = (Locator2) fLocator;
- fXML11 = "1.1".equals(locator2.getXMLVersion());
- encoding = locator2.getEncoding();
- if (encoding == null) {
- encoding = "UTF-8";
- }
- }
+ fXML11 = "1.1".equals(getVersion());
fLocator = null;
}
// The XML declaration cannot be printed in startDocument because
- // the version and encoding information reported by the Locator
- // cannot be relied on until the next event after startDocument.
+ // the version reported by the Locator cannot be relied on until after
+ // the XML declaration in the instance document has been read.
if (!fCanonical) {
- fOut.print("<?xml version=\"");
- fOut.print(fXML11 ? "1.1" : "1.0");
- fOut.print("\" encoding=\"");
- fOut.print(encoding);
- fOut.println("\"?>");
+ if (fXML11) {
+ fOut.println("<?xml version=\"1.1\" encoding=\"UTF-8\"?>");
+ }
+ else {
+ fOut.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ }
fOut.flush();
}
}
@@ -536,6 +529,27 @@ public class Writer
} // printError(String,SAXParseException)
+ /** Extracts the XML version from the Locator. */
+ protected String getVersion() {
+ if (fLocator == null) {
+ return null;
+ }
+ String version = null;
+ Method getXMLVersion = null;
+ try {
+ getXMLVersion = fLocator.getClass().getMethod("getXMLVersion", new Class[]{});
+ // If Locator implements Locator2, this method will exist.
+ if (getXMLVersion != null) {
+ version = (String) getXMLVersion.invoke(fLocator, (Object[]) null);
+ }
+ }
+ catch (Exception e) {
+ // Either this locator object doesn't have
+ // this method, or we're on an old JDK.
+ }
+ return version;
+ } // getVersion()
+
//
// Main
//
diff --git a/samples/xni/PSVIWriter.java b/samples/xni/PSVIWriter.java
index dc38d2bf1..7ec107c5b 100644
--- a/samples/xni/PSVIWriter.java
+++ b/samples/xni/PSVIWriter.java
@@ -1863,6 +1863,11 @@ public class PSVIWriter implements XMLComponent, XMLDocumentFilter {
} else {
sendIndentedElement("psv:substitutionGroupAffiliation");
processPSVIElementRef("psv:elementDeclaration", elem.getSubstitutionGroupAffiliation());
+// XSElementDeclaration[] subgroups = elem.getSubstitutionGroupAffiliations();
+// for (int i=0; i<subgroups.length; i++) {
+// XSElementDeclaration subgroup = subgroups[i];
+// processPSVIElementRef("psv:elementDeclaration", subgroup);
+// }
sendUnIndentedElement("psv:substitutionGroupAffiliation");
}
}
diff --git a/samples/xs/XSSerializer.java b/samples/xs/XSSerializer.java
new file mode 100644
index 000000000..91b491a7f
--- /dev/null
+++ b/samples/xs/XSSerializer.java
@@ -0,0 +1,1182 @@
+/*
+ * 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 xs;
+
+import java.io.StringReader;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
+import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XMLSchemaLoader;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
+import org.apache.xerces.impl.xs.XSAttributeDecl;
+import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
+import org.apache.xerces.impl.xs.XSComplexTypeDecl;
+import org.apache.xerces.impl.xs.XSElementDecl;
+import org.apache.xerces.impl.xs.XSGroupDecl;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
+import org.apache.xerces.impl.xs.XSWildcardDecl;
+import org.apache.xerces.impl.xs.identity.Field;
+import org.apache.xerces.impl.xs.identity.IdentityConstraint;
+import org.apache.xerces.impl.xs.identity.KeyRef;
+import org.apache.xerces.impl.xs.identity.Selector;
+import org.apache.xerces.impl.xs.util.XS11TypeHelper;
+import org.apache.xerces.xs.StringList;
+import org.apache.xerces.xs.XSAttributeUse;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSFacet;
+import org.apache.xerces.xs.XSIDCDefinition;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSModelGroup;
+import org.apache.xerces.xs.XSMultiValueFacet;
+import org.apache.xerces.xs.XSNamedMap;
+import org.apache.xerces.xs.XSObject;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSParticle;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTerm;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.apache.xerces.xs.XSValue;
+import org.apache.xerces.xs.XSWildcard;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+import org.xml.sax.InputSource;
+
+/**
+ * XSModel serialization utility.
+ * This utility serializes the Xerces XSModel instance into lexical, XSD syntax.
+ *
+ * @author Mukul Gandhi, IBM
+ * @version $Id$
+ */
+public class XSSerializer {
+
+ private static final String XSD_LANGUAGE_URI = SchemaSymbols.URI_SCHEMAFORSCHEMA;
+ private static final String XML_SCHEMA_VERSION = Constants.XERCES_PROPERTY_PREFIX + Constants.XML_SCHEMA_VERSION_PROPERTY;
+ private static String XSD_LANGUAGE_PREFIX = "xs:";
+
+
+ /*
+ * "Main method"
+ *
+ * An entry point to test this utility.
+ *
+ * The XSModel could be synthesized by various means (for example, by direct
+ * API calls to Xerces Schema API, methods) -- in which case, the method
+ * "serialize" will be used directly, passing in the XSModel object.
+ */
+ public static void main(String[] args) {
+
+ if (args.length == 0 || args.length > 5) {
+ printUsage();
+ System.exit(-1);
+ }
+
+ // the last command line argument must be a schema URI
+ String schemaUri = args[args.length - 1];
+
+ // iterate other command line arguments
+ String schemaVersion = null;
+ String schemaPrefix = null;
+ for (int argIndx = 0; argIndx < args.length - 1; argIndx += 2) {
+ if (args[argIndx].equals("-version")) {
+ schemaVersion = args[argIndx + 1];
+ }
+ else if (args[argIndx].equals("-prefix")) {
+ if (argIndx + 1 < args.length - 1) {
+ schemaPrefix = args[argIndx + 1];
+ }
+ }
+ }
+
+ XMLSchemaLoader xsLoader = new XMLSchemaLoader();
+ if ("1.1".equals(schemaVersion)) {
+ xsLoader.setProperty(XML_SCHEMA_VERSION, Constants.W3C_XML_SCHEMA11_NS_URI);
+ }
+ else if (schemaVersion != null && !"1.0".equals(schemaVersion)) {
+ printUsage();
+ System.exit(-1);
+ }
+
+ if (schemaPrefix != null) {
+ XSD_LANGUAGE_PREFIX = schemaPrefix + ":";
+ }
+
+ // construct the XSModel object from a schema document
+ XSModel xsModel = xsLoader.loadURI(schemaUri);
+
+ try {
+ // instantiate the serializer and invoke serialization method
+ XSSerializer xsSerializer = new XSSerializer();
+ xsSerializer.serialize(xsModel);
+ }
+ catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+ } // main
+
+
+ /*
+ * Print a diagnostic message, explaining how to invoke this sample.
+ */
+ private static void printUsage() {
+
+ System.err.println("Usage:");
+ System.err.println("java xs.XSSerializer [options] schema.xsd");
+ System.err.println("\nOptions:");
+ System.err.println("-version [1.0|1.1] XSD language level (default level is 1.0)");
+ System.err.println("-prefix <prefix> XSD language URI prefix (for e.g 'xs' or 'xsd'), for the serialized output");
+
+ } // printUsage
+
+
+ /*
+ * Serialize an XML Schema, XSModel object to the standard output.
+ */
+ public void serialize(XSModel xsModel) throws Exception {
+
+ //get DOM after conversion, from XSModel
+ Document xsdDocument = transformXSModelToDOMTree(xsModel);
+
+ // serialize the DOM to XML Schema document
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+ writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
+ LSOutput output = impl.createLSOutput();
+ output.setEncoding("UTF-8");
+ output.setByteStream(System.out);
+ writer.write(xsdDocument, output);
+
+ } // serialize
+
+
+ /*
+ * Transform an XML Schema, XSModel object into DOM document.
+ */
+ public Document transformXSModelToDOMTree(XSModel xsModel) throws Exception {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbf.newDocumentBuilder();
+ Document document = dBuilder.newDocument();
+
+ Element schemaDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_SCHEMA);
+
+ document.appendChild(schemaDeclDomNode);
+
+ // process global element declarations
+ XSNamedMap globalElemDecls = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+ processGlobalElementDecl(globalElemDecls, document, schemaDeclDomNode);
+
+ // process global complex type declarations
+ XSNamedMap globalComplexTypeDecls = xsModel.getComponents(XSTypeDefinition.COMPLEX_TYPE);
+ processGlobalComplexTypeDecl(globalComplexTypeDecls, document, schemaDeclDomNode);
+
+ // process global simple type declarations
+ XSNamedMap globalSimpleTypeDecls = xsModel.getComponents(XSTypeDefinition.SIMPLE_TYPE);
+ processGlobalSimpleTypeDecl(globalSimpleTypeDecls, document, schemaDeclDomNode);
+
+ // process global attribute declarations
+ XSNamedMap globalAttrDecls = xsModel.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
+ processGlobalAttrDecl(globalAttrDecls, document, schemaDeclDomNode);
+
+ // process global attribute group declarations
+ XSNamedMap globalAttrGroupDecls = xsModel.getComponents(XSConstants.ATTRIBUTE_GROUP);
+ processGlobalAttrGroupDecl(globalAttrGroupDecls, document, schemaDeclDomNode);
+
+ // process global model group declarations
+ XSNamedMap globalGroupDecls = xsModel.getComponents(XSConstants.MODEL_GROUP_DEFINITION);
+ processGlobalGroupDecl(globalGroupDecls, document, schemaDeclDomNode);
+
+ return document;
+
+ } // transformXSModelToDOMTree
+
+
+ /*
+ * Process global attribute group declarations.
+ */
+ private void processGlobalAttrGroupDecl(XSNamedMap globalAttrGpDecls, Document document, Element schemaDeclDomNode) {
+
+ // iterating global attribute group declarations in the Schema
+ for (int attrGpIdx = 0; attrGpIdx < globalAttrGpDecls.size(); attrGpIdx++) {
+ XSAttributeGroupDecl attrGpDecl = (XSAttributeGroupDecl) globalAttrGpDecls.item(attrGpIdx);
+ String attrGpName = attrGpDecl.getName();
+ Element attrGpDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_ATTRIBUTEGROUP);
+ attrGpDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, attrGpName);
+
+ // add annotation to attribute group
+ XSAnnotationImpl attrGpAnnotation = (XSAnnotationImpl) attrGpDecl.getAnnotation();
+ if (attrGpAnnotation != null) {
+ addAnnotationToSchemaComponent(document, attrGpDomNode, attrGpAnnotation);
+ }
+
+ XSObjectList attrUses = attrGpDecl.getAttributeUses();
+ for (int attrUsesIdx = 0; attrUsesIdx < attrUses.size(); attrUsesIdx++) {
+ XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(attrUsesIdx);
+ XSAttributeDecl attrDecl = (XSAttributeDecl) attrUse.getAttrDeclaration();
+ String constraintName = null;
+ String constraintVal = null;
+ if (attrUse.getConstraintType() != XSConstants.VC_NONE) {
+ constraintName = (attrUse.getConstraintType() == XSConstants.VC_DEFAULT) ? SchemaSymbols.ATT_DEFAULT : SchemaSymbols.ATT_FIXED;
+ XSValue xsConstraintVal = attrUse.getValueConstraintValue();
+ constraintVal = xsConstraintVal.getNormalizedValue();
+ }
+ String requiredVal = (attrUse.getRequired() == true) ? SchemaSymbols.ATTVAL_REQUIRED : SchemaSymbols.ATTVAL_OPTIONAL;
+ addAttributeToSchemaComponent(document, attrGpDomNode, attrDecl, constraintName, constraintVal, requiredVal);
+ }
+
+ // possible serialization of <anyAttribute/>
+ XSWildcard attrWildCard = attrGpDecl.getAttributeWildcard();
+ if (attrWildCard != null) {
+ addWildcardToSchemaComponent(document, attrGpDomNode, (XSWildcardDecl) attrWildCard, SchemaSymbols.ELT_ANYATTRIBUTE, null, null);
+ }
+
+ schemaDeclDomNode.appendChild(attrGpDomNode);
+ }
+
+ } // processGlobalAttrGroupDecl
+
+
+ /*
+ * Process global element declarations.
+ */
+ private void processGlobalElementDecl(XSNamedMap globalElemDecls, Document document, Element schemaDeclDomNode) throws DOMException {
+ // iterating global element declarations in the Schema
+ for (int elemIdx = 0; elemIdx < globalElemDecls.size(); elemIdx++) {
+ XSElementDecl elemDecl = (XSElementDecl) globalElemDecls.item(elemIdx);
+ addElementDeclToSchemaComponent(document, schemaDeclDomNode, elemDecl, null, null, true);
+ }
+ } // processGlobalElementDecl
+
+
+ /*
+ * Adding an element declaration to Schema component.
+ */
+ private void addElementDeclToSchemaComponent(Document document, Element parentDomNode, XSElementDecl elemDecl, String minOccurs, String maxOccurs, boolean isGlobal) throws DOMException {
+
+ String elemName = elemDecl.getName();
+ Element elemDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_ELEMENT);
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, elemName);
+
+ // add annotation to an element declaration
+ XSAnnotationImpl elemAnnotation = (XSAnnotationImpl) elemDecl.getAnnotation();
+ if (elemAnnotation != null) {
+ addAnnotationToSchemaComponent(document, elemDeclDomNode, elemAnnotation);
+ }
+
+ XSTypeDefinition typeDef = elemDecl.getTypeDefinition();
+ if (!typeDef.getAnonymous()) {
+ // handling a non-anonymous schema type
+ String typeName = typeDef.getName();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeDef.getNamespace())) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_TYPE, XSD_LANGUAGE_PREFIX + typeName);
+ }
+ else {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_TYPE, typeName);
+ }
+ }
+ else {
+ // handling an anonymous schema type
+ if (typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ XSSimpleTypeDecl simpleTypeDecl = (XSSimpleTypeDecl) typeDef;
+ processSimpleTypeContents(document, elemDeclDomNode, simpleTypeDecl, simpleTypeDecl.getName());
+ }
+ else if (typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+ processAnonComplexTypeOnElement(document, elemDeclDomNode, typeDef);
+ }
+ }
+
+ // add possible, minOccurs & maxOccurs attributes
+ if (!isGlobal) {
+ if (minOccurs != null) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_MINOCCURS, minOccurs);
+ }
+ if (maxOccurs != null) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_MAXOCCURS, maxOccurs);
+ }
+ }
+
+ // add "abstract" attribute to xs:element component, if applicable
+ if (elemDecl.getAbstract() == true) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_ABSTRACT, SchemaSymbols.ATTVAL_TRUE);
+ }
+
+ // add "block" attribute to xs:element component, if applicable
+ String blockVal = getElementBlockAttrValue(elemDecl);
+ if (!blockVal.equals("")) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_BLOCK, blockVal);
+ }
+
+ // add "nillable" attribute to xs:element component, if applicable
+ if (elemDecl.getNillable() == true) {
+ elemDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_NILLABLE, SchemaSymbols.ATTVAL_TRUE);
+ }
+
+ // add identity constraint definitions to an 'element declaration'
+ addIDConstraintsToElementDecl(document, elemDecl, elemDeclDomNode);
+
+ parentDomNode.appendChild(elemDeclDomNode);
+
+ } // addElementDeclToSchemaComponent
+
+
+ // construct value of the, "block" attribute for an element declaration.
+ private String getElementBlockAttrValue(XSElementDecl elemDecl) {
+
+ String blockVal = "";
+ boolean blockExt = false;
+ boolean blockRestr = false;
+ boolean blockSubst = false;
+ if (elemDecl.isDisallowedSubstitution(XSConstants.DERIVATION_EXTENSION) == true) {
+ blockExt = true;
+ }
+ if (elemDecl.isDisallowedSubstitution(XSConstants.DERIVATION_RESTRICTION) == true) {
+ blockRestr = true;
+ }
+ if (elemDecl.isDisallowedSubstitution(XSConstants.DERIVATION_SUBSTITUTION) == true) {
+ blockSubst = true;
+ }
+
+ if ((blockExt == true) && (blockRestr == true) && (blockSubst == true)) {
+ blockVal = SchemaSymbols.ATTVAL_POUNDALL;
+ }
+ else {
+ if (blockExt == true) {
+ blockVal = blockVal + SchemaSymbols.ATTVAL_EXTENSION;
+ }
+ if (blockRestr == true) {
+ blockVal = blockVal + " " + SchemaSymbols.ATTVAL_RESTRICTION;
+ }
+ if (blockSubst == true) {
+ blockVal = blockVal + " " + SchemaSymbols.ATTVAL_SUBSTITUTION;
+ }
+ }
+
+ return blockVal;
+
+ } // getElementBlockAttrValue
+
+
+ /*
+ * Add identity constraints to element declaration.
+ */
+ private void addIDConstraintsToElementDecl(Document document, XSElementDecl elemDecl, Element elemDeclDomNode) throws DOMException {
+
+ XSNamedMap idConstraintsMap = elemDecl.getIdentityConstraints();
+
+ // iterate all identity constraints on an element declaration
+ for (int idConsIdx = 0; idConsIdx < idConstraintsMap.getLength(); idConsIdx++) {
+ IdentityConstraint idCons = (IdentityConstraint) idConstraintsMap.item(idConsIdx);
+ String consType = null;
+ String idReferStr = null;
+ if (idCons.getCategory() == XSIDCDefinition.IC_UNIQUE) {
+ consType = SchemaSymbols.ELT_UNIQUE;
+ }
+ else if (idCons.getCategory() == XSIDCDefinition.IC_KEY) {
+ consType = SchemaSymbols.ELT_KEY;
+ }
+ else if (idCons.getCategory() == XSIDCDefinition.IC_KEYREF) {
+ consType = SchemaSymbols.ELT_KEYREF;
+ idReferStr = (((KeyRef) idCons).getKey()).getName();
+ }
+
+ Element idConsDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + consType);
+ String idConsName = idCons.getName();
+ idConsDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, idConsName);
+
+ if (idReferStr != null) {
+ idConsDomNode.setAttributeNS(null, SchemaSymbols.ATT_REFER, idReferStr);
+ }
+
+ // add annotation to an ID constraint
+ XSAnnotationImpl idConsAnnotation = (XSAnnotationImpl) idCons.getAnnotations().item(0);
+ if (idConsAnnotation != null) {
+ addAnnotationToSchemaComponent(document, idConsDomNode, idConsAnnotation);
+ }
+
+ Selector idSelector = idCons.getSelector();
+ String selectorXPathStr = idSelector.getXPath().toString();
+ Element selectorDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_SELECTOR);
+ selectorDomNode.setAttributeNS(null, SchemaSymbols.ATT_XPATH, selectorXPathStr);
+ idConsDomNode.appendChild(selectorDomNode);
+
+ for (int fieldIdx = 0; fieldIdx < idCons.getFieldCount(); fieldIdx++) {
+ Field field = idCons.getFieldAt(fieldIdx);
+ String fieldXpathStr = field.getXPath().toString();
+ Element fieldDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_FIELD);
+ fieldDomNode.setAttributeNS(null, SchemaSymbols.ATT_XPATH, fieldXpathStr);
+ idConsDomNode.appendChild(fieldDomNode);
+ }
+
+ elemDeclDomNode.appendChild(idConsDomNode);
+ }
+
+ } // addIDConstraintsToElementDecl
+
+
+ /*
+ * Process global complex type declarations.
+ */
+ private void processGlobalComplexTypeDecl(XSNamedMap globalComplexTypeDecls, Document document, Element schemaDeclDomNode) throws DOMException {
+
+ // iterating global complex type definitions in the Schema.
+ // leaving out built-in Schema type, "anyType" from iteration
+ for (int ctIdx = 0; ctIdx < globalComplexTypeDecls.size() - 1; ctIdx++) {
+ XSComplexTypeDecl complexTypeDecl = (XSComplexTypeDecl) globalComplexTypeDecls.item(ctIdx);
+ String ctName = complexTypeDecl.getName();
+ Element complxTypeDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_COMPLEXTYPE);
+ complxTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, ctName);
+
+ // add annotation to complex type
+ XSAnnotationImpl complexTypeAnnot = (XSAnnotationImpl) complexTypeDecl.getAnnotations().item(0);
+ if (complexTypeAnnot != null) {
+ addAnnotationToSchemaComponent(document, complxTypeDomNode, complexTypeAnnot);
+ }
+
+ addChildrenToComplexType(document, schemaDeclDomNode, complexTypeDecl, complxTypeDomNode);
+ }
+
+ } // processGlobalComplexTypeDecl
+
+
+ /*
+ * Process global simple type declarations.
+ */
+ private void processGlobalSimpleTypeDecl(XSNamedMap globalSimpleTypeDecls, Document document, Element schemaDeclDomNode) throws DOMException {
+ // iterating global simple types in the Schema
+ for (int stIdx = 0; stIdx < globalSimpleTypeDecls.size(); stIdx++) {
+ XSSimpleTypeDecl simpleTypeDecl = (XSSimpleTypeDecl) globalSimpleTypeDecls.item(stIdx);
+ // consider only user defined simple types
+ if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(simpleTypeDecl.getNamespace())) {
+ String stName = simpleTypeDecl.getName();
+ processSimpleTypeContents(document, schemaDeclDomNode, simpleTypeDecl, stName);
+ }
+ }
+ } // processGlobalSimpleTypeDecl
+
+
+ /*
+ * Processing Simple Type contents.
+ */
+ private void processSimpleTypeContents(Document document,Element parentDomNode, XSSimpleTypeDecl simpleTypeDecl, String stName) throws DOMException {
+
+ Element simpleTypeDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_SIMPLETYPE);
+ if (stName != null) {
+ simpleTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, stName);
+ }
+ parentDomNode.appendChild(simpleTypeDomNode);
+
+ // add annotation to a simple type
+ XSAnnotationImpl simpleTypeAnnotation = (XSAnnotationImpl) simpleTypeDecl.getAnnotations().item(0);
+ if (simpleTypeAnnotation != null) {
+ addAnnotationToSchemaComponent(document, simpleTypeDomNode, simpleTypeAnnotation);
+ }
+
+ if (simpleTypeDecl.getVariety() == XSSimpleTypeDefinition.VARIETY_ATOMIC) {
+ Element restrictionDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_RESTRICTION);
+ XSTypeDefinition baseType = simpleTypeDecl.getBaseType();
+ addRestrictionToSimpleContent(document, simpleTypeDecl, simpleTypeDomNode, restrictionDomNode, baseType);
+ }
+ else if (simpleTypeDecl.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
+ XSSimpleTypeDefinition listType = simpleTypeDecl.getItemType();
+ addListDeclToSimpleType(document, simpleTypeDomNode, listType);
+ }
+ else if (simpleTypeDecl.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
+ XSObjectList unionMemberTypes = simpleTypeDecl.getMemberTypes();
+ addUnionDeclToSimpleType(document, simpleTypeDomNode, unionMemberTypes);
+ }
+
+ } // processSimpleTypeContents
+
+
+ /*
+ * Add children to "xs:restriction" for simple contents.
+ */
+ private void addRestrictionToSimpleContent(Document document, XSTypeDefinition typeDefn, Element parentDomNode, Element restrictionDomNode, XSTypeDefinition baseType) throws DOMException {
+
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(baseType.getNamespace())) {
+ restrictionDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, XSD_LANGUAGE_PREFIX + baseType.getName());
+ }
+ else {
+ restrictionDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, baseType.getName());
+ }
+
+ // simple type definition to be used, to get the facets
+ XSSimpleTypeDefinition simpleTypeDefn = null;
+
+ if (typeDefn instanceof XSComplexTypeDefinition) {
+ XSComplexTypeDefinition complexTypeDefn = (XSComplexTypeDefinition) typeDefn;
+ simpleTypeDefn = complexTypeDefn.getSimpleType();
+
+ }
+ else {
+ simpleTypeDefn = (XSSimpleTypeDefinition) typeDefn;
+ }
+
+ // handling single-valued facets
+ XSObjectList facets = simpleTypeDefn.getFacets();
+ for (int facetIdx = 0; facetIdx < facets.getLength(); facetIdx++) {
+ XSFacet facet = (XSFacet) facets.item(facetIdx);
+ Element facetDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + getFacetName(facet.getFacetKind()));
+ facetDomNode.setAttributeNS(null, SchemaSymbols.ATT_VALUE, facet.getLexicalFacetValue());
+ restrictionDomNode.appendChild(facetDomNode);
+ }
+
+ // handling multi-valued Facets ("enumeration" or "pattern")
+ XSObjectList mvFacets = simpleTypeDefn.getMultiValueFacets();
+ for (int mvFacetIdx = 0; mvFacetIdx < mvFacets.getLength(); mvFacetIdx++) {
+ XSMultiValueFacet mvFacet = (XSMultiValueFacet) mvFacets.item(mvFacetIdx);
+ StringList facetValues = mvFacet.getLexicalFacetValues();
+ for (int facValIdex = 0; facValIdex < facetValues.getLength(); facValIdex++) {
+ String facetValue = (String) facetValues.get(facValIdex);
+ Element facetDomNode = null;
+ if (mvFacet.getFacetKind() == XSSimpleTypeDefinition.FACET_ENUMERATION) {
+ facetDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_ENUMERATION);
+ }
+ else if (mvFacet.getFacetKind() == XSSimpleTypeDefinition.FACET_PATTERN) {
+ facetDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_PATTERN);
+ }
+ facetDomNode.setAttributeNS(null, SchemaSymbols.ATT_VALUE, facetValue);
+ restrictionDomNode.appendChild(facetDomNode);
+ }
+ }
+
+ parentDomNode.appendChild(restrictionDomNode);
+
+ } // addRestrictionToSimpleContent
+
+
+ /*
+ * Process global attribute declarations.
+ */
+ private void processGlobalAttrDecl(XSNamedMap globalAttrDecls, Document document, Element schemaDeclDomNode) throws DOMException {
+
+ // iterating global attribute declarations in the Schema
+ for (int attrIdx = 0; attrIdx < globalAttrDecls.size(); attrIdx++) {
+ XSAttributeDecl attrDecl = (XSAttributeDecl) globalAttrDecls.item(attrIdx);
+ String constraintName = null;
+ String constraintVal = null;
+ if (attrDecl.getConstraintType() != XSConstants.VC_NONE) {
+ constraintName = (attrDecl.getConstraintType() == XSConstants.VC_DEFAULT) ? SchemaSymbols.ATT_DEFAULT : SchemaSymbols.ATT_FIXED;
+ constraintVal = attrDecl.getConstraintValue();
+ }
+ addAttributeToSchemaComponent(document, schemaDeclDomNode, attrDecl, constraintName, constraintVal, null);
+ }
+
+ } // processGlobalAttrDecl
+
+
+ /*
+ * Process global group declarations.
+ */
+ private void processGlobalGroupDecl(XSNamedMap globalGroupDecls, Document document, Element schemaDeclDomNode) {
+ // iterating global group declarations in the Schema
+ for (int groupIdx = 0; groupIdx < globalGroupDecls.size(); groupIdx++) {
+ XSGroupDecl groupDecl = (XSGroupDecl) globalGroupDecls.item(groupIdx);
+ addGroupChildToSchemaComponent(document, schemaDeclDomNode, groupDecl, true);
+ }
+ } // processGlobalGroupDecl
+
+
+ /*
+ * Add xs:group child to a Schema component.
+ */
+ private void addGroupChildToSchemaComponent(Document document, Element parentDomNode, XSGroupDecl groupDecl, boolean isGlobal) {
+
+ Element groupDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_GROUP);
+ // add annotation to a group declaration
+ XSAnnotationImpl groupAnnotation = (XSAnnotationImpl) groupDecl.getAnnotation();
+ if (groupAnnotation != null) {
+ addAnnotationToSchemaComponent(document, groupDeclDomNode, groupAnnotation);
+ }
+
+ if (isGlobal) {
+ String groupName = groupDecl.getName();
+ groupDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, groupName);
+ XSModelGroup modelGroup = groupDecl.getModelGroup();
+ if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
+ addCompositorOnSchemaComponent(document, groupDeclDomNode, modelGroup, SchemaSymbols.ELT_SEQUENCE, "1", "1");
+ }
+ else if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_CHOICE) {
+ addCompositorOnSchemaComponent(document, groupDeclDomNode, modelGroup, SchemaSymbols.ELT_CHOICE, "1", "1");
+ }
+ else if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_ALL) {
+ addAllCompositorOnComplexType(document, groupDeclDomNode, modelGroup, "1", "1");
+ }
+ }
+
+ parentDomNode.appendChild(groupDeclDomNode);
+
+ } // addGroupChildToSchemaComponent
+
+
+ /*
+ * Add attribute declaration to a Schema component (like xs:schema, xs:complexType etc).
+ */
+ private void addAttributeToSchemaComponent(Document document, Element parentDomNode, XSAttributeDecl attrDecl, String constraintName,
+ String constraintVal, String requiredVal) throws DOMException {
+
+ String attrName = attrDecl.getName();
+ Element attrDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_ATTRIBUTE);
+ attrDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_NAME, attrName);
+ parentDomNode.appendChild(attrDeclDomNode);
+
+ // add annotation to attribute declaration
+ XSAnnotationImpl attrAnnotation = (XSAnnotationImpl) attrDecl.getAnnotation();
+ if (attrAnnotation != null) {
+ addAnnotationToSchemaComponent(document, attrDeclDomNode, attrAnnotation);
+ }
+
+ if (constraintName != null) {
+ attrDeclDomNode.setAttributeNS(null, constraintName, constraintVal);
+ }
+
+ if (requiredVal != null) {
+ attrDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_USE, requiredVal);
+ }
+
+ XSTypeDefinition typeDef = attrDecl.getTypeDefinition();
+ if (!typeDef.getAnonymous()) {
+ // handling a non-anonymous schema type
+ String typeName = typeDef.getName();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeDef.getNamespace())) {
+ attrDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_TYPE, XSD_LANGUAGE_PREFIX + typeName);
+ }
+ else {
+ attrDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_TYPE, typeName);
+ }
+ }
+ else {
+ // handling an anonymous schema type
+ XSSimpleTypeDecl simpleTypeDecl = (XSSimpleTypeDecl) typeDef;
+ processSimpleTypeContents(document, attrDeclDomNode, simpleTypeDecl, simpleTypeDecl.getName());
+ }
+
+ } // addAttributeToSchemaComponent
+
+
+ /*
+ * Processing an "anonymous" complex type declaration, on an element.
+ */
+ private void processAnonComplexTypeOnElement(Document document, Element elemDeclDomNode, XSTypeDefinition typeDef) throws DOMException {
+
+ XSComplexTypeDecl complexTypeDecl = (XSComplexTypeDecl) typeDef;
+ Element complexTypeDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_COMPLEXTYPE);
+ // add annotation to a complex type
+ XSAnnotationImpl cmplxTypeAnnotation = (XSAnnotationImpl) complexTypeDecl.getAnnotations().item(0);
+ if (cmplxTypeAnnotation != null) {
+ addAnnotationToSchemaComponent(document, complexTypeDomNode, cmplxTypeAnnotation);
+ }
+
+ addChildrenToComplexType(document, elemDeclDomNode, complexTypeDecl, complexTypeDomNode);
+
+ } // processAnonComplexTypeOnElement
+
+
+ /*
+ * Add child content to complex type definition.
+ */
+ private void addChildrenToComplexType(Document document, Element parentDomNode, XSComplexTypeDecl complexTypeDecl, Element complexTypeDomNode) throws DOMException {
+
+ // add "abstract" & "mixed" attributes if applicable
+ boolean isAbstract = complexTypeDecl.getAbstract();
+ boolean isMixed = (complexTypeDecl.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED);
+ if (isAbstract) {
+ complexTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_ABSTRACT, SchemaSymbols.ATTVAL_TRUE);
+ }
+ if (isMixed) {
+ complexTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_MIXED, SchemaSymbols.ATTVAL_TRUE);
+ }
+
+ // add "block" attribute if applicable
+ short prohSubstitutions = complexTypeDecl.getProhibitedSubstitutions();
+ String prohSubsStr = "";
+ if (prohSubstitutions == (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION)) {
+ prohSubsStr = SchemaSymbols.ATTVAL_POUNDALL;
+ }
+ else if (prohSubstitutions == XSConstants.DERIVATION_EXTENSION) {
+ prohSubsStr = SchemaSymbols.ELT_EXTENSION;
+ }
+ else if (prohSubstitutions == XSConstants.DERIVATION_RESTRICTION) {
+ prohSubsStr = SchemaSymbols.ELT_RESTRICTION;
+ }
+ if (!prohSubsStr.equals("")) {
+ complexTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_BLOCK, prohSubsStr);
+ }
+
+ // add "final" attribute if applicable
+ short finalSet = complexTypeDecl.getFinalSet();
+ String finalStr = "";
+ if (finalSet == (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION)) {
+ finalStr = SchemaSymbols.ATTVAL_POUNDALL;
+ }
+ else if (finalSet == XSConstants.DERIVATION_EXTENSION) {
+ finalStr = SchemaSymbols.ELT_EXTENSION;
+ }
+ else if (finalSet == XSConstants.DERIVATION_RESTRICTION) {
+ finalStr = SchemaSymbols.ELT_RESTRICTION;
+ }
+ if (!finalStr.equals("")) {
+ complexTypeDomNode.setAttributeNS(null, SchemaSymbols.ATT_FINAL, finalStr);
+ }
+
+ parentDomNode.appendChild(complexTypeDomNode);
+
+ short derivationMethod = complexTypeDecl.getDerivationMethod();
+
+ if (complexTypeDecl.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) {
+ // add xs:simpleContent as child of xs:complexType
+ addSimpleContentToComplexType(document, complexTypeDomNode, complexTypeDecl);
+ }
+ else if ((derivationMethod == XSConstants.DERIVATION_RESTRICTION) || (derivationMethod == XSConstants.DERIVATION_EXTENSION)) {
+ if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(complexTypeDecl.getBaseType().getNamespace())) {
+ // add xs:complexContent as child of xs:complexType
+ addComplexContentToComplexType(document, complexTypeDomNode, complexTypeDecl, derivationMethod);
+ }
+ else {
+ XSParticle particle = complexTypeDecl.getParticle();
+ if (particle != null) {
+ processParticleFromComplexType(document, complexTypeDomNode, particle);
+ // add attributes to the complex type
+ addAttributesToComplexType(document, complexTypeDecl, complexTypeDomNode);
+ }
+ else {
+ addAttributesToComplexType(document, complexTypeDecl, complexTypeDomNode);
+ }
+ }
+ }
+
+ } // addChildrenToComplexType
+
+
+ /*
+ * Add xs:simpleContent as child of xs:complexType.
+ */
+ private void addSimpleContentToComplexType(Document document, Element complexTypeDomNode, XSComplexTypeDecl complexTypeDecl) {
+
+ Element simpleContentDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_SIMPLECONTENT);
+ if (complexTypeDecl.getDerivationMethod() == XSConstants.DERIVATION_RESTRICTION) {
+ Element simpleContentRestrDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_RESTRICTION);
+ XSTypeDefinition baseType = complexTypeDecl.getBaseType();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(baseType.getNamespace())) {
+ simpleContentRestrDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, XSD_LANGUAGE_PREFIX + baseType.getName());
+ }
+ else {
+ simpleContentRestrDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, baseType.getName());
+ }
+
+ addRestrictionToSimpleContent(document, complexTypeDecl, simpleContentDomNode, simpleContentRestrDomNode, complexTypeDecl.getBaseType());
+ addAttributesToComplexType(document, complexTypeDecl, simpleContentRestrDomNode);
+
+ simpleContentDomNode.appendChild(simpleContentRestrDomNode);
+ }
+ else if (complexTypeDecl.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
+ Element simpleContentExtDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_EXTENSION);
+ XSTypeDefinition baseType = complexTypeDecl.getBaseType();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(baseType.getNamespace())) {
+ simpleContentExtDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, XSD_LANGUAGE_PREFIX + baseType.getName());
+ }
+ else {
+ simpleContentExtDomNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, baseType.getName());
+ }
+ addAttributesToComplexType(document, complexTypeDecl, simpleContentExtDomNode);
+ simpleContentDomNode.appendChild(simpleContentExtDomNode);
+ }
+
+ complexTypeDomNode.appendChild(simpleContentDomNode);
+
+ } // addSimpleContentToComplexType
+
+
+ /*
+ * Add xs:complexContent as child of xs:complexType.
+ */
+ private void addComplexContentToComplexType(Document document, Element complexTypeDomNode, XSComplexTypeDecl complexTypeDecl, short derivationMethod) {
+
+ Element complexContentDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_COMPLEXCONTENT);
+ Element complexContentDerivationNode = null;
+ if (derivationMethod == XSConstants.DERIVATION_RESTRICTION) {
+ complexContentDerivationNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_RESTRICTION);
+ }
+ else if (derivationMethod == XSConstants.DERIVATION_EXTENSION) {
+ complexContentDerivationNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_EXTENSION);
+ }
+
+ if (complexContentDerivationNode != null) {
+ XSTypeDefinition baseType = complexTypeDecl.getBaseType();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(baseType.getNamespace())) {
+ complexContentDerivationNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, XSD_LANGUAGE_PREFIX + baseType.getName());
+ }
+ else {
+ complexContentDerivationNode.setAttributeNS(null, SchemaSymbols.ATT_BASE, baseType.getName());
+ }
+ complexContentDomNode.appendChild(complexContentDerivationNode);
+ }
+
+ XSParticle particle = complexTypeDecl.getParticle();
+ if (derivationMethod == XSConstants.DERIVATION_EXTENSION) {
+ XSTerm particleTerm = null;
+ if (particle != null) {
+ particleTerm = particle.getTerm();
+ XSModelGroupImpl modelGroup = (XSModelGroupImpl) particleTerm;
+ if (modelGroup.fParticles.length == 2) {
+ particle = modelGroup.fParticles[1];
+ }
+ }
+ }
+
+ if (particle != null) {
+ processParticleFromComplexType(document, complexContentDerivationNode, particle);
+ }
+
+ addAttributesToComplexType(document, complexTypeDecl, complexContentDerivationNode);
+
+ complexTypeDomNode.appendChild(complexContentDomNode);
+
+ } // addComplexContentToComplexType
+
+
+ /*
+ * Add attributes to the complex type.
+ */
+ private void addAttributesToComplexType(Document document, XSComplexTypeDecl complexTypeDecl, Element parentDomNode) throws DOMException {
+
+ // iterate all attributes on the complex type. all attributes on a complex type (from all-of
+ // it's xs:attribute & xs:attributeGroup declarations) are expanded, into an XSObjectList list.
+ XSObjectList attributeUses = complexTypeDecl.getAttributeUses();
+ for (int attrUsesIdx = 0; attrUsesIdx < attributeUses.getLength(); attrUsesIdx++) {
+ XSAttributeUse attrUse = (XSAttributeUse) attributeUses.item(attrUsesIdx);
+ String constraintName = null;
+ String constraintVal = null;
+ if (attrUse.getConstraintType() != XSConstants.VC_NONE) {
+ constraintName = (attrUse.getConstraintType() == XSConstants.VC_DEFAULT) ? SchemaSymbols.ATT_DEFAULT : SchemaSymbols.ATT_FIXED;
+ XSValue xsConstraintVal = attrUse.getValueConstraintValue();
+ constraintVal = xsConstraintVal.getNormalizedValue();
+ }
+
+ String requiredVal = (attrUse.getRequired() == true) ? SchemaSymbols.ATTVAL_REQUIRED : SchemaSymbols.ATTVAL_OPTIONAL;
+ XSAttributeDecl attrDecl = (XSAttributeDecl) attrUse.getAttrDeclaration();
+ XSComplexTypeDefinition enclosingCTDefn = attrDecl.getEnclosingCTDefinition();
+ boolean complexTypesIdentical = (enclosingCTDefn == null) ? false : XS11TypeHelper.isSchemaTypesIdentical(complexTypeDecl, enclosingCTDefn);
+ // do not add attributes, from the base type. they will be serialized as part of the base type serialization.
+ if (complexTypesIdentical) {
+ addAttributeToSchemaComponent(document, parentDomNode, attrDecl, constraintName, constraintVal, requiredVal);
+ }
+ }
+
+ // possible serialization of <anyAttribute/>
+ XSWildcard attrWildCard = complexTypeDecl.getAttributeWildcard();
+ if (attrWildCard != null) {
+ addWildcardToSchemaComponent(document, parentDomNode, (XSWildcardDecl) attrWildCard, SchemaSymbols.ELT_ANYATTRIBUTE, null, null);
+ }
+
+ } // addAttributesToComplexType
+
+
+ /*
+ * Processing a "particle" from a complex type.
+ */
+ private void processParticleFromComplexType(Document document, Element parentDomNode, XSParticle particle) throws DOMException {
+
+ XSTerm particleTerm = particle.getTerm();
+
+ if (particleTerm instanceof XSModelGroup) {
+ XSModelGroup modelGroup = (XSModelGroup) particleTerm;
+ String minOccurs = getMinOccursVal(particle);
+ String maxOccurs = getMaxOccursVal(particle);
+ if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
+ addCompositorOnSchemaComponent(document, parentDomNode, modelGroup, SchemaSymbols.ELT_SEQUENCE, minOccurs, maxOccurs);
+ }
+ else if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_CHOICE) {
+ addCompositorOnSchemaComponent(document, parentDomNode, modelGroup, SchemaSymbols.ELT_CHOICE, minOccurs, maxOccurs);
+ }
+ else if (modelGroup.getCompositor() == XSModelGroup.COMPOSITOR_ALL) {
+ addAllCompositorOnComplexType(document, parentDomNode, modelGroup, minOccurs, maxOccurs);
+ }
+ }
+
+ } // processParticleFromComplexType
+
+
+ /*
+ * Adding a "sequence" or "choice" compositor on a complex type.
+ */
+ private void addCompositorOnSchemaComponent(Document document, Element parentDomNode, XSModelGroup modelGroup, String compositor, String minOccurs, String maxOccurs) throws DOMException {
+
+ Element compositorDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + compositor);
+ // add minOccurs & maxOccurs attributes to the compositor root
+ if (minOccurs != null && !minOccurs.equals("1")) {
+ compositorDomNode.setAttributeNS(null, SchemaSymbols.ATT_MINOCCURS, minOccurs);
+ }
+ if (maxOccurs != null && !maxOccurs.equals("1")) {
+ compositorDomNode.setAttributeNS(null, SchemaSymbols.ATT_MAXOCCURS, maxOccurs);
+ }
+
+ XSObjectList compositorChildren = modelGroup.getParticles();
+ for (int seqIdx = 0; seqIdx < compositorChildren.getLength(); seqIdx++) {
+ XSObject seqItem = compositorChildren.item(seqIdx);
+ XSParticle compositorParticle = (XSParticle) seqItem;
+ String minOccursParticle = getMinOccursVal(compositorParticle);
+ String maxOccursParticle = getMaxOccursVal(compositorParticle);
+ XSTerm partclTerm = compositorParticle.getTerm();
+ if (partclTerm instanceof XSElementDeclaration) {
+ XSElementDecl elemDecl = (XSElementDecl) partclTerm;
+ addElementDeclToSchemaComponent(document, compositorDomNode, elemDecl, minOccursParticle, maxOccursParticle, false);
+ }
+ else if (partclTerm instanceof XSModelGroup) {
+ // recursively adding model groups
+ XSModelGroup partlModelGroup = (XSModelGroup) partclTerm;
+ if (partlModelGroup.getCompositor() == XSModelGroup.COMPOSITOR_CHOICE) {
+ addCompositorOnSchemaComponent(document, compositorDomNode, partlModelGroup, SchemaSymbols.ELT_CHOICE, minOccursParticle, maxOccursParticle);
+ }
+ else if (partlModelGroup.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
+ addCompositorOnSchemaComponent(document, compositorDomNode, partlModelGroup, SchemaSymbols.ELT_SEQUENCE, minOccursParticle, maxOccursParticle);
+ }
+ }
+ else if (partclTerm instanceof XSWildcard) {
+ addWildcardToSchemaComponent(document, compositorDomNode, (XSWildcardDecl) partclTerm, SchemaSymbols.ELT_ANY, minOccursParticle, maxOccursParticle);
+ }
+ }
+
+ parentDomNode.appendChild(compositorDomNode);
+
+ } // addCompositorOnSchemaComponent
+
+
+ /*
+ * Processing an "all" declaration on a complex type.
+ */
+ private void addAllCompositorOnComplexType(Document document, Element complxTypeDomNode, XSModelGroup modelGroup, String minOccurs, String maxOccurs) throws DOMException {
+
+ Element allDeclDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_ALL);
+ // add minOccurs & maxOccurs attributes to the compositor root
+ if (minOccurs != null && !minOccurs.equals("1")) {
+ allDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_MINOCCURS, minOccurs);
+ }
+ if (maxOccurs != null && !maxOccurs.equals("1")) {
+ allDeclDomNode.setAttributeNS(null, SchemaSymbols.ATT_MAXOCCURS, maxOccurs);
+ }
+
+ XSObjectList modelParticles = modelGroup.getParticles();
+ for (int prtclIdx = 0; prtclIdx < modelParticles.getLength(); prtclIdx++) {
+ XSParticle partclItem = (XSParticle) modelParticles.item(prtclIdx);
+ String minOccursParticle = getMinOccursVal(partclItem);
+ String maxOccursParticle = getMaxOccursVal(partclItem);
+ XSTerm partclTerm = partclItem.getTerm();
+ if (partclTerm instanceof XSElementDeclaration) {
+ addElementDeclToSchemaComponent(document, allDeclDomNode, (XSElementDecl) partclTerm, minOccursParticle, maxOccursParticle, false);
+ }
+ else if (partclTerm instanceof XSWildcard) {
+ XSWildcardDecl wildCardDecl = (XSWildcardDecl) partclTerm;
+ addWildcardToSchemaComponent(document, allDeclDomNode, wildCardDecl, SchemaSymbols.ELT_ANY, minOccursParticle, maxOccursParticle);
+ }
+ }
+
+ complxTypeDomNode.appendChild(allDeclDomNode);
+
+ } // addAllCompositorOnComplexType
+
+
+ /*
+ * Adding wild-card to a Schema component.
+ */
+ private void addWildcardToSchemaComponent(Document document, Element parentNode, XSWildcardDecl wildCardDecl, String wildCardType, String minOccurs, String maxOccurs) {
+ Element wildCardDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + wildCardType);
+ String processContentsVal = wildCardDecl.getProcessContentsAsString();
+ if (!processContentsVal.equals(SchemaSymbols.ATTVAL_STRICT)) {
+ wildCardDomNode.setAttributeNS(null, SchemaSymbols.ATT_PROCESSCONTENTS, processContentsVal);
+ }
+ if (minOccurs != null) {
+ wildCardDomNode.setAttributeNS(null, SchemaSymbols.ATT_MINOCCURS, minOccurs);
+ }
+ if (maxOccurs != null) {
+ wildCardDomNode.setAttributeNS(null, SchemaSymbols.ATT_MAXOCCURS, maxOccurs);
+ }
+ parentNode.appendChild(wildCardDomNode);
+ } // addWildcardToSchemaComponent
+
+
+ /*
+ * Add xs:list as child of xs:simpleType.
+ */
+ private void addListDeclToSimpleType(Document document, Element simpleTypeDomNode, XSSimpleTypeDefinition listType) {
+
+ Element listDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ELT_LIST);
+ simpleTypeDomNode.appendChild(listDomNode);
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(listType.getNamespace())) {
+ listDomNode.setAttributeNS(null, SchemaSymbols.ATT_ITEMTYPE, XSD_LANGUAGE_PREFIX + listType.getName());
+ }
+ else {
+ if (listType.getName() != null) {
+ listDomNode.setAttributeNS(null, SchemaSymbols.ATT_ITEMTYPE, listType.getName());
+ }
+ else {
+ // add xs:simpleType as child of, xs:list
+ XSSimpleTypeDecl simpleTypeDeclOfList = (XSSimpleTypeDecl) listType;
+ processSimpleTypeContents(document, listDomNode, simpleTypeDeclOfList, simpleTypeDeclOfList.getName());
+ }
+ }
+
+ } // addListDeclToSimpleType
+
+
+ /*
+ * Add xs:union as child of xs:simpleType.
+ */
+ private void addUnionDeclToSimpleType(Document document, Element simpleTypeDomNode, XSObjectList unionMemberTypes) {
+
+ Element unionDomNode = document.createElementNS(XSD_LANGUAGE_URI, XSD_LANGUAGE_PREFIX + SchemaSymbols.ATTVAL_UNION);
+ simpleTypeDomNode.appendChild(unionDomNode);
+
+ String memberTypesStr = "";
+ for (int unionTypeListIdx = 0; unionTypeListIdx < unionMemberTypes.getLength(); unionTypeListIdx++) {
+ XSSimpleTypeDecl memberType = (XSSimpleTypeDecl) unionMemberTypes.item(unionTypeListIdx);
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(memberType.getNamespace())) {
+ memberTypesStr = memberTypesStr + " " + XSD_LANGUAGE_PREFIX + memberType.getName();
+ }
+ else {
+ if (memberType.getName() != null) {
+ memberTypesStr = memberTypesStr + " " + memberType.getName();
+ }
+ else {
+ // add xs:simpleType as child of, xs:union
+ XSSimpleTypeDecl simpleTypeDeclOfUnion = (XSSimpleTypeDecl) memberType;
+ processSimpleTypeContents(document, unionDomNode, simpleTypeDeclOfUnion, simpleTypeDeclOfUnion.getName());
+ }
+ }
+ }
+
+ if (!memberTypesStr.equals("")) {
+ // discard a blank space character, at the beginning
+ memberTypesStr = memberTypesStr.substring(1);
+ unionDomNode.setAttributeNS(null, SchemaSymbols.ATT_MEMBERTYPES, memberTypesStr);
+ }
+
+ } // addUnionDeclToSimpleType
+
+
+ /*
+ * Add annotation to a schema component.
+ */
+ private void addAnnotationToSchemaComponent(Document document, Element parentDomNode, XSAnnotationImpl annotation) throws DOMException {
+
+ String annotString = annotation.getAnnotationString();
+ StringReader annotationReader = new StringReader(annotString);
+ InputSource annotationInputSrc = new InputSource(annotationReader);
+ DocumentBuilderFactory annotationDbf = DocumentBuilderFactory.newInstance();
+ Element annotationElement = null;
+ try {
+ DocumentBuilder annotationDb = annotationDbf.newDocumentBuilder();
+ Document annotationDom = annotationDb.parse(annotationInputSrc);
+ annotationElement = (Element) document.importNode(annotationDom.getDocumentElement(), true);
+ }
+ catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+ parentDomNode.appendChild(annotationElement);
+
+ } // addAnnotationToSchemaComponent
+
+
+ /*
+ * Get name of a facet given it's kind.
+ */
+ private String getFacetName(short facetKind) {
+
+ if (facetKind == XSSimpleTypeDefinition.FACET_MINEXCLUSIVE) {
+ return SchemaSymbols.ELT_MINEXCLUSIVE;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_MININCLUSIVE) {
+ return SchemaSymbols.ELT_MININCLUSIVE;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE) {
+ return SchemaSymbols.ELT_MAXEXCLUSIVE;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_MAXINCLUSIVE) {
+ return SchemaSymbols.ELT_MAXINCLUSIVE;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_TOTALDIGITS) {
+ return SchemaSymbols.ELT_TOTALDIGITS;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_FRACTIONDIGITS) {
+ return SchemaSymbols.ELT_FRACTIONDIGITS;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_LENGTH) {
+ return SchemaSymbols.ELT_LENGTH;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_MINLENGTH) {
+ return SchemaSymbols.ELT_MINLENGTH;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_MAXLENGTH) {
+ return SchemaSymbols.ELT_MAXLENGTH;
+ }
+ else if (facetKind == XSSimpleTypeDefinition.FACET_WHITESPACE) {
+ return SchemaSymbols.ELT_WHITESPACE;
+ }
+
+ // unreach
+ return null;
+
+ } // getFacetName
+
+
+ /*
+ * Given an XSD particle, get it's minOccurs value as a String.
+ */
+ private String getMinOccursVal(XSParticle particle) {
+ String minOccursStr = null;
+ int minOccurs = particle.getMinOccurs();
+ if (minOccurs != 1) {
+ minOccursStr = String.valueOf(minOccurs);
+ }
+ return minOccursStr;
+ } // getMinOccursVal
+
+
+ /*
+ * Given an XSD particle, get it's maxOccurs value as a String.
+ */
+ private String getMaxOccursVal(XSParticle particle) {
+ String maxOccursStr = null;
+ if (particle.getMaxOccursUnbounded()) {
+ maxOccursStr = SchemaSymbols.ATTVAL_UNBOUNDED;
+ }
+ else {
+ int maxOccurs = particle.getMaxOccurs();
+ if (maxOccurs != 1) {
+ maxOccursStr = String.valueOf(maxOccurs);
+ }
+ }
+ return maxOccursStr;
+ } // getMaxOccursVal
+
+} // class XSSerializer
diff --git a/src/org/apache/xerces/dom/ElementImpl.java b/src/org/apache/xerces/dom/ElementImpl.java
index 5f8d9750b..7bfa697f6 100644
--- a/src/org/apache/xerces/dom/ElementImpl.java
+++ b/src/org/apache/xerces/dom/ElementImpl.java
@@ -1023,7 +1023,7 @@ public class ElementImpl
return true;
}
-
+
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
diff --git a/src/org/apache/xerces/dom/NamedNodeMapImpl.java b/src/org/apache/xerces/dom/NamedNodeMapImpl.java
index 23a9f2241..b93a148d0 100644
--- a/src/org/apache/xerces/dom/NamedNodeMapImpl.java
+++ b/src/org/apache/xerces/dom/NamedNodeMapImpl.java
@@ -605,8 +605,8 @@ public class NamedNodeMapImpl
throws IOException, ClassNotFoundException {
in.defaultReadObject();
if (nodes != null) {
- // cast to Vector is required
- nodes = new ArrayList((Vector)nodes);
+ // cast to Vector is required
+ nodes = new ArrayList((Vector)nodes);
}
}
diff --git a/src/org/apache/xerces/dom/NodeImpl.java b/src/org/apache/xerces/dom/NodeImpl.java
index b5c3a8353..8d6fc5d13 100644
--- a/src/org/apache/xerces/dom/NodeImpl.java
+++ b/src/org/apache/xerces/dom/NodeImpl.java
@@ -1855,7 +1855,7 @@ public abstract class NodeImpl
}
}
- return true;
+ return true;
}
/**
diff --git a/src/org/apache/xerces/dom/PSVIElementNSImpl.java b/src/org/apache/xerces/dom/PSVIElementNSImpl.java
index 3a6aec259..f8addbf8f 100644
--- a/src/org/apache/xerces/dom/PSVIElementNSImpl.java
+++ b/src/org/apache/xerces/dom/PSVIElementNSImpl.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutputStream;
import org.apache.xerces.impl.dv.ValidatedInfo;
import org.apache.xerces.impl.xs.ElementPSVImpl;
+import org.apache.xerces.impl.xs.util.ObjectListImpl;
import org.apache.xerces.impl.xs.util.StringListImpl;
import org.apache.xerces.xs.ElementPSVI;
import org.apache.xerces.xs.ItemPSVI;
@@ -34,8 +35,10 @@ import org.apache.xerces.xs.XSElementDeclaration;
import org.apache.xerces.xs.XSModel;
import org.apache.xerces.xs.XSNotationDeclaration;
import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeAlternative;
import org.apache.xerces.xs.XSTypeDefinition;
import org.apache.xerces.xs.XSValue;
+import org.apache.xerces.xs.datatypes.ObjectList;
/**
* Element namespace implementation; stores PSVI element items.
@@ -106,6 +109,15 @@ public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
/** the schema information property */
protected XSModel fSchemaInformation = null;
+ /** inherited attributes */
+ protected ObjectList fInheritedAttributes = null;
+
+ /** failed assertions */
+ protected ObjectList fFailedAssertions = null;
+
+ /** type alternative **/
+ protected XSTypeAlternative fTypeAlternative = null;
+
//
// ElementPSVI methods
//
@@ -266,6 +278,40 @@ public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
return fSchemaInformation;
}
+ /**
+ * Inherited attributes.
+ *
+ * @return inherited attributes list, or an empty list
+ * if there are no inherited attributes.
+ */
+ public ObjectList getInheritedAttributes() {
+ if (fInheritedAttributes != null) {
+ return fInheritedAttributes;
+ }
+ return ObjectListImpl.EMPTY_LIST;
+ }
+
+ /**
+ * Failed assertions.
+ *
+ * @return failed assertions list, or an empty list
+ * if none of assertions failed.
+ */
+ public ObjectList getFailedAssertions() {
+ if (fFailedAssertions != null) {
+ return fFailedAssertions;
+ }
+ return ObjectListImpl.EMPTY_LIST;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.xerces.xs.ElementPSVI#getTypeAlternative()
+ */
+ public XSTypeAlternative getTypeAlternative() {
+ return fTypeAlternative;
+ }
+
/**
* Copy PSVI properties from another psvi item.
*
@@ -291,6 +337,9 @@ public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
}
this.fSpecified = elem.getIsSchemaSpecified();
this.fNil = elem.getNil();
+ this.fTypeAlternative = elem.getTypeAlternative();
+ this.fInheritedAttributes = elem.getInheritedAttributes();
+ this.fFailedAssertions = elem.getFailedAssertions();
}
/* (non-Javadoc)
diff --git a/src/org/apache/xerces/dom/ParentNode.java b/src/org/apache/xerces/dom/ParentNode.java
index f1c22364c..cd0ab6111 100644
--- a/src/org/apache/xerces/dom/ParentNode.java
+++ b/src/org/apache/xerces/dom/ParentNode.java
@@ -910,7 +910,7 @@ public abstract class ParentNode
return false;
}
- return true;
+ return true;
}
//
diff --git a/src/org/apache/xerces/impl/Constants.java b/src/org/apache/xerces/impl/Constants.java
index 2b4fb3eeb..c14c94a56 100644
--- a/src/org/apache/xerces/impl/Constants.java
+++ b/src/org/apache/xerces/impl/Constants.java
@@ -40,7 +40,9 @@ public final class Constants {
// Schema Versions:
public static final String W3C_XML_SCHEMA10_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0".intern();
-
+ public static final String W3C_XML_SCHEMA11_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.1".intern();
+ public static final String W3C_XML_SCHEMA10EX_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0EX".intern();
+
// sax features
/** SAX feature prefix ("http://xml.org/sax/features/"). */
@@ -296,7 +298,7 @@ public final class Constants {
public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris";
/** XInclude fixup language feature ("xinclude/fixup-language"). */
- public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language";
+ public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language";
/**
* Feature to ignore xsi:type attributes on elements during validation,
@@ -328,6 +330,15 @@ public final class Constants {
/** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */
public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking";
+
+ /** Feature to ignore errors caused by type alternatives */
+ public static final String TYPE_ALTERNATIVES_CHEKING_FEATURE = "validation/type-alternative-checking";
+
+ /** Feature to allow full XPath 2.0 checking for CTA processing */
+ public static final String CTA_FULL_XPATH_CHECKING_FEATURE = "validation/cta-full-xpath-checking";
+
+ /** Feature to allow if comments and PIs should be available in <assert> XDM trees */
+ public static final String ASSERT_COMMENT_PI_CHECKING_FEATURE = "validation/assert-comments-and-pi-checking";
/** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */
public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking";
@@ -430,9 +441,15 @@ public final class Constants {
/** Schema element declaration for the root element in a document ("validation/schema/root-element-declaration"). */
public static final String ROOT_ELEMENT_DECLARATION_PROPERTY = "validation/schema/root-element-declaration";
-
+
/** Schema element declaration for the root element in a document ("internal/validation/schema/dv-factory"). */
public static final String SCHEMA_DV_FACTORY_PROPERTY = "internal/validation/schema/dv-factory";
+
+ /** XML Schema version property ("validation/schema/version"). */
+ public static final String XML_SCHEMA_VERSION_PROPERTY ="validation/schema/version";
+
+ /** Datatype XML version property ("validation/schema/datatype-xml-version"). */
+ public static final String DATATYPE_XML_VERSION_PROPERTY = "validation/schema/datatype-xml-version";
// general constants
@@ -473,8 +490,19 @@ public final class Constants {
// Constant to enable Schema 1.1 support
public final static boolean SCHEMA_1_1_SUPPORT = false;
- public final static short SCHEMA_VERSION_1_0 = 1;
+ public final static short SCHEMA_VERSION_1_0 = 1;
public final static short SCHEMA_VERSION_1_0_EXTENDED = 2;
+ public final static short SCHEMA_VERSION_1_1 = 4;
+
+ // Constants to support XML Schema 1.1 conditional inclusion functionality
+ public final static short IS_TYPE = 0;
+ public final static short IS_FACET = 1;
+ public final static short TYPE_AND_FACET_AVAILABILITY = 2;
+ public final static short TYPE_AND_FACET_UNAVAILABILITY = 3;
+
+ // Constants to support Eclipse XPath 2.0 engine uses
+ public final static String XPATH2_NAMESPACE_CONTEXT = "XPATH2_NS_CONTEXT";
+ public final static String IS_CTA_EVALUATOR = "CTA-EVALUATOR";
// private
@@ -532,6 +560,9 @@ public final class Constants {
NAMESPACE_GROWTH_FEATURE,
TOLERATE_DUPLICATES_FEATURE,
STRINGS_INTERNED_FEATURE,
+ TYPE_ALTERNATIVES_CHEKING_FEATURE,
+ CTA_FULL_XPATH_CHECKING_FEATURE,
+ ASSERT_COMMENT_PI_CHECKING_FEATURE,
};
/** Xerces properties. */
@@ -557,6 +588,8 @@ public final class Constants {
ROOT_TYPE_DEFINITION_PROPERTY,
ROOT_ELEMENT_DECLARATION_PROPERTY,
SCHEMA_DV_FACTORY_PROPERTY,
+ XML_SCHEMA_VERSION_PROPERTY,
+ DATATYPE_XML_VERSION_PROPERTY
};
/** Empty enumeration. */
diff --git a/src/org/apache/xerces/impl/dv/ValidationContext.java b/src/org/apache/xerces/impl/dv/ValidationContext.java
index 30cf41f10..564ea6e9f 100644
--- a/src/org/apache/xerces/impl/dv/ValidationContext.java
+++ b/src/org/apache/xerces/impl/dv/ValidationContext.java
@@ -19,6 +19,8 @@ package org.apache.xerces.impl.dv;
import java.util.Locale;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper;
+
/**
* ValidationContext has all the information required for the
* validation of: id, idref, entity, notation, qname
@@ -60,4 +62,10 @@ public interface ValidationContext {
// Locale
public Locale getLocale();
+
+ // TypeValidatorHelper
+ public TypeValidatorHelper getTypeValidatorHelper();
+
+ // Datatype XML version
+ public short getDatatypeXMLVersion();
}
diff --git a/src/org/apache/xerces/impl/dv/XSFacets.java b/src/org/apache/xerces/impl/dv/XSFacets.java
index df72a8346..8a1e042d8 100644
--- a/src/org/apache/xerces/impl/dv/XSFacets.java
+++ b/src/org/apache/xerces/impl/dv/XSFacets.java
@@ -38,7 +38,17 @@ public class XSFacets {
* value of length facet.
*/
public int length;
+
+ /**
+ * value of maxScale facet.
+ */
+ public int maxScale;
+ /**
+ * value of minScale facet.
+ */
+ public int minScale;
+
/**
* value of minLength facet.
*/
@@ -53,6 +63,11 @@ public class XSFacets {
* value of whiteSpace facet.
*/
public short whiteSpace;
+
+ /**
+ * value of explicitTimezone facet.
+ */
+ public short explicitTimezone;
/**
* value of totalDigits facet.
@@ -102,7 +117,10 @@ public class XSFacets {
*/
public String minExclusive;
-
+ /*
+ * Vector containing reference to the assert facets. introduced in XML Schema 1.1
+ */
+ public Vector assertFacets;
public XSAnnotation lengthAnnotation;
public XSAnnotation minLengthAnnotation;
@@ -116,6 +134,12 @@ public class XSFacets {
public XSAnnotation maxExclusiveAnnotation;
public XSAnnotation minInclusiveAnnotation;
public XSAnnotation minExclusiveAnnotation;
+ public XSAnnotation maxScaleAnnotation; //XML Schema 1.1
+ public XSAnnotation minScaleAnnotation; //XML Schema 1.1
+ public XSAnnotation explicitTimezoneAnnotation; //XML schema 1.1
+
+ // the annotations of the assertions are stored in XSAssertImpl objects
+ // stored in the 'assertFacets' Vector.
public void reset(){
lengthAnnotation = null;
@@ -130,5 +154,9 @@ public class XSFacets {
maxExclusiveAnnotation = null;
minInclusiveAnnotation = null;
minExclusiveAnnotation = null;
+ assertFacets = null;
+ maxScaleAnnotation = null;//XML Schema 1.1
+ minScaleAnnotation = null;//XML Schema 1.1
+ explicitTimezoneAnnotation = null; //XML Schema 1.1
}
}
diff --git a/src/org/apache/xerces/impl/dv/XSSimpleType.java b/src/org/apache/xerces/impl/dv/XSSimpleType.java
index fb7e74a1a..97a1b7c8c 100644
--- a/src/org/apache/xerces/impl/dv/XSSimpleType.java
+++ b/src/org/apache/xerces/impl/dv/XSSimpleType.java
@@ -45,9 +45,22 @@ public interface XSSimpleType extends XSSimpleTypeDefinition {
public static final short WS_REPLACE = 1;
/** collapse the white spaces */
public static final short WS_COLLAPSE = 2;
-
+
+ /**
+ * constants defined for the value of 'explicitTimezone' facet.
+ * see <a href='http://www.w3.org/TR/xmlschema11-2/#rf-explicitTimezone'> XML Schema
+ * Part 2: Datatypes </a>
+ */
+
+ // optional the explicit timezone
+ public static final short ET_OPTIONAL = 0;
+ // required the explicit timezone
+ public static final short ET_REQUIRED = 1;
+ // prohibited the explicit timezone
+ public static final short ET_PROHIBITED = 2;
+
/**
- * Constant defined for the primitive built-in simple tpyes.
+ * Constant defined for the primitive built-in simple types.
* see <a href='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
* XML Schema Part 2: Datatypes </a>
*/
@@ -63,7 +76,7 @@ public interface XSSimpleType extends XSSimpleTypeDefinition {
public static final short PRIMITIVE_DOUBLE = 5;
/** "duration" type */
public static final short PRIMITIVE_DURATION = 6;
- /** "dataTime" type */
+ /** "dateTime" type */
public static final short PRIMITIVE_DATETIME = 7;
/** "time" type */
public static final short PRIMITIVE_TIME = 8;
@@ -151,7 +164,7 @@ public interface XSSimpleType extends XSSimpleTypeDefinition {
* @param context the validation context
* @exception InvalidDatatypeFacetException exception for invalid facet values.
*/
- public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
+ public void applyFacets(XSFacets facets, int presentFacet, int fixedFacet, ValidationContext context)
throws InvalidDatatypeFacetException;
/**
diff --git a/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java b/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
index c1f078f89..e874538fd 100644
--- a/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
@@ -62,10 +62,6 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
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()
-
// distinguishes between identity and equality for date/time values
// ie: two values representing the same "moment in time" but with different
@@ -93,6 +89,10 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
((DateTimeData)value2), true);
}//compare()
+ public boolean hasTimeZone(Object value){
+ return ((DateTimeData)value).hasTimeZone();
+ }
+
/**
* Compare algorithm described in dateDime (3.2.7).
* Duration datatype overwrites this method
@@ -408,22 +408,20 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
*
* @param data
*/
- protected void validateDateTime (DateTimeData data) {
+ protected void validateDateTime(DateTimeData data, boolean isSchema11Type) {
//REVISIT: should we throw an exception for not valid dates
// or reporting an error message should be sufficient?
-
- /**
- * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
- */
- if (!Constants.SCHEMA_1_1_SUPPORT && data.year==0 ) {
- throw new RuntimeException("The year \"0000\" is an illegal year value");
-
- }
-
+ /**
+ * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
+ */
+ if (!isSchema11Type && data.year==0 ) {
+ throw new RuntimeException("The year \"0000\" is an illegal year value");
+
+ }
+
if ( data.month<1 || data.month>12 ) {
throw new RuntimeException("The month must have values 1 to 12");
-
}
//validate days
diff --git a/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java b/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java
index 7e9bbeb7b..b31898644 100644
--- a/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java
@@ -30,11 +30,7 @@ import org.apache.xerces.impl.dv.ValidationContext;
* @version $Id$
*/
class AnyAtomicDV extends TypeValidator {
-
- public short getAllowedFacets() {
- return 0;
- }
-
+
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
return content;
}
diff --git a/src/org/apache/xerces/impl/dv/xs/AnySimpleDV.java b/src/org/apache/xerces/impl/dv/xs/AnySimpleDV.java
index a805db402..bdad262ca 100644
--- a/src/org/apache/xerces/impl/dv/xs/AnySimpleDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/AnySimpleDV.java
@@ -32,11 +32,6 @@ import org.apache.xerces.impl.dv.ValidationContext;
*/
public class AnySimpleDV extends TypeValidator {
- public short getAllowedFacets() {
- // anySimpleType doesn't allow any facet, not even whiteSpace
- return 0;
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
return content;
}
diff --git a/src/org/apache/xerces/impl/dv/xs/AnyURIDV.java b/src/org/apache/xerces/impl/dv/xs/AnyURIDV.java
index 31534fa0f..9ddbf9016 100644
--- a/src/org/apache/xerces/impl/dv/xs/AnyURIDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/AnyURIDV.java
@@ -43,28 +43,41 @@ public class AnyURIDV extends TypeValidator {
BASE_URI = uri;
}
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
// before we return string we have to make sure it is correct URI as per spec.
// for some types (string and derived), they just return the string itself
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- // check 3.2.17.c0 must: URI (rfc 2396/2723)
- try {
- if( content.length() != 0 ) {
- // encode special characters using XLink 5.4 algorithm
- final String encoded = encode(content);
- // Support for relative URLs
- // According to Java 1.1: URLs may also be specified with a
- // String and the URL object that it is related to.
- new URI(BASE_URI, encoded );
+ // According to XML Schema 1.1
+ //
+ // 3.3.17.1 Value Space
+ //
+ // The value space of anyURI is the set of finite-length sequences of
+ // zero or more characters (as defined in [XML]) that match the Char
+ // production from [XML].
+ //
+ // 3.3.17.2 Lexical Mapping
+ //
+ // The lexical space of anyURI is the set of finite-length sequences
+ // of zero or more characters (as defined in [XML]) that match the
+ // Char production from [XML].
+
+ // Only for XML Schema 1.0
+ if (!context.getTypeValidatorHelper().isXMLSchema11()) {
+ // check 3.2.17.c0 must: URI (rfc 2396/2723)
+ try {
+ if( content.length() != 0 ) {
+ // encode special characters using XLink 5.4 algorithm
+ final String encoded = encode(content);
+ // Support for relative URLs
+ // According to Java 1.1: URLs may also be specified with a
+ // String and the URL object that it is related to.
+ new URI(BASE_URI, encoded );
+ }
+ } catch (URI.MalformedURIException ex) {
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "anyURI"});
}
- } catch (URI.MalformedURIException ex) {
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "anyURI"});
}
- // REVISIT: do we need to return the new URI object?
+ // REVISIT - XML Schema 1.0: do we need to return the new URI object?
return content;
}
diff --git a/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java b/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java
index 274320ea5..2a03ee167 100644
--- a/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/Base64BinaryDV.java
@@ -34,10 +34,6 @@ import org.apache.xerces.impl.dv.util.ByteListImpl;
*/
public class Base64BinaryDV extends TypeValidator {
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
byte[] decoded = Base64.decode(content);
if (decoded == null)
diff --git a/src/org/apache/xerces/impl/dv/xs/BaseSchemaDVFactory.java b/src/org/apache/xerces/impl/dv/xs/BaseSchemaDVFactory.java
index 5627ba304..7ae1c4181 100644
--- a/src/org/apache/xerces/impl/dv/xs/BaseSchemaDVFactory.java
+++ b/src/org/apache/xerces/impl/dv/xs/BaseSchemaDVFactory.java
@@ -220,31 +220,31 @@ public abstract class BaseSchemaDVFactory extends SchemaDVFactory {
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;
+ /*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);
+ 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;
+ /*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);
+ 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;
+ /*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);
+ builtInTypes.put(NMTOKENS, nmtokensDV);*/
} //createBuiltInTypes()
/**
diff --git a/src/org/apache/xerces/impl/dv/xs/BooleanDV.java b/src/org/apache/xerces/impl/dv/xs/BooleanDV.java
index 56fdc96bd..d71045a3d 100644
--- a/src/org/apache/xerces/impl/dv/xs/BooleanDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/BooleanDV.java
@@ -32,10 +32,6 @@ import org.apache.xerces.impl.dv.ValidationContext;
*/
public class BooleanDV extends TypeValidator {
- public short getAllowedFacets() {
- return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE);
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
if ("false".equals(content) || "0".equals(content)) {
return Boolean.FALSE;
diff --git a/src/org/apache/xerces/impl/dv/xs/DateDV.java b/src/org/apache/xerces/impl/dv/xs/DateDV.java
index abe1d9b13..123691ef7 100644
--- a/src/org/apache/xerces/impl/dv/xs/DateDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DateDV.java
@@ -37,7 +37,7 @@ public class DateDV extends DateTimeDV {
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "date"});
}
@@ -51,7 +51,7 @@ public class DateDV extends DateTimeDV {
* @return normalized dateTime representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException {
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException {
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -60,7 +60,7 @@ public class DateDV extends DateTimeDV {
//validate and normalize
//REVISIT: do we need SchemaDateTimeException?
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java b/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
index fe739f85b..27774124a 100644
--- a/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
@@ -39,7 +39,7 @@ public class DateTimeDV extends AbstractDateTimeDV {
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "dateTime"});
}
@@ -53,7 +53,7 @@ public class DateTimeDV extends AbstractDateTimeDV {
* @return normalized dateTime representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException {
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException {
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -73,7 +73,7 @@ public class DateTimeDV extends AbstractDateTimeDV {
//validate and normalize
//REVISIT: do we need SchemaDateTimeException?
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/IDREFDV.java b/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java
similarity index 60%
copy from src/org/apache/xerces/impl/dv/xs/IDREFDV.java
copy to src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java
index c48696e85..2de45d973 100644
--- a/src/org/apache/xerces/impl/dv/xs/IDREFDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java
@@ -19,34 +19,32 @@ package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
-import org.apache.xerces.util.XMLChar;
/**
- * Represent the schema type "IDREF"
- *
- * @xerces.internal
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
+ * Validator for <dateTimeStamp> datatype (W3C Schema Datatypes)
*
+ * @xerces.internal
+ *
* @version $Id$
*/
-public class IDREFDV extends TypeValidator{
-
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
+public class DateTimeStampDV extends DateTimeDV {
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- if (!XMLChar.isValidNCName(content)) {
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
+ try{
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
+ } catch(Exception ex){
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "dateTimeStamp"});
}
- return content;
}
-
- public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
- context.addIdRef((String)value);
+
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException {
+ DateTimeData parsedDateTime = super.parse(str, isXMLSchema11);
+ if (parsedDateTime.utc == 0) {
+ throw new RuntimeException("dateTimeStamp must have timezone");
+ }
+ else {
+ return parsedDateTime;
+ }
}
-
-}//IDREF class
-
+
+}
diff --git a/src/org/apache/xerces/impl/dv/xs/DayDV.java b/src/org/apache/xerces/impl/dv/xs/DayDV.java
index c2073ae57..01190e92a 100644
--- a/src/org/apache/xerces/impl/dv/xs/DayDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DayDV.java
@@ -39,7 +39,7 @@ public class DayDV extends AbstractDateTimeDV {
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gDay"});
}
@@ -54,7 +54,7 @@ public class DayDV extends AbstractDateTimeDV {
* @return normalized date representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException {
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException {
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -78,7 +78,7 @@ public class DayDV extends AbstractDateTimeDV {
}
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/DecimalDV.java b/src/org/apache/xerces/impl/dv/xs/DecimalDV.java
index 32685f017..3575b8558 100644
--- a/src/org/apache/xerces/impl/dv/xs/DecimalDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DecimalDV.java
@@ -36,10 +36,6 @@ import org.apache.xerces.xs.datatypes.XSDecimal;
*/
public class DecimalDV extends TypeValidator {
- public final short getAllowedFacets(){
- return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try {
return new XDecimal(content);
diff --git a/src/org/apache/xerces/impl/dv/xs/DoubleDV.java b/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
index 61454bff6..c62e2ea4d 100644
--- a/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
@@ -19,6 +19,7 @@ package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper.TypeValidatorHelper1_1;
import org.apache.xerces.xs.datatypes.XSDouble;
/**
@@ -33,14 +34,10 @@ import org.apache.xerces.xs.datatypes.XSDouble;
*/
public class DoubleDV extends TypeValidator {
- 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()
-
//convert a String to Double form, we have to take care of cases specified in spec like INF, -INF and NaN
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- try{
- return new XDouble(content);
+ try {
+ return new XDouble(content, context.getTypeValidatorHelper() instanceof TypeValidatorHelper1_1);
} catch (NumberFormatException ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "double"});
}
@@ -79,11 +76,11 @@ public class DoubleDV extends TypeValidator {
private static final class XDouble implements XSDouble {
private final double value;
- public XDouble(String s) throws NumberFormatException {
+ public XDouble(String s, boolean isSchema11) throws NumberFormatException {
if (isPossibleFP(s)) {
value = Double.parseDouble(s);
}
- else if ( s.equals("INF") ) {
+ else if ( s.equals("INF") || (isSchema11 && s.equals("+INF"))) {
value = Double.POSITIVE_INFINITY;
}
else if ( s.equals("-INF") ) {
diff --git a/src/org/apache/xerces/impl/dv/xs/EntityDV.java b/src/org/apache/xerces/impl/dv/xs/EntityDV.java
index 8b268eb21..d5b58d91b 100644
--- a/src/org/apache/xerces/impl/dv/xs/EntityDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/EntityDV.java
@@ -17,8 +17,10 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
/**
@@ -33,12 +35,10 @@ import org.apache.xerces.util.XMLChar;
*/
public class EntityDV extends TypeValidator {
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- if (!XMLChar.isValidNCName(content)) {
+ final boolean valid = (context.getDatatypeXMLVersion() == Constants.XML_VERSION_1_0)
+ ? XMLChar.isValidNCName(content) : XML11Char.isXML11ValidNCName(content);
+ if (!valid) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
}
diff --git a/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java b/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java
new file mode 100644
index 000000000..663f81209
--- /dev/null
+++ b/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java
@@ -0,0 +1,219 @@
+/*
+ * 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 org.apache.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.dv.ValidatedInfo;
+import org.apache.xerces.impl.dv.xs.ListDV.ListData;
+import org.apache.xerces.xs.ShortList;
+import org.apache.xerces.xs.XSConstants;
+
+/**
+ * @xerces.internal
+ *
+ * @version $Id$
+ */
+public class EqualityHelper {
+
+ // private constructor
+ private EqualityHelper() {}
+
+ // public methods
+
+ /**
+ * Compare 2 actual values
+ */
+ public static boolean isEqual(Object value1, Object value2,
+ short value1Type, short value2Type,
+ ShortList typeList1, ShortList typeList2,
+ short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ return isEqual11(value1, value2, value1Type, value2Type, typeList1, typeList2);
+ }
+
+ return isEqual(value1, value2, value1Type, value2Type, typeList1, typeList2);
+ }
+
+ public static boolean isEqual(ValidatedInfo value1, ValidatedInfo value2, short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ return isEqual11(value1.actualValue, value2.actualValue,
+ value1.actualValueType, value2.actualValueType,
+ value1.itemValueTypes, value2.itemValueTypes);
+ }
+
+ return isEqual(value1.actualValue, value2.actualValue,
+ value1.actualValueType, value2.actualValueType,
+ value1.itemValueTypes, value2.itemValueTypes);
+ }
+
+ // private XML Schema 1.0 methods
+ private static boolean isEqual(Object value1, Object value2,
+ short value1Type, short value2Type,
+ ShortList typeList1, ShortList typeList2) {
+
+ if (!isTypeComparable(value1Type, value2Type, typeList1, typeList2)) {
+ return false;
+ }
+
+ if (value1 == value2) {
+ return true;
+ }
+
+ if (value1 == null || value2 == null) {
+ return false;
+ }
+
+ return value1.equals(value2);
+ }
+
+ private static boolean isTypeComparable(short type1, short type2,
+ ShortList typeList1, ShortList typeList2) {
+
+ final short primitiveType1 = convertToPrimitiveKind(type1);
+ final short primitiveType2 = convertToPrimitiveKind(type2);
+
+ // Same types
+ if (primitiveType1 == primitiveType2) {
+ if (primitiveType1 == XSConstants.LIST_DT) {
+ return isListTypeComparable(typeList1, typeList2);
+ }
+
+ return true;
+ }
+
+ // Different types
+ return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
+ primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
+ }
+
+ // private XML Schema 1.1 methods
+ private static boolean isEqual11(Object value1, Object value2,
+ short value1Type, short value2Type,
+ ShortList typeList1, ShortList typeList2) {
+
+ if (!isType11Comparable(value1Type, value2Type, typeList1, typeList2)) {
+ return false;
+ }
+
+ if (value1 == value2) {
+ return true;
+ }
+
+ if (value1 == null || value2 == null) {
+ return false;
+ }
+
+ if (value1 instanceof ListData) {
+ if (!(value2 instanceof ListData)) {
+ final ListData listData = (ListData) value1;
+ if (listData.getLength() != 1) {
+ return false;
+ }
+ value1 = listData.get(0);
+ }
+ }
+ else if (value2 instanceof ListData) {
+ final ListData listData = (ListData) value2;
+ if (listData.getLength() != 1) {
+ return false;
+ }
+ value2 = listData.get(0);
+ }
+
+ return value1.equals(value2);
+ }
+
+ private static boolean isType11Comparable(short type1, short type2,
+ ShortList typeList1, ShortList typeList2) {
+
+ final short primitiveType1 = convertToPrimitiveKind(type1);
+ final short primitiveType2 = convertToPrimitiveKind(type2);
+
+ // Same types
+ if (primitiveType1 == primitiveType2) {
+ if (primitiveType1 == XSConstants.LIST_DT) {
+ return isListTypeComparable(typeList1, typeList2);
+ }
+
+ return true;
+ }
+
+ // Different types
+ // Check singleton list vs atomic
+ if (primitiveType1 == XSConstants.LIST_DT) {
+ if (typeList1 == null || typeList1.getLength() != 1) {
+ return false;
+ }
+ return isType11Comparable(typeList1.item(0), primitiveType2, null, null);
+ }
+ else if (primitiveType2 == XSConstants.LIST_DT) {
+ if (typeList2 == null || typeList2.getLength() != 1) {
+ return false;
+ }
+ return isType11Comparable(primitiveType1, typeList2.item(0), null, null);
+ }
+
+ return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
+ primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
+ }
+
+ // Private common methods
+ private static short convertToPrimitiveKind(short valueType) {
+ /** Primitive datatypes. */
+ if (valueType <= XSConstants.NOTATION_DT) {
+ return valueType;
+ }
+ /** Types derived from string. */
+ if (valueType <= XSConstants.ENTITY_DT) {
+ return XSConstants.STRING_DT;
+ }
+ /** Types derived from decimal. */
+ if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
+ return XSConstants.DECIMAL_DT;
+ }
+
+ /** List datatypes */
+ if (valueType == XSConstants.LIST_DT || valueType == XSConstants.LISTOFUNION_DT) {
+ return XSConstants.LIST_DT;
+ }
+ /** Other types. */
+ return valueType;
+ }
+
+ private static boolean isListTypeComparable(ShortList typeList1, ShortList typeList2) {
+ final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0;
+ final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0;
+ if (typeList1Length != typeList2Length) {
+ return false;
+ }
+ for (int i = 0; i < typeList1Length; ++i) {
+ final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i));
+ final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i));
+ if (primitiveItem1 != primitiveItem2) {
+ if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
+ primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
+ continue;
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java b/src/org/apache/xerces/impl/dv/xs/ErrorDV.java
similarity index 80%
copy from src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java
copy to src/org/apache/xerces/impl/dv/xs/ErrorDV.java
index 7e9bbeb7b..df6391bb0 100644
--- a/src/org/apache/xerces/impl/dv/xs/AnyAtomicDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/ErrorDV.java
@@ -21,22 +21,18 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
/**
- * Represent the schema type "anyAtomicType"
+ * Represents the schema type "error"
*
- * @xerces.experimental
+ * @xerces.internal
*
- * @author Ankit Pasricha, IBM
+ * @author Mukul Gandhi, IBM
*
* @version $Id$
*/
-class AnyAtomicDV extends TypeValidator {
-
- public short getAllowedFacets() {
- return 0;
- }
-
+public class ErrorDV extends TypeValidator {
+
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- return content;
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "error"});
}
-
-} // class AnyAtomicDV
+
+} // class ErrorDV
diff --git a/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java b/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
index 110bd15bd..64c79318d 100644
--- a/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
+++ b/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
@@ -43,11 +43,15 @@ public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory {
final String DURATION = "duration";
final String YEARMONTHDURATION = "yearMonthDuration";
final String DAYTIMEDURATION = "dayTimeDuration";
+ final String ERROR = "error";
createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);
// add anyAtomicType
fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add error
+ fBuiltInTypes.put(ERROR, XSSimpleTypeDecl.fError);
// add 2 duration types
XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
diff --git a/src/org/apache/xerces/impl/dv/xs/FloatDV.java b/src/org/apache/xerces/impl/dv/xs/FloatDV.java
index ce5f98448..52b173e79 100644
--- a/src/org/apache/xerces/impl/dv/xs/FloatDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/FloatDV.java
@@ -19,6 +19,7 @@ package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper.TypeValidatorHelper1_1;
import org.apache.xerces.xs.datatypes.XSFloat;
/**
@@ -33,14 +34,10 @@ import org.apache.xerces.xs.datatypes.XSFloat;
*/
public class FloatDV extends TypeValidator {
- 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()
-
//convert a String to Float form, we have to take care of cases specified in spec like INF, -INF and NaN
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- try{
- return new XFloat(content);
+ try {
+ return new XFloat(content, context.getTypeValidatorHelper() instanceof TypeValidatorHelper1_1);
} catch (NumberFormatException ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "float"});
}
@@ -63,11 +60,11 @@ public class FloatDV extends TypeValidator {
private static final class XFloat implements XSFloat {
private final float value;
- public XFloat(String s) throws NumberFormatException {
+ public XFloat(String s, boolean isSchema11) throws NumberFormatException {
if (DoubleDV.isPossibleFP(s)) {
value = Float.parseFloat(s);
}
- else if ( s.equals("INF") ) {
+ else if ( s.equals("INF") || (isSchema11 && s.equals("+INF"))) {
value = Float.POSITIVE_INFINITY;
}
else if ( s.equals("-INF") ) {
diff --git a/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java b/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java
index 44591cb64..31ad9e37b 100644
--- a/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/HexBinaryDV.java
@@ -34,10 +34,6 @@ import org.apache.xerces.impl.dv.util.HexBin;
*/
public class HexBinaryDV extends TypeValidator {
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
byte[] decoded = HexBin.decode(content);
if (decoded == null)
diff --git a/src/org/apache/xerces/impl/dv/xs/IDDV.java b/src/org/apache/xerces/impl/dv/xs/IDDV.java
index bee86c81c..d1aa2d122 100644
--- a/src/org/apache/xerces/impl/dv/xs/IDDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/IDDV.java
@@ -17,8 +17,10 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
/**
@@ -33,12 +35,10 @@ import org.apache.xerces.util.XMLChar;
*/
public class IDDV extends TypeValidator{
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- if (!XMLChar.isValidNCName(content)) {
+ final boolean valid = (context.getDatatypeXMLVersion() == Constants.XML_VERSION_1_0)
+ ? XMLChar.isValidNCName(content) : XML11Char.isXML11ValidNCName(content);
+ if (!valid) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
}
return content;
diff --git a/src/org/apache/xerces/impl/dv/xs/IDREFDV.java b/src/org/apache/xerces/impl/dv/xs/IDREFDV.java
index c48696e85..94414173c 100644
--- a/src/org/apache/xerces/impl/dv/xs/IDREFDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/IDREFDV.java
@@ -17,8 +17,10 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
/**
@@ -33,12 +35,10 @@ import org.apache.xerces.util.XMLChar;
*/
public class IDREFDV extends TypeValidator{
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
- if (!XMLChar.isValidNCName(content)) {
+ final boolean valid = (context.getDatatypeXMLVersion() == Constants.XML_VERSION_1_0)
+ ? XMLChar.isValidNCName(content) : XML11Char.isXML11ValidNCName(content);
+ if (!valid) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "NCName"});
}
return content;
diff --git a/src/org/apache/xerces/impl/dv/xs/ListDV.java b/src/org/apache/xerces/impl/dv/xs/ListDV.java
index 88c6b4b8c..3bf4a3cf1 100644
--- a/src/org/apache/xerces/impl/dv/xs/ListDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/ListDV.java
@@ -35,10 +35,6 @@ import org.apache.xerces.xs.datatypes.ObjectList;
*/
public class ListDV extends TypeValidator{
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
// this method should never be called: XSSimpleTypeDecl is responsible for
// calling the item type for the convertion
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
diff --git a/src/org/apache/xerces/impl/dv/xs/MonthDV.java b/src/org/apache/xerces/impl/dv/xs/MonthDV.java
index 3e4259c7f..f88e90df3 100644
--- a/src/org/apache/xerces/impl/dv/xs/MonthDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/MonthDV.java
@@ -44,7 +44,7 @@ public class MonthDV extends AbstractDateTimeDV {
*/
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gMonth"});
}
@@ -58,7 +58,7 @@ public class MonthDV extends AbstractDateTimeDV {
* @return normalized date representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException{
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException{
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -87,7 +87,7 @@ public class MonthDV extends AbstractDateTimeDV {
}
}
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java b/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java
index 71a89f5f3..9b8210083 100644
--- a/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java
@@ -47,7 +47,7 @@ public class MonthDayDV extends AbstractDateTimeDV {
*/
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gMonthDay"});
}
@@ -61,7 +61,7 @@ public class MonthDayDV extends AbstractDateTimeDV {
* @return normalized date representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException{
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException{
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -90,7 +90,7 @@ public class MonthDayDV extends AbstractDateTimeDV {
}
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/PrecisionDecimalDV.java b/src/org/apache/xerces/impl/dv/xs/PrecisionDecimalDV.java
index 2a4002eda..af66f3337 100644
--- a/src/org/apache/xerces/impl/dv/xs/PrecisionDecimalDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/PrecisionDecimalDV.java
@@ -30,9 +30,9 @@ import org.apache.xerces.impl.dv.ValidationContext;
* @version $Id$
*/
class PrecisionDecimalDV extends TypeValidator {
-
- static class XPrecisionDecimal {
-
+
+ private static class XPrecisionDecimal {
+
// sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
int sign = 1;
// total digits. >= 1
@@ -42,36 +42,41 @@ class PrecisionDecimalDV extends TypeValidator {
// fraction digits when sign != 0
int fracDigits = 0;
//precision
- //int precision = 0;
+ int precision = 0;
// the string representing the integer part
String ivalue = "";
// the string representing the fraction part
String fvalue = "";
int pvalue = 0;
-
-
+
XPrecisionDecimal(String content) throws NumberFormatException {
if(content.equals("NaN")) {
- ivalue = content;
+ ivalue = "NaN";
sign = 0;
+ return;
}
- if(content.equals("+INF") || content.equals("INF") || content.equals("-INF")) {
- ivalue = content.charAt(0) == '+' ? content.substring(1) : content;
+ if(content.equals("+INF") || content.equals("INF")) {
+ ivalue = "INF";
+ return;
+ }
+ if(content.equals("-INF")) {
+ ivalue = "-INF";
return;
}
initD(content);
}
-
+
void initD(String content) throws NumberFormatException {
int len = content.length();
- if (len == 0)
+ if (len == 0) {
throw new NumberFormatException();
-
+ }
+
// these 4 variables are used to indicate where the integre/fraction
// parts start/end.
int intStart = 0, intEnd = 0, fracStart = 0, fracEnd = 0;
-
+
// Deal with leading sign symbol if present
if (content.charAt(0) == '+') {
// skip '+', so intStart should be 1
@@ -81,253 +86,302 @@ class PrecisionDecimalDV extends TypeValidator {
intStart = 1;
sign = -1;
}
-
+
// skip leading zeroes in integer part
int actualIntStart = intStart;
while (actualIntStart < len && content.charAt(actualIntStart) == '0') {
actualIntStart++;
}
-
+
// Find the ending position of the integer part
for (intEnd = actualIntStart; intEnd < len && TypeValidator.isDigit(content.charAt(intEnd)); intEnd++);
-
+
// Not reached the end yet
if (intEnd < len) {
// the remaining part is not ".DDD" or "EDDD" or "eDDD", error
- if (content.charAt(intEnd) != '.' && content.charAt(intEnd) != 'E' && content.charAt(intEnd) != 'e')
+ if (content.charAt(intEnd) != '.' && content.charAt(intEnd) != 'E' && content.charAt(intEnd) != 'e') {
throw new NumberFormatException();
-
- if(content.charAt(intEnd) == '.') {
+ }
+
+ if (content.charAt(intEnd) == '.') {
// fraction part starts after '.', and ends at the end of the input
fracStart = intEnd + 1;
-
+
// find location of E or e (if present)
// Find the ending position of the fracion part
for (fracEnd = fracStart;
- fracEnd < len && TypeValidator.isDigit(content.charAt(fracEnd));
- fracEnd++);
+ fracEnd < len && TypeValidator.isDigit(content.charAt(fracEnd));
+ fracEnd++);
+
+ fracDigits = fracEnd - fracStart;
+ if (fracDigits > 0) {
+ fvalue = content.substring(fracStart, fracEnd);
+ }
+ if (fracEnd < len) {
+ if (content.charAt(fracEnd) != 'E' && content.charAt(fracEnd) != 'e') {
+ throw new NumberFormatException();
+ }
+ if (content.charAt(fracEnd + 1) == '+') {
+ fracEnd++;
+ }
+ pvalue = Integer.parseInt(content.substring(fracEnd + 1, len));
+ }
}
else {
- pvalue = Integer.parseInt(content.substring(intEnd + 1, len));
+ final int increment = (content.charAt(intEnd + 1) == '+') ? 1 :0;
+ pvalue = Integer.parseInt(content.substring(intEnd + 1 + increment, len));
}
}
-
+
// no integer part, no fraction part, error.
- if (intStart == intEnd && fracStart == fracEnd)
+ if (intStart == intEnd && fracStart == fracEnd) {
throw new NumberFormatException();
-
- // ignore trailing zeroes in fraction part
- /*while (fracEnd > fracStart && content.charAt(fracEnd-1) == '0') {
- fracEnd--;
- }*/
-
- // check whether there is non-digit characters in the fraction part
- for (int fracPos = fracStart; fracPos < fracEnd; fracPos++) {
- if (!TypeValidator.isDigit(content.charAt(fracPos)))
- throw new NumberFormatException();
}
-
+
intDigits = intEnd - actualIntStart;
- fracDigits = fracEnd - fracStart;
-
if (intDigits > 0) {
ivalue = content.substring(actualIntStart, intEnd);
+ totalDigits = intDigits + fracDigits;
}
-
- if (fracDigits > 0) {
- fvalue = content.substring(fracStart, fracEnd);
- if(fracEnd < len) {
- pvalue = Integer.parseInt(content.substring(fracEnd + 1, len));
+ else {
+ totalDigits = fracDigits;
+ for (int i = 0; i < fracDigits; i++,totalDigits--) {
+ if (fvalue.charAt(i) != '0') {
+ break;
+ }
+ }
+ if (totalDigits == 0) {
+ totalDigits = 1;
}
}
- totalDigits = intDigits + fracDigits;
+
+ precision = fracDigits - pvalue;
}
-
-
+
public boolean equals(Object val) {
- if (val == this)
+ if (val == this) {
return true;
-
- if (!(val instanceof XPrecisionDecimal))
+ }
+
+ if (!(val instanceof XPrecisionDecimal)) {
return false;
- XPrecisionDecimal oval = (XPrecisionDecimal)val;
-
+ }
+
+ final XPrecisionDecimal oval = (XPrecisionDecimal)val;
+ if (sign == 0 && oval.sign == 0) {
+ // Both are NaN. Treat as "equal".
+ return true;
+ }
return this.compareTo(oval) == EQUAL;
}
-
+
/**
* @return
*/
private int compareFractionalPart(XPrecisionDecimal oval) {
- if(fvalue.equals(oval.fvalue))
+ if (fvalue.equals(oval.fvalue)) {
return EQUAL;
-
+ }
+
StringBuffer temp1 = new StringBuffer(fvalue);
StringBuffer temp2 = new StringBuffer(oval.fvalue);
-
+
truncateTrailingZeros(temp1, temp2);
return temp1.toString().compareTo(temp2.toString());
}
-
+
private void truncateTrailingZeros(StringBuffer fValue, StringBuffer otherFValue) {
- for(int i = fValue.length() - 1;i >= 0; i--)
- if(fValue.charAt(i) == '0')
+ for (int i = fValue.length() - 1;i >= 0; i--) {
+ if (fValue.charAt(i) == '0') {
fValue.deleteCharAt(i);
- else
+ }
+ else {
break;
-
- for(int i = otherFValue.length() - 1;i >= 0; i--)
- if(otherFValue.charAt(i) == '0')
+ }
+ }
+
+ for (int i = otherFValue.length() - 1;i >= 0; i--) {
+ if(otherFValue.charAt(i) == '0') {
otherFValue.deleteCharAt(i);
- else
+ }
+ else {
break;
+ }
+ }
}
-
+
public int compareTo(XPrecisionDecimal val) {
-
// seen NaN
- if(sign == 0)
+ if (sign == 0 || val.sign == 0) {
return INDETERMINATE;
-
+ }
+
//INF is greater than everything and equal to itself
- if(ivalue.equals("INF") || val.ivalue.equals("INF")) {
- if(ivalue.equals(val.ivalue))
+ if (ivalue.equals("INF") || val.ivalue.equals("INF")) {
+ if (ivalue.equals(val.ivalue)) {
return EQUAL;
- else if(ivalue.equals("INF"))
+ }
+ else if (ivalue.equals("INF")) {
return GREATER_THAN;
+ }
return LESS_THAN;
}
-
+
//-INF is smaller than everything and equal itself
- if(ivalue.equals("-INF") || val.ivalue.equals("-INF")) {
- if(ivalue.equals(val.ivalue))
+ if (ivalue.equals("-INF") || val.ivalue.equals("-INF")) {
+ if (ivalue.equals(val.ivalue)) {
return EQUAL;
- else if(ivalue.equals("-INF"))
+ }
+ else if (ivalue.equals("-INF")) {
return LESS_THAN;
+ }
return GREATER_THAN;
}
-
- if (sign != val.sign)
+
+ if (sign != val.sign) {
+ // Return equal if both are 0
+ if (isZero() && val.isZero()) {
+ return EQUAL;
+ }
return sign > val.sign ? GREATER_THAN : LESS_THAN;
-
+ }
+
return sign * compare(val);
}
-
+ private boolean isZero() {
+ // Either "000" or "0.00"
+ return totalDigits == 1 && intDigits == 0 &&
+ (fracDigits == 0 || fvalue.charAt(fracDigits-1) == '0');
+ }
+
// To enable comparison - the exponent part of the decimal will be limited
// to the max value of int.
- private int compare(XPrecisionDecimal val) {
-
- if(pvalue != 0 || val.pvalue != 0) {
- if(pvalue == val.pvalue)
- return intComp(val);
- else {
-
- if(intDigits + pvalue != val.intDigits + val.pvalue)
- return intDigits + pvalue > val.intDigits + val.pvalue ? GREATER_THAN : LESS_THAN;
-
- //otherwise the 2 combined values are the same
- if(pvalue > val.pvalue) {
- int expDiff = pvalue - val.pvalue;
- StringBuffer buffer = new StringBuffer(ivalue);
- StringBuffer fbuffer = new StringBuffer(fvalue);
- for(int i = 0;i < expDiff; i++) {
- if(i < fracDigits) {
- buffer.append(fvalue.charAt(i));
- fbuffer.deleteCharAt(i);
- }
- else
- buffer.append('0');
- }
- return compareDecimal(buffer.toString(), val.ivalue, fbuffer.toString(), val.fvalue);
+ private int compare(XPrecisionDecimal val) {
+ if (pvalue == val.pvalue) {
+ return intComp(val);
+ }
+ else if (pvalue > val.pvalue) {
+ int expDiff = pvalue - val.pvalue;
+ StringBuffer buffer = new StringBuffer(ivalue);
+ StringBuffer fbuffer = new StringBuffer(fvalue);
+ for(int i = 0;i < expDiff; i++) {
+ if (i < fracDigits) {
+ buffer.append(fvalue.charAt(i));
+ fbuffer.deleteCharAt(0);
}
- else {
- int expDiff = val.pvalue - pvalue;
- StringBuffer buffer = new StringBuffer(val.ivalue);
- StringBuffer fbuffer = new StringBuffer(val.fvalue);
- for(int i = 0;i < expDiff; i++) {
- if(i < val.fracDigits) {
- buffer.append(val.fvalue.charAt(i));
- fbuffer.deleteCharAt(i);
- }
- else
- buffer.append('0');
- }
- return compareDecimal(ivalue, buffer.toString(), fvalue, fbuffer.toString());
+ else {
+ buffer.append('0');
}
}
+ // remove leading zeroes in integer part
+ while (buffer.length() > 0 && buffer.charAt(0) == '0') buffer.deleteCharAt(0);
+ return compareDecimal(buffer.toString(), fbuffer.toString(), val.ivalue, val.fvalue);
}
else {
- return intComp(val);
- }
+ int expDiff = val.pvalue - pvalue;
+ StringBuffer buffer = new StringBuffer(val.ivalue);
+ StringBuffer fbuffer = new StringBuffer(val.fvalue);
+ for(int i = 0;i < expDiff; i++) {
+ if (i < val.fracDigits) {
+ buffer.append(val.fvalue.charAt(i));
+ fbuffer.deleteCharAt(0);
+ }
+ else {
+ buffer.append('0');
+ }
+ }
+ // remove leading zeroes in integer part
+ while (buffer.length() > 0 && buffer.charAt(0) == '0') buffer.deleteCharAt(0);
+ return compareDecimal(ivalue, fvalue, buffer.toString(), fbuffer.toString());
+ }
}
-
+
/**
* @param val
* @return
*/
private int intComp(XPrecisionDecimal val) {
- if (intDigits != val.intDigits)
+ if (intDigits != val.intDigits) {
return intDigits > val.intDigits ? GREATER_THAN : LESS_THAN;
-
- return compareDecimal(ivalue, val.ivalue, fvalue, val.fvalue);
+ }
+
+ return compareDecimal(ivalue, fvalue, val.ivalue, val.fvalue);
}
-
+
/**
* @param val
* @return
*/
- private int compareDecimal(String iValue, String fValue, String otherIValue, String otherFValue) {
+ private int compareDecimal(String iValue, String fValue, String otherIValue, String otherFValue) {
+ if (iValue.length() != otherIValue.length()) {
+ return iValue.length() > otherIValue.length() ? GREATER_THAN : LESS_THAN;
+ }
+
int ret = iValue.compareTo(otherIValue);
- if (ret != 0)
+ if (ret != 0) {
return ret > 0 ? GREATER_THAN : LESS_THAN;
+ }
- if(fValue.equals(otherFValue))
+ if (fValue.equals(otherFValue)) {
return EQUAL;
-
- StringBuffer temp1=new StringBuffer(fValue);
- StringBuffer temp2=new StringBuffer(otherFValue);
-
+ }
+
+ final StringBuffer temp1 = new StringBuffer(fValue);
+ final StringBuffer temp2 = new StringBuffer(otherFValue);
truncateTrailingZeros(temp1, temp2);
ret = temp1.toString().compareTo(temp2.toString());
return ret == 0 ? EQUAL : (ret > 0 ? GREATER_THAN : LESS_THAN);
}
-
+
private String canonical;
-
public synchronized String toString() {
if (canonical == null) {
makeCanonical();
}
return canonical;
}
-
+
private void makeCanonical() {
- // REVISIT: to be determined by working group
- canonical = "TBD by Working Group";
+ // REVISIT
+
+ // A workaround for now
+ if (ivalue.equals("INF") || ivalue.equals("-INF") || ivalue.equals("NaN")) {
+ canonical = ivalue;
+ }
+ else {
+ final StringBuffer tempBuf = new StringBuffer();
+ if (intDigits > 0) {
+ tempBuf.append(ivalue);
+ }
+ if (fracDigits > 0) {
+ tempBuf.append('.');
+ tempBuf.append(fvalue);
+ }
+ if (pvalue != 0) {
+ tempBuf.append('E');
+ tempBuf.append(pvalue);
+ }
+ canonical = tempBuf.toString();
+ }
}
-
+
/**
* @param decimal
* @return
*/
public boolean isIdentical(XPrecisionDecimal decimal) {
- if(ivalue.equals(decimal.ivalue) && (ivalue.equals("INF") || ivalue.equals("-INF") || ivalue.equals("NaN")))
+ if (ivalue.equals(decimal.ivalue) && (ivalue.equals("INF") || ivalue.equals("-INF") || ivalue.equals("NaN"))) {
return true;
+ }
- if(sign == decimal.sign && intDigits == decimal.intDigits && fracDigits == decimal.fracDigits && pvalue == decimal.pvalue
- && ivalue.equals(decimal.ivalue) && fvalue.equals(decimal.fvalue))
+ if (sign == decimal.sign && intDigits == decimal.intDigits && fracDigits == decimal.fracDigits && pvalue == decimal.pvalue
+ && ivalue.equals(decimal.ivalue) && fvalue.equals(decimal.fvalue)) {
return true;
+ }
return false;
}
-
}
- /* (non-Javadoc)
- * @see org.apache.xerces.impl.dv.xs.TypeValidator#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 | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
- }
-
+
/* (non-Javadoc)
* @see org.apache.xerces.impl.dv.xs.TypeValidator#getActualValue(java.lang.String, org.apache.xerces.impl.dv.ValidationContext)
*/
@@ -339,22 +393,29 @@ class PrecisionDecimalDV extends TypeValidator {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "precisionDecimal"});
}
}
-
+
public int compare(Object value1, Object value2) {
return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
}
-
- public int getFractionDigits(Object value) {
- return ((XPrecisionDecimal)value).fracDigits;
- }
-
+
public int getTotalDigits(Object value) {
return ((XPrecisionDecimal)value).totalDigits;
}
-
+
public boolean isIdentical(Object value1, Object value2) {
- if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
+ if (!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal)) {
return false;
+ }
return ((XPrecisionDecimal)value1).isIdentical((XPrecisionDecimal)value2);
}
+
+ public int getPrecision(Object value){
+ return ((XPrecisionDecimal)value).precision;
+ }
+
+ public boolean hasPrecision(Object value){
+ XPrecisionDecimal pd = (XPrecisionDecimal)value;
+ // Can't be NaN (sign==0) or +-INF. != is OK. See initD().
+ return pd.sign != 0 && pd.ivalue != "INF" && pd.ivalue != "-INF";
+ }
}
diff --git a/src/org/apache/xerces/impl/dv/xs/QNameDV.java b/src/org/apache/xerces/impl/dv/xs/QNameDV.java
index 1ea256058..4b2bc8b04 100644
--- a/src/org/apache/xerces/impl/dv/xs/QNameDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/QNameDV.java
@@ -17,8 +17,10 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xs.datatypes.XSQName;
@@ -37,10 +39,6 @@ public class QNameDV extends TypeValidator {
private static final String EMPTY_STRING = "".intern();
- public short getAllowedFacets() {
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE);
- }
-
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
@@ -56,12 +54,17 @@ public class QNameDV extends TypeValidator {
localpart = content;
}
- // both prefix (if any) a nd localpart must be valid NCName
- if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix))
+ final boolean isXML10 = context.getDatatypeXMLVersion() == Constants.XML_VERSION_1_0;
+
+ // both prefix (if any) and localpart must be valid NCName
+ // if using XSD 1.1, use the XML 1.1 rules of validating the prefix and the local part, else use the XML 1.0 rules
+ if (prefix.length() > 0 && ((isXML10) ? !XMLChar.isValidNCName(prefix) : !XML11Char.isXML11ValidNCName(prefix))) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
+ }
- if(!XMLChar.isValidNCName(localpart))
+ if ((isXML10) ? !XMLChar.isValidNCName(localpart) : !XML11Char.isXML11ValidNCName(localpart)) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "QName"});
+ }
// resove prefix to a uri, report an error if failed
String uri = context.getURI(prefix);
diff --git a/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java b/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
similarity index 54%
copy from src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
copy to src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
index 110bd15bd..6224d4a87 100644
--- a/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
+++ b/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
@@ -17,6 +17,7 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.util.SymbolHash;
@@ -30,7 +31,7 @@ import org.apache.xerces.util.SymbolHash;
*
* @version $Id$
*/
-public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory {
+public class Schema11DVFactoryImpl extends BaseSchemaDVFactory {
static SymbolHash fBuiltInTypes = new SymbolHash();
static {
@@ -43,16 +44,60 @@ public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory {
final String DURATION = "duration";
final String YEARMONTHDURATION = "yearMonthDuration";
final String DAYTIMEDURATION = "dayTimeDuration";
-
+ final String PRECISIONDECIMAL = "precisionDecimal";
+ final String ERROR = "error";
+ final String DATETIMESTAMP = "dateTimeStamp";
+ final String DATETIME = "dateTime";
+ final String ENTITIES = "ENTITIES";
+ final String ENTITY = "ENTITY";
+ final String NMTOKENS = "NMTOKENS";
+ final String NMTOKEN = "NMTOKEN";
+ final String IDREFS = "IDREFS";
+ final String IDREF = "IDREF";
+
createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);
// add anyAtomicType
fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add error
+ fBuiltInTypes.put(ERROR, XSSimpleTypeDecl.fError);
+
+ // In XML Schema 1.1, ENTITIES, NMTOKENS, IDREFS have anySimpleType
+ // as the base type
+ final XSFacets facets = new XSFacets();
+ facets.minLength = 1;
+ facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
+
+ // add ENTITIES
+ final XSSimpleTypeDecl entityDV = (XSSimpleTypeDecl)fBuiltInTypes.get(ENTITY);
+ final XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, entityDV, false, null);
+ entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH | XSSimpleType.FACET_WHITESPACE, (short)0);
+ fBuiltInTypes.put(ENTITIES, entitiesDV);
+
+ // add NMTOKENS
+ final XSSimpleTypeDecl nmtokenDV = (XSSimpleTypeDecl)fBuiltInTypes.get(NMTOKEN);
+ final XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, false, null);
+ nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH | XSSimpleType.FACET_WHITESPACE, (short)0);
+ fBuiltInTypes.put(NMTOKENS, nmtokensDV);
+
+ // add IDREFS
+ final XSSimpleTypeDecl idrefDV = (XSSimpleTypeDecl)fBuiltInTypes.get(IDREF);
+ final XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(IDREFS, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, false, null);
+ idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH | XSSimpleType.FACET_WHITESPACE, (short)0);
+ fBuiltInTypes.put(IDREFS, idrefsDV);
// 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));
+
+ //add dateTimeStamp
+ XSSimpleTypeDecl dateTimeDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DATETIME);
+ fBuiltInTypes.put(DATETIMESTAMP, new XSSimpleTypeDecl(dateTimeDV, DATETIMESTAMP, XSSimpleTypeDecl.DV_DATETIMESTAMP, XSSimpleTypeDecl.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DATETIMESTAMP_DT));
+
+ // add precision decimal
+ fBuiltInTypes.put(PRECISIONDECIMAL, new XSSimpleTypeDecl(XSSimpleTypeDecl.fAnyAtomicType, PRECISIONDECIMAL, XSSimpleTypeDecl.DV_PRECISIONDECIMAL, XSSimpleType.ORDERED_PARTIAL, false, false, true, true, XSSimpleTypeDecl.PRECISIONDECIMAL_DT));
} //createBuiltInTypes()
/**
diff --git a/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java b/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
index 09a1d60c2..76dcca07f 100644
--- a/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
+++ b/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
@@ -17,17 +17,17 @@
package org.apache.xerces.impl.dv.xs;
+import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.util.SymbolHash;
/**
- * the factory to create/return built-in schema 1.0 DVs and create user-defined DVs
+ * the 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$
*/
@@ -41,8 +41,39 @@ public class SchemaDVFactoryImpl extends BaseSchemaDVFactory {
// create all built-in types
static void createBuiltInTypes() {
- createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnySimpleType);
-
+ final String ENTITIES = "ENTITIES";
+ final String ENTITY = "ENTITY";
+ final String NMTOKENS = "NMTOKENS";
+ final String NMTOKEN = "NMTOKEN";
+ final String IDREFS = "IDREFS";
+ final String IDREF = "IDREF";
+
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnySimpleType);
+
+ XSFacets facets = new XSFacets();
+ facets.minLength = 1;
+
+ // add ENTITIES
+ final XSSimpleTypeDecl entityDV = (XSSimpleTypeDecl)fBuiltInTypes.get(ENTITY);
+ XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null);
+ final XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ fBuiltInTypes.put(ENTITIES, entitiesDV);
+
+ // add NMTOKENS
+ final XSSimpleTypeDecl nmtokenDV = (XSSimpleTypeDecl)fBuiltInTypes.get(NMTOKEN);
+ tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null);
+ final XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ fBuiltInTypes.put(NMTOKENS, nmtokensDV);
+
+ // add IDREFS
+ final XSSimpleTypeDecl idrefDV = (XSSimpleTypeDecl)fBuiltInTypes.get(IDREF);
+ tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
+ final XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
+ idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
+ fBuiltInTypes.put(IDREFS, idrefsDV);
+
// TODO: move specific 1.0 DV implementation from base
} //createBuiltInTypes()
diff --git a/src/org/apache/xerces/impl/dv/xs/StringDV.java b/src/org/apache/xerces/impl/dv/xs/StringDV.java
index 543615124..2ff1e5055 100644
--- a/src/org/apache/xerces/impl/dv/xs/StringDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/StringDV.java
@@ -32,10 +32,6 @@ import org.apache.xerces.impl.dv.ValidationContext;
*/
public class StringDV extends TypeValidator {
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
return content;
diff --git a/src/org/apache/xerces/impl/dv/xs/TimeDV.java b/src/org/apache/xerces/impl/dv/xs/TimeDV.java
index 10d4880b0..f8e1112e1 100644
--- a/src/org/apache/xerces/impl/dv/xs/TimeDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/TimeDV.java
@@ -43,7 +43,7 @@ public class TimeDV extends AbstractDateTimeDV {
*/
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "time"});
}
@@ -58,7 +58,7 @@ public class TimeDV extends AbstractDateTimeDV {
* @return normalized time representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException{
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException{
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -71,14 +71,19 @@ public class TimeDV extends AbstractDateTimeDV {
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
+
+ // reset back day
+ date.day = 15;
//save unnormalized values
saveUnnormalized(date);
if ( date.utc!=0 && date.utc != 'Z') {
normalize(date);
- date.day = 15;
+ if (!isXMLSchema11) {
+ date.day = 15;
+ }
}
date.position = 2;
return date;
diff --git a/src/org/apache/xerces/impl/dv/xs/TypeValidator.java b/src/org/apache/xerces/impl/dv/xs/TypeValidator.java
index 2a645a20f..e29f42271 100644
--- a/src/org/apache/xerces/impl/dv/xs/TypeValidator.java
+++ b/src/org/apache/xerces/impl/dv/xs/TypeValidator.java
@@ -48,9 +48,6 @@ public abstract class TypeValidator {
return Boolean.FALSE;
}}) == Boolean.TRUE;
- // which facets are allowed for this type
- public abstract short getAllowedFacets();
-
// convert a string to an actual value. for example,
// for number types (decimal, double, float, and types derived from them),
// get the BigDecimal, Double, Flout object.
@@ -144,4 +141,19 @@ public abstract class TypeValidator {
return isDigit(ch) ? ch - '0' : -1;
}
+ //get the number of precision of the value
+ //the parameters are in compiled form (from getActualValue)
+ public int getPrecision(Object value){
+ return 0;
+ }
+
+ //whether this value has a precision. false indicate it's a special value.
+ public boolean hasPrecision(Object value){
+ return false;
+ }
+
+ public boolean hasTimeZone(Object value){
+ return false;
+ }
+
} // interface TypeValidator
diff --git a/src/org/apache/xerces/impl/dv/xs/TypeValidatorHelper.java b/src/org/apache/xerces/impl/dv/xs/TypeValidatorHelper.java
new file mode 100644
index 000000000..edfb6d0c7
--- /dev/null
+++ b/src/org/apache/xerces/impl/dv/xs/TypeValidatorHelper.java
@@ -0,0 +1,197 @@
+/*
+ * 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 org.apache.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.Constants;
+
+/**
+ * @xerces.internal
+ *
+ * @version $Id$
+ */
+public abstract class TypeValidatorHelper {
+
+ // Constants
+ private static int FACETS_GROUP1 = XSSimpleTypeDecl.FACET_NONE;
+
+ private static int FACETS_GROUP2 = XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE;
+
+ private static int FACETS_GROUP3 = FACETS_GROUP2 | XSSimpleTypeDecl.FACET_LENGTH |
+ XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
+ XSSimpleTypeDecl.FACET_ENUMERATION;
+
+ private static int FACETS_GROUP4 = FACETS_GROUP2 | XSSimpleTypeDecl.FACET_ENUMERATION |
+ XSSimpleTypeDecl.FACET_MAXINCLUSIVE | XSSimpleTypeDecl.FACET_MININCLUSIVE |
+ XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE;
+
+ private static int FACETS_GROUP5 = FACETS_GROUP4 | XSSimpleTypeDecl.FACET_TOTALDIGITS |
+ XSSimpleTypeDecl.FACET_FRACTIONDIGITS;
+
+ private static int FACETS_GROUP6 = XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION;
+
+ private static int FACETS_GROUP7 = FACETS_GROUP2 | XSSimpleTypeDecl.FACET_ASSERT;
+
+ private static int FACETS_GROUP8 = FACETS_GROUP3 | XSSimpleTypeDecl.FACET_ASSERT;
+
+ private static int FACETS_GROUP9 = FACETS_GROUP4 | XSSimpleTypeDecl.FACET_ASSERT;
+
+ private static int FACETS_GROUP10 = FACETS_GROUP9 | XSSimpleTypeDecl.FACET_EXPLICITTIMEZONE;
+
+ private static int FACETS_GROUP11 = FACETS_GROUP5 | XSSimpleTypeDecl.FACET_ASSERT;
+
+ private static int FACETS_GROUP12 = FACETS_GROUP6 | XSSimpleTypeDecl.FACET_ASSERT;
+
+ private static int FACETS_GROUP13 = FACETS_GROUP4 | XSSimpleTypeDecl.FACET_TOTALDIGITS |
+ XSSimpleTypeDecl.FACET_ASSERT | XSSimpleTypeDecl.FACET_MAXSCALE | XSSimpleTypeDecl.FACET_MINSCALE;
+
+ // Static data
+ private static final TypeValidatorHelper fHelper1_0 = new TypeValidatorHelper1_0();
+ private static final TypeValidatorHelper fHelper1_1 = new TypeValidatorHelper1_1();
+
+ // Methods
+ public static TypeValidatorHelper getInstance(short schemaVersion) {
+ if (schemaVersion < Constants.SCHEMA_VERSION_1_1) {
+ return fHelper1_0;
+ }
+ return fHelper1_1;
+ }
+
+ public boolean isXMLSchema11() {
+ return false;
+ }
+
+ public abstract int getAllowedFacets(short validationDV);
+
+ // Constructor
+ protected TypeValidatorHelper() {}
+
+ // Inner classes
+
+ // XML Schema 1.0
+ static class TypeValidatorHelper1_0 extends TypeValidatorHelper {
+
+ // Data
+ protected static int[] fAllowedFacets;
+
+ static {
+ createAllowedFacets();
+ }
+
+ // create allowed facets
+ static void createAllowedFacets() {
+ fAllowedFacets = new int[] {
+ FACETS_GROUP1, // anySimpleType
+ FACETS_GROUP3, // string
+ FACETS_GROUP2, // boolean
+ FACETS_GROUP5, // decimal
+ FACETS_GROUP4, // float
+ FACETS_GROUP4, // double
+ FACETS_GROUP4, // duration
+ FACETS_GROUP4, // dateTime
+ FACETS_GROUP4, // time
+ FACETS_GROUP4, // date
+ FACETS_GROUP4, // gYearMonth
+ FACETS_GROUP4, // gYear
+ FACETS_GROUP4, // gMonthDay
+ FACETS_GROUP4, // gDay
+ FACETS_GROUP4, // gMonth
+ FACETS_GROUP3, // hexBinary
+ FACETS_GROUP3, // base64Binary
+ FACETS_GROUP3, // anyURI
+ FACETS_GROUP3, // QName
+ FACETS_GROUP1, // precisionDecimal
+ FACETS_GROUP3, // NOTATION
+ FACETS_GROUP3, // ID
+ FACETS_GROUP3, // IDREF
+ FACETS_GROUP3, // ENTITY
+ FACETS_GROUP5, // integer
+ FACETS_GROUP3, // list
+ FACETS_GROUP6, // union
+ FACETS_GROUP1, // gYearMonthDuration
+ FACETS_GROUP1, // gDayTimeDuration
+ FACETS_GROUP1, // anyAtomic
+ FACETS_GROUP1, // error
+ FACETS_GROUP1 // dateTimeStamp
+ };
+ }
+
+ // TypeValidator abstract methods
+ public int getAllowedFacets(short validationDV) {
+ return (validationDV < fAllowedFacets.length) ? fAllowedFacets[validationDV] : FACETS_GROUP1;
+ }
+ }
+
+ // XML Schema 1.1
+ static class TypeValidatorHelper1_1 extends TypeValidatorHelper {
+
+ // Data
+ protected static int[] fAllowedFacets;
+
+ static {
+ createAllowedFacets();
+ }
+
+ // create allowed facets
+ static void createAllowedFacets() {
+ fAllowedFacets = new int[] {
+ FACETS_GROUP1, //anySimpleType
+ FACETS_GROUP8, // string
+ FACETS_GROUP7, // boolean
+ FACETS_GROUP11, // decimal
+ FACETS_GROUP9, // float
+ FACETS_GROUP9, // double
+ FACETS_GROUP9, // duration
+ FACETS_GROUP10, // dateTime
+ FACETS_GROUP10, // time
+ FACETS_GROUP10, // date
+ FACETS_GROUP10, // gYearMonth
+ FACETS_GROUP10, // gYear
+ FACETS_GROUP10, // gMonthDay
+ FACETS_GROUP10, // gDay
+ FACETS_GROUP10, // gMonth
+ FACETS_GROUP8, // hexBinary
+ FACETS_GROUP8, // base64Binary
+ FACETS_GROUP8, // anyURI
+ FACETS_GROUP8, // QName
+ FACETS_GROUP13, // precisionDecimal
+ FACETS_GROUP8, // NOTATION
+ FACETS_GROUP8, // ID
+ FACETS_GROUP8, // IDREF
+ FACETS_GROUP8, // ENTITY
+ FACETS_GROUP11, // integer
+ FACETS_GROUP8, // list
+ FACETS_GROUP12, // union
+ FACETS_GROUP9, // gYearMonthDuration
+ FACETS_GROUP9, // gDayTimeDuration
+ FACETS_GROUP1, // anyAtomic
+ FACETS_GROUP1, // error
+ FACETS_GROUP10 // dateTimeStamp
+ };
+ }
+
+ // TypeValidator abstract methods
+
+ public int getAllowedFacets(short validationDV) {
+ return (validationDV < fAllowedFacets.length) ? fAllowedFacets[validationDV] : FACETS_GROUP1;
+ }
+
+ public boolean isXMLSchema11() {
+ return true;
+ }
+ }
+}
diff --git a/src/org/apache/xerces/impl/dv/xs/UnionDV.java b/src/org/apache/xerces/impl/dv/xs/UnionDV.java
index 89f63ca93..12179ea62 100644
--- a/src/org/apache/xerces/impl/dv/xs/UnionDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/UnionDV.java
@@ -32,10 +32,6 @@ import org.apache.xerces.impl.dv.ValidationContext;
*/
public class UnionDV extends TypeValidator{
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION );
- }
-
// this method should never be called: XSSimpleTypeDecl is responsible for
// calling the member types for the convertion
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
diff --git a/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java b/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
index 1a4813d15..bb062a655 100644
--- a/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
+++ b/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
@@ -19,7 +19,10 @@ package org.apache.xerces.impl.dv.xs;
import java.math.BigInteger;
import java.util.AbstractList;
+import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -33,12 +36,19 @@ import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xpath.regex.RegularExpression;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XMLAssertXPath2EngineImpl;
+import org.apache.xerces.impl.xs.XMLAssertXPath2EngineImpl.AssertionError;
+import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
import org.apache.xerces.impl.xs.util.ObjectListImpl;
import org.apache.xerces.impl.xs.util.ShortListImpl;
import org.apache.xerces.impl.xs.util.StringListImpl;
+import org.apache.xerces.impl.xs.util.XS11TypeHelper;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.util.NamespaceSupport;
+import org.apache.xerces.util.XML11Char;
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
import org.apache.xerces.xs.ShortList;
import org.apache.xerces.xs.StringList;
import org.apache.xerces.xs.XSAnnotation;
@@ -63,37 +73,39 @@ import org.w3c.dom.TypeInfo;
*/
public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
- 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_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;
+ protected static final short DV_DAYTIMEDURATION = DV_NOTATION + 8;
+ protected static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
+ protected static final short DV_ERROR = DV_NOTATION + 10;
+ protected static final short DV_DATETIMESTAMP = DV_NOTATION + 11;
private static final TypeValidator[] gDVs = {
new AnySimpleDV(),
@@ -125,7 +137,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
new UnionDV(),
new YearMonthDurationDV(), // XML Schema 1.1 type
new DayTimeDurationDV(), // XML Schema 1.1 type
- new AnyAtomicDV() // XML Schema 1.1 type
+ new AnyAtomicDV(), // XML Schema 1.1 type
+ new ErrorDV(), // XML Schema 1.1 type
+ new DateTimeStampDV() //XML Schema 1.1 type
};
static final short NORMALIZE_NONE = 0;
@@ -162,6 +176,8 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
+ NORMALIZE_NONE, //ErrorDV() (Schema 1.1)
+ NORMALIZE_TRIM, //DateTimeStampDV(), (Schema 1.1)
};
static final short SPECIAL_PATTERN_NONE = 0;
@@ -177,6 +193,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
"preserve", "replace", "collapse"
};
+ static final String[] ET_FACET_STRING = {
+ "optional", "required", "prohibited"
+ };
+
static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
static final String ANY_TYPE = "anyType";
@@ -185,6 +205,8 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public static final short DAYTIMEDURATION_DT = 47;
public static final short PRECISIONDECIMAL_DT = 48;
public static final short ANYATOMICTYPE_DT = 49;
+ public static final short ERROR_DT = 50;
+ public static final short DATETIMESTAMP_DT = 51;
// DOM Level 3 TypeInfo Derivation Method constants
static final int DERIVATION_ANY = 0;
@@ -228,6 +250,12 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public Locale getLocale() {
return Locale.getDefault();
}
+ public TypeValidatorHelper getTypeValidatorHelper() {
+ return TypeValidatorHelper.getInstance(Constants.SCHEMA_VERSION_1_0);
+ }
+ public short getDatatypeXMLVersion() {
+ return Constants.XML_VERSION_1_0;
+ }
};
protected static TypeValidator[] getGDVs() {
@@ -238,6 +266,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fDVs = dvs;
}
+
+ // Default TypeValidatorHelper
+ private static TypeValidatorHelper fDefaultTypeValidatorHelper = TypeValidatorHelper.getInstance(Constants.SCHEMA_VERSION_1_0);
+
// 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).
@@ -260,11 +292,14 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
//for constraining facets
private short fWhiteSpace = 0;
+ private short fExplicitTimezone = ET_OPTIONAL; //for XML Schema 1.1
private int fLength = -1;
private int fMinLength = -1;
private int fMaxLength = -1;
private int fTotalDigits = -1;
private int fFractionDigits = -1;
+ private int fMaxScale; //for XML Schema 1.1
+ private int fMinScale; //for XML Schema 1.1
private Vector fPattern;
private Vector fPatternStr;
private ValidatedInfo[] fEnumeration;
@@ -278,6 +313,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
private Object fMaxExclusive;
private Object fMinExclusive;
private Object fMinInclusive;
+ private Vector fAssertion; // added for XML Schema 1.1, assertions
// annotations for constraining facets
public XSAnnotation lengthAnnotation;
@@ -292,6 +328,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public XSAnnotation maxExclusiveAnnotation;
public XSAnnotation minInclusiveAnnotation;
public XSAnnotation minExclusiveAnnotation;
+ public XSAnnotation maxScaleAnnotation;
+ public XSAnnotation minScaleAnnotation;
+ public XSAnnotation explicitTimezoneAnnotation;
// facets as objects
private XSObjectListImpl fFacets;
@@ -313,6 +352,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// 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;
+
+ // context
+ XSObject fContext = null;
// default constructor
public XSSimpleTypeDecl(){}
@@ -387,6 +429,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fPatternStr = fBase.fPatternStr;
fEnumeration = fBase.fEnumeration;
fEnumerationSize = fBase.fEnumerationSize;
+ fAssertion = fBase.fAssertion; // added for XML Schema 1.1
fWhiteSpace = fBase.fWhiteSpace;
fMaxExclusive = fBase.fMaxExclusive;
fMaxInclusive = fBase.fMaxInclusive;
@@ -397,6 +440,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fPatternType = fBase.fPatternType;
fFixedFacet = fBase.fFixedFacet;
fFacetsDefined = fBase.fFacetsDefined;
+ fMaxScale = fBase.fMaxScale;
+ fMinScale = fBase.fMinScale;
+ fExplicitTimezone = fBase.fExplicitTimezone;
// always inherit facet annotations in case applyFacets is not called.
lengthAnnotation = fBase.lengthAnnotation;
@@ -411,6 +457,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
minInclusiveAnnotation = fBase.minInclusiveAnnotation;
totalDigitsAnnotation = fBase.totalDigitsAnnotation;
fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
+ maxScaleAnnotation = fBase.maxScaleAnnotation;
+ minScaleAnnotation = fBase.minScaleAnnotation;
+ explicitTimezoneAnnotation = fBase.explicitTimezoneAnnotation;
//we also set fundamental facets information in case applyFacets is not called.
calcFundamentalFacets();
@@ -421,8 +470,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
//Create a new simple type for list.
- protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable,
- XSObjectList annotations) {
+ protected XSSimpleTypeDecl(String name, String uri, short finalSet, XSSimpleTypeDecl itemType, boolean isImmutable, XSObjectList annotations) {
fBase = fAnySimpleType;
fTypeName = name;
fTargetNamespace = uri;
@@ -430,7 +478,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fAnnotations = annotations;
fVariety = VARIETY_LIST;
- fItemType = (XSSimpleTypeDecl)itemType;
+ fItemType = itemType;
fValidationDV = DV_LIST;
fFacetsDefined = FACET_WHITESPACE;
fFixedFacet = FACET_WHITESPACE;
@@ -517,6 +565,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fPatternType = fBase.fPatternType;
fFixedFacet = fBase.fFixedFacet;
fFacetsDefined = fBase.fFacetsDefined;
+ fMaxScale = fBase.fMaxScale;
+ fMinScale = fBase.fMinScale;
+ fExplicitTimezone = fBase.fExplicitTimezone;
//we also set fundamental facets information in case applyFacets is not called.
calcFundamentalFacets();
@@ -528,8 +579,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
//set values for list.
- protected XSSimpleTypeDecl setListValues(String name, String uri, short finalSet, XSSimpleTypeDecl itemType,
- XSObjectList annotations) {
+ 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;
@@ -540,7 +590,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fAnnotations = annotations;
fVariety = VARIETY_LIST;
- fItemType = (XSSimpleTypeDecl)itemType;
+ fItemType = itemType;
fValidationDV = DV_LIST;
fFacetsDefined = FACET_WHITESPACE;
fFixedFacet = FACET_WHITESPACE;
@@ -610,6 +660,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
return fFinalSet;
}
+ public TypeValidator getTypeValidator() {
+ return fDVs[fValidationDV];
+ }
+
public boolean isFinal(short derivation) {
return (fFinalSet & derivation) != 0;
}
@@ -650,7 +704,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
public short getPrimitiveKind() {
- if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
+ if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE && fValidationDV != DV_ANYATOMICTYPE) {
if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
return DV_STRING;
}
@@ -682,14 +736,15 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* If variety is <code>atomic</code> the primitive type definition (a
* built-in primitive datatype definition or the simple ur-type
- * definition) is available, otherwise <code>null</code>.
+ * definition) if available, otherwise <code>null</code>.
*/
public XSSimpleTypeDefinition getPrimitiveType() {
- if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
+ if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE && fValidationDV != DV_ANYATOMICTYPE) {
XSSimpleTypeDecl pri = this;
// recursively get base, until we reach anySimpleType
- while (pri.fBase != fAnySimpleType)
+ while (pri.fBase != fAnySimpleType && pri.fBase != fAnyAtomicType) {
pri = pri.fBase;
+ }
return pri;
}
else {
@@ -700,7 +755,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* If variety is <code>list</code> the item type definition (an atomic or
- * union simple type definition) is available, otherwise
+ * union simple type definition) if available, otherwise
* <code>null</code>.
*/
public XSSimpleTypeDefinition getItemType() {
@@ -715,7 +770,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* If variety is <code>union</code> the list of member type definitions (a
- * non-empty sequence of simple type definitions) is available,
+ * non-empty sequence of simple type definitions) if available,
* otherwise an empty <code>XSObjectList</code>.
*/
public XSObjectList getMemberTypes() {
@@ -730,7 +785,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* If <restriction> is chosen
*/
- public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
+ public void applyFacets(XSFacets facets, int presentFacet, int fixedFacet, ValidationContext context)
throws InvalidDatatypeFacetException {
if (context == null) {
context = fEmptyContext;
@@ -741,7 +796,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* built-in derived types by restriction
*/
- void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet) {
+ void applyFacets1(XSFacets facets, int presentFacet, int fixedFacet) {
try {
applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, fDummyContext);
@@ -756,7 +811,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* built-in derived types by restriction
*/
- void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short patternType) {
+ void applyFacets1(XSFacets facets, int presentFacet, int fixedFacet, short patternType) {
try {
applyFacets(facets, presentFacet, fixedFacet, patternType, fDummyContext);
@@ -771,9 +826,11 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
/**
* If <restriction> is chosen, or built-in derived types by restriction
*/
- void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context)
+ void applyFacets(XSFacets facets, int presentFacet, int fixedFacet, short patternType, ValidationContext context)
throws InvalidDatatypeFacetException {
-
+
+ boolean isXsd11 = context.getTypeValidatorHelper().isXMLSchema11();
+
// if the object is immutable, should not apply facets...
if(fIsImmutable) return;
ValidatedInfo tempInfo = new ValidatedInfo();
@@ -791,7 +848,12 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
int result = 0 ;
// step 1: parse present facets
- short allowedFacet = fDVs[fValidationDV].getAllowedFacets();
+ TypeValidatorHelper typeValidatorHelper = context.getTypeValidatorHelper();
+ if (typeValidatorHelper == null) {
+ // fall back to 1.0 simple types
+ typeValidatorHelper = fDefaultTypeValidatorHelper;
+ }
+ int allowedFacet = typeValidatorHelper.getAllowedFacets(fValidationDV);
// length
if ((presentFacet & FACET_LENGTH) != 0) {
@@ -836,8 +898,11 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
} else {
patternAnnotations = facets.patternAnnotations;
RegularExpression regex = null;
+ // In schema 1.1, enable the new behavior for '-' and
+ // unrecognized block names.
+ final String options = context.getTypeValidatorHelper().isXMLSchema11() ? "Xbh" : "X";
try {
- regex = new RegularExpression(facets.pattern, "X", context.getLocale());
+ regex = new RegularExpression(facets.pattern, options, context.getLocale(), context.getDatatypeXMLVersion());
} catch (Exception e) {
reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
}
@@ -877,6 +942,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
ValidationContextImpl ctx = new ValidationContextImpl(context);
enumerationAnnotations = facets.enumAnnotations;
fEnumerationSize = 0;
+
for (int i = 0; i < size; i++) {
if (enumNSDecls != null)
ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
@@ -888,12 +954,155 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()});
}
}
+
+ if (isXsd11) {
+ // added for XML Schema 1.1
+ String enumVal = null;
+ try {
+ boolean isTypeDerivedFromList = ((XSSimpleType) this.getBaseType()).
+ getVariety() == XSSimpleType.VARIETY_LIST;
+ boolean isTypeDerivedFromUnion = ((XSSimpleType) this.getBaseType()).
+ getVariety() == XSSimpleType.VARIETY_UNION;
+ Map assertProcessorParams = new HashMap();
+ assertProcessorParams.put(Constants.XPATH2_NAMESPACE_CONTEXT, new NamespaceSupport());
+ XMLAssertXPath2EngineImpl fAssertionProcessor = new XMLAssertXPath2EngineImpl(assertProcessorParams);
+ fAssertionProcessor.initXPathProcessor();
+
+ QName elemQname = new QName(null, "enumeration", "enumeration", Constants.NS_XMLSCHEMA);
+ QName attrQname = new QName(null, "value", "value", null);
+
+ for (int i = 0; i < size; i++) {
+ enumVal = (String)enumVals.elementAt(i);
+ if (fAssertion != null) {
+ for (int idx = 0; idx < fAssertion.size(); idx++) {
+ XSAssertImpl assertImpl = (XSAssertImpl)fAssertion.get(idx);
+ Boolean isAssertSucceeded = fAssertionProcessor.evaluateOneAssertionFromSimpleType(elemQname, enumVal, null,
+ (XSSimpleTypeDefinition)this.getBaseType(), isTypeDerivedFromList,
+ isTypeDerivedFromUnion, assertImpl, true, attrQname, true);
+ if (isAssertSucceeded.booleanValue() == false) {
+ throw new InvalidDatatypeFacetException(null, null);
+ }
+ }
+ }
+
+ if (isTypeDerivedFromList) {
+ Boolean isAssertSucceeded = fAssertionProcessor.evaluateAssertsFromItemTypeOfSTList(elemQname,
+ ((XSSimpleTypeDefinition)this.getBaseType()).getItemType(), enumVal, true);
+ if (isAssertSucceeded.booleanValue() == false) {
+ throw new InvalidDatatypeFacetException(null, null);
+ }
+ }
+
+ if (isTypeDerivedFromUnion) {
+ boolean isValidationFailedForUnion = fAssertionProcessor.isValidationFailedForSTUnion(((XSSimpleTypeDefinition)this.getBaseType()).
+ getMemberTypes(), elemQname, enumVal, null, true);
+ if (isValidationFailedForUnion) {
+ throw new InvalidDatatypeFacetException(null, null);
+ }
+ }
+
+ // handling, assertions when the base simpleType definition, has variety list whose itemType is union
+ if (((XSSimpleTypeDefinition)this.getBaseType()).getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
+ XSSimpleTypeDefinition xsItemTypeDefn = ((XSSimpleTypeDefinition)this.getBaseType()).getItemType();
+ if (xsItemTypeDefn.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
+ XSObjectList memberTypes = xsItemTypeDefn.getMemberTypes();
+ int unionTypeNoOfMembers = memberTypes.getLength();
+ int noOfUnionAtomicTypes = 0;
+ List memberTypeList = new Vector();
+ for (int idx = 0; idx < memberTypes.getLength(); idx++) {
+ XSSimpleTypeDefinition memberType = (XSSimpleTypeDefinition)memberTypes.get(idx);
+ if (memberType.getVariety() == XSSimpleTypeDefinition.VARIETY_ATOMIC) {
+ noOfUnionAtomicTypes++;
+ XSSimpleTypeDecl xsSimpleTypeDecl = (XSSimpleTypeDecl)memberType;
+ memberTypeList.add(xsSimpleTypeDecl);
+ }
+ }
+
+ if (unionTypeNoOfMembers == noOfUnionAtomicTypes) {
+ // tokenize the list value by a sequence of white spaces
+ StringTokenizer listStrTokens = new StringTokenizer(enumVal, " \n\t\r");
+ while (listStrTokens.hasMoreTokens()) {
+ String listItemStrValue = listStrTokens.nextToken();
+ // iterate over all the member types of union
+ boolean isValidationForListItemSuccessful = false;
+ for (int idx = 0; idx < memberTypeList.size(); idx++) {
+ XSSimpleTypeDecl xsSimpleTypeDecl = (XSSimpleTypeDecl)memberTypeList.get(idx);
+ if (XS11TypeHelper.isStrValueValidForASimpleType(listItemStrValue, xsSimpleTypeDecl, Constants.SCHEMA_VERSION_1_1)) {
+ Vector assertVector = xsSimpleTypeDecl.getAssertions();
+ if (assertVector != null) {
+ int noOfAsserts = assertVector.size();
+ int noOfAssertSuccesses = 0;
+ for (int idx1 = 0; idx1 < assertVector.size(); idx1++) {
+ fAssertionProcessor.setXDMTypedValueOf$valueForSTVarietyAtomic(listItemStrValue, fAssertionProcessor.getXercesXSDTypeCodeFor$value((XSTypeDefinition)xsSimpleTypeDecl),
+ fAssertionProcessor.getDynamicContext());
+ AssertionError assertError = fAssertionProcessor.evaluateOneAssertion(elemQname, (XSAssertImpl)assertVector.get(idx1), listItemStrValue, false, true);
+ if (assertError == null) {
+ noOfAssertSuccesses++;
+ }
+ }
+ if (noOfAsserts == noOfAssertSuccesses) {
+ isValidationForListItemSuccessful = true;
+ break;
+ }
+ }
+ else {
+ isValidationForListItemSuccessful = true;
+ }
+ }
+
+ if (isValidationForListItemSuccessful) {
+ break;
+ }
+ }
+
+ if (!isValidationForListItemSuccessful) {
+ throw new InvalidDatatypeFacetException(null, null);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (InvalidDatatypeFacetException ex) {
+ reportError("enumeration-valid-restriction", new Object[]{enumVal, this.getBaseType().getName()});
+ }
+ catch (Exception ex) {
+ // NO OP
+ }
+ }
+
fFacetsDefined |= FACET_ENUMERATION;
if ((fixedFacet & FACET_ENUMERATION) != 0)
fFixedFacet |= FACET_ENUMERATION;
}
}
+ // assertion. added for XML Schema 1.1
+ if ((presentFacet & FACET_ASSERT) != 0) {
+ fAssertion = new Vector();
+ Vector asserts = facets.assertFacets;
+ for (int i = 0; i < asserts.size(); i++) {
+ fAssertion.addElement(asserts.elementAt(i));
+ }
+ fFacetsDefined |= FACET_ASSERT;
+ if ((fixedFacet & FACET_ASSERT) != 0)
+ fFixedFacet |= FACET_ASSERT;
+ }
+
+ //explicitTimezone
+ if ((presentFacet & FACET_EXPLICITTIMEZONE) != 0) {
+ if ((allowedFacet & FACET_EXPLICITTIMEZONE) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"explicitTimezone", fTypeName});
+ } else {
+ fExplicitTimezone = facets.explicitTimezone;
+ explicitTimezoneAnnotation = facets.explicitTimezoneAnnotation;
+ fFacetsDefined |= FACET_EXPLICITTIMEZONE;
+ if ((fixedFacet & FACET_EXPLICITTIMEZONE) != 0)
+ fFixedFacet |= FACET_EXPLICITTIMEZONE;
+ }
+ }
+
// maxInclusive
if ((presentFacet & FACET_MAXINCLUSIVE) != 0) {
if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) {
@@ -901,7 +1110,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
} else {
maxInclusiveAnnotation = facets.maxInclusiveAnnotation;
try {
- fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true);
+ fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true, false);
fFacetsDefined |= FACET_MAXINCLUSIVE;
if ((fixedFacet & FACET_MAXINCLUSIVE) != 0)
fFixedFacet |= FACET_MAXINCLUSIVE;
@@ -937,7 +1146,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
} else {
maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
try {
- fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
+ fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true, false);
fFacetsDefined |= FACET_MAXEXCLUSIVE;
if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
fFixedFacet |= FACET_MAXEXCLUSIVE;
@@ -984,7 +1193,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
} else {
minExclusiveAnnotation = facets.minExclusiveAnnotation;
try {
- fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
+ fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true, false);
fFacetsDefined |= FACET_MINEXCLUSIVE;
if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
fFixedFacet |= FACET_MINEXCLUSIVE;
@@ -1030,7 +1239,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
} else {
minInclusiveAnnotation = facets.minInclusiveAnnotation;
try {
- fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
+ fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true, false);
fFacetsDefined |= FACET_MININCLUSIVE;
if ((fixedFacet & FACET_MININCLUSIVE) != 0)
fFixedFacet |= FACET_MININCLUSIVE;
@@ -1083,6 +1292,31 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
}
+ //maxScale
+ if ((presentFacet & FACET_MAXSCALE) !=0 ){
+ if ((allowedFacet & FACET_MAXSCALE) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"maxScale", fTypeName});
+ }else {
+ maxScaleAnnotation = facets.maxScaleAnnotation;
+ fMaxScale = facets.maxScale;
+ fFacetsDefined |= FACET_MAXSCALE;
+ if ((fixedFacet & FACET_MAXSCALE) != 0)
+ fFixedFacet |= FACET_MAXSCALE;
+ }
+ }
+ //minScale
+ if ((presentFacet & FACET_MINSCALE) !=0 ){
+ if ((allowedFacet & FACET_MINSCALE) == 0) {
+ reportError("cos-applicable-facets", new Object[]{"minScale", fTypeName});
+ }else {
+ minScaleAnnotation = facets.minScaleAnnotation;
+ fMinScale = facets.minScale;
+ fFacetsDefined |= FACET_MINSCALE;
+ if ((fixedFacet & FACET_MINSCALE) != 0)
+ fFixedFacet |= FACET_MINSCALE;
+ }
+ }
+
// token type: internal use, so do less checking
if (patternType != SPECIAL_PATTERN_NONE) {
fPatternType = patternType;
@@ -1140,6 +1374,12 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
if (fFractionDigits > fTotalDigits)
reportError( "fractionDigits-totalDigits", new Object[]{Integer.toString(fFractionDigits), Integer.toString(fTotalDigits), fTypeName});
}
+
+ // check 4.3.14.4 must: minScale <= maxScale
+ if (((fFacetsDefined & FACET_MAXSCALE) != 0 ) && ((fFacetsDefined & FACET_MINSCALE) != 0)) {
+ if (fMinScale > fMaxScale)
+ reportError ("minScale-totalDigits", new Object[]{Integer.toString(fMinScale), Integer.toString(fMaxScale), fTypeName});
+ }
// step 3: check facets against base
// check 4.3.1.c1 error: length & (fBase.maxLength | fBase.minLength)
@@ -1375,7 +1615,43 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
}
}
-
+
+ //check maxScale > fBase.maxScale
+ if ( (fFacetsDefined & FACET_MAXSCALE) != 0 ) {
+ if ( (fBase.fFacetsDefined & FACET_MAXSCALE) != 0 ){
+ if(( (fBase.fFixedFacet & FACET_MAXSCALE) != 0 )&& fMaxScale != fBase.fMaxScale ) {
+ reportError( "FixedFacetValue", new Object[]{"maxScale", Integer.toString(fMaxScale), Integer.toString(fBase.fMaxScale), fTypeName});
+ }
+ if ( fMaxScale > fBase.fMaxScale) {
+ reportError( "maxScale-valid-restriction", new Object[]{Integer.toString(fMaxScale), Integer.toString(fBase.fMaxScale), fTypeName});
+ }
+ }
+ }
+ //check minScale < fBase.minScale
+ if ( (fFacetsDefined & FACET_MINSCALE) != 0 ) {
+ if ( (fBase.fFacetsDefined & FACET_MINSCALE) != 0 ){
+ if(( (fBase.fFixedFacet & FACET_MINSCALE) != 0 )&& fMinScale != fBase.fMinScale ) {
+ reportError( "FixedFacetValue", new Object[]{"minScale", Integer.toString(fMinScale), Integer.toString(fBase.fMinScale), fTypeName});
+ }
+ if (fMinScale < fBase.fMinScale) {
+ reportError( "minScale-valid-restriction", new Object[]{Integer.toString(fMinScale), Integer.toString(fBase.fMinScale), fTypeName});
+ }
+ }
+ }
+ //check must maxScale >= fBase.minScale
+ if ( ((fFacetsDefined & FACET_MAXSCALE ) != 0 ) && ((fBase.fFacetsDefined & FACET_MINSCALE ) != 0 )) {
+ if ( fMaxScale < fBase.fMinScale) {
+ reportError ("minScale-totalDigits", new Object[]{Integer.toString(fBase.fMinScale), Integer.toString(fMaxScale), fTypeName});
+ }
+ }
+
+ //check must minScale <= fBase.maxScale
+ if ( ((fFacetsDefined & FACET_MINSCALE ) != 0 ) && ((fBase.fFacetsDefined & FACET_MAXSCALE ) != 0 )) {
+ if ( fMinScale > fBase.fMaxScale) {
+ reportError ("minScale-totalDigits", new Object[]{Integer.toString(fMinScale), Integer.toString(fBase.fMaxScale), fTypeName});
+ }
+ }
+
// check 4.3.12.c1 must: fractionDigits <= base.totalDigits
if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
if ((fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0) {
@@ -1420,6 +1696,26 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
reportError( "whiteSpace-valid-restriction.2", new Object[]{fTypeName});
}
}
+
+ if ((fFacetsDefined & FACET_EXPLICITTIMEZONE) != 0) {
+ if ((fBase.fFacetsDefined & FACET_EXPLICITTIMEZONE ) != 0 && fExplicitTimezone != fBase.fExplicitTimezone){
+ final String explicitTZStr = explicitTimezoneValue(fExplicitTimezone);
+ final String baseExplicitTZStr = explicitTimezoneValue(fBase.fExplicitTimezone);
+ if ((fBase.fFixedFacet & FACET_EXPLICITTIMEZONE) != 0) {
+ reportError( "FixedFacetValue", new Object[]{"explicitTimezone", explicitTZStr, baseExplicitTZStr, fTypeName});
+ }
+ //check 4.3.16.4 error:
+ //(explicitTimezone != prohibited && fBase.explicitTimezone = prohibited)
+ //or (explicitTimezone != required && fBase.explicitTimezone = required)
+ if (fBase.fExplicitTimezone != ET_OPTIONAL) {
+ reportError("timezone-valid-restriction", new Object[]{fTypeName, explicitTZStr, baseExplicitTZStr});
+ }
+ }
+ if ( (fValidationDV == DV_DATETIMESTAMP) && fExplicitTimezone != XSSimpleType.ET_REQUIRED){
+ reportError( "FixedFacetValue", new Object[]{"explicitTimezone", explicitTimezoneValue(fExplicitTimezone), explicitTimezoneValue(ET_REQUIRED), fTypeName});
+ }
+ }
+
}//fFacetsDefined != null
// step 4: inherit other facets from base (including fTokeyType)
@@ -1473,6 +1769,14 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fWhiteSpace = fBase.fWhiteSpace;
whiteSpaceAnnotation = fBase.whiteSpaceAnnotation;
}
+
+ //inherit explicitTimezone
+ if ( (fFacetsDefined & FACET_EXPLICITTIMEZONE) == 0 && (fBase.fFacetsDefined & FACET_EXPLICITTIMEZONE) != 0 ) {
+ fFacetsDefined |= FACET_EXPLICITTIMEZONE;
+ fExplicitTimezone = fBase.fExplicitTimezone;
+ explicitTimezoneAnnotation = fBase.explicitTimezoneAnnotation;
+ }
+
// inherit enumeration
if ((fFacetsDefined & FACET_ENUMERATION) == 0 && (fBase.fFacetsDefined & FACET_ENUMERATION) != 0) {
fFacetsDefined |= FACET_ENUMERATION;
@@ -1508,6 +1812,22 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fMinInclusive = fBase.fMinInclusive;
minInclusiveAnnotation = fBase.minInclusiveAnnotation;
}
+
+ //inherit maxScale
+ if ((( fBase.fFacetsDefined & FACET_MAXSCALE) != 0) &&
+ !((fFacetsDefined & FACET_MAXSCALE) != 0)) {
+ fFacetsDefined |= FACET_MAXSCALE;
+ fMaxScale = fBase.fMaxScale;
+ maxScaleAnnotation = fBase.maxScaleAnnotation;
+ }
+ //inherit minScale
+ if ((( fBase.fFacetsDefined & FACET_MINSCALE) != 0) &&
+ !((fFacetsDefined & FACET_MINSCALE) != 0)) {
+ fFacetsDefined |= FACET_MINSCALE;
+ fMinScale = fBase.fMinScale;
+ minScaleAnnotation = fBase.minScaleAnnotation;
+ }
+
// inherit totalDigits
if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0) &&
!((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
@@ -1522,6 +1842,14 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fFractionDigits = fBase.fFractionDigits;
fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
}
+
+ // inherit assertion. added for XML Schema 1.1
+ if (((fBase.fFacetsDefined & FACET_ASSERT) != 0)
+ && !((fFacetsDefined & FACET_ASSERT) != 0)) {
+ fFacetsDefined |= FACET_ASSERT;
+ fAssertion = fBase.fAssertion;
+ }
+
//inherit tokeytype
if ((fPatternType == SPECIAL_PATTERN_NONE ) && (fBase.fPatternType != SPECIAL_PATTERN_NONE)) {
fPatternType = fBase.fPatternType ;
@@ -1550,7 +1878,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// first normalize string value, and convert it to actual value
boolean needNormalize = context==null||context.needToNormalize();
- Object ob = getActualValue(content, context, validatedInfo, needNormalize);
+ Object ob = getActualValue(content, context, validatedInfo, needNormalize, false);
validate(context, validatedInfo);
@@ -1560,13 +1888,18 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
protected ValidatedInfo getActualEnumValue(String lexical, ValidationContext ctx, ValidatedInfo info)
throws InvalidDatatypeValueException {
- return fBase.validateWithInfo(lexical, ctx, info);
+ return fBase.validateWithInfo(lexical, ctx, info, true);
}
/**
* validate a value, and return the compiled form
*/
public ValidatedInfo validateWithInfo(String content, ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
+ return validateWithInfo(content, context, validatedInfo, false);
+ }
+
+ private ValidatedInfo validateWithInfo(String content, ValidationContext context,
+ ValidatedInfo validatedInfo, boolean enumerationValidation) throws InvalidDatatypeValueException {
if (context == null)
context = fEmptyContext;
@@ -1578,7 +1911,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// first normalize string value, and convert it to actual value
boolean needNormalize = context==null||context.needToNormalize();
- getActualValue(content, context, validatedInfo, needNormalize);
+ getActualValue(content, context, validatedInfo, needNormalize, enumerationValidation);
validate(context, validatedInfo);
@@ -1601,7 +1934,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// first normalize string value, and convert it to actual value
boolean needNormalize = context==null||context.needToNormalize();
- Object ob = getActualValue(content, context, validatedInfo, needNormalize);
+ Object ob = getActualValue(content, context, validatedInfo, needNormalize, false);
validate(context, validatedInfo);
@@ -1624,7 +1957,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// then validate the actual value against the facets
if (context.needFacetChecking() &&
(fFacetsDefined != 0 && fFacetsDefined != FACET_WHITESPACE)) {
- checkFacets(validatedInfo);
+ checkFacets(validatedInfo, context);
}
// now check extra rules: for ID/IDREF/ENTITY
@@ -1634,12 +1967,11 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
- private void checkFacets(ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
+ private void checkFacets(ValidatedInfo validatedInfo, ValidationContext context) throws InvalidDatatypeValueException {
Object ob = validatedInfo.actualValue;
String content = validatedInfo.normalizedValue;
- short type = validatedInfo.actualValueType;
- ShortList itemType = validatedInfo.itemValueTypes;
+ final short schemaVersion = (context.getTypeValidatorHelper().isXMLSchema11()) ? Constants.SCHEMA_VERSION_1_1 : Constants.SCHEMA_VERSION_1_0;
// For QName and NOTATION types, we don't check length facets
if (fValidationDV != DV_QNAME && fValidationDV != DV_NOTATION) {
@@ -1674,42 +2006,13 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
boolean present = false;
final int enumSize = fEnumerationSize;
- final short primitiveType1 = convertToPrimitiveKind(type);
for (int i = 0; i < enumSize; i++) {
- final short primitiveType2 = convertToPrimitiveKind(fEnumeration[i].actualValueType);
- if ((primitiveType1 == primitiveType2 ||
- primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
- primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT)
- && fEnumeration[i].actualValue.equals(ob)) {
- if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
- ShortList enumItemType = fEnumeration[i].itemValueTypes;
- final int typeList1Length = itemType != null ? itemType.getLength() : 0;
- final int typeList2Length = enumItemType != null ? enumItemType.getLength() : 0;
- if (typeList1Length == typeList2Length) {
- int j;
- for (j = 0; j < typeList1Length; ++j) {
- final short primitiveItem1 = convertToPrimitiveKind(itemType.item(j));
- 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) {
- continue;
- }
- break;
- }
- }
- if (j == typeList1Length) {
- present = true;
- break;
- }
- }
- }
- else {
- present = true;
- break;
- }
+ if (EqualityHelper.isEqual(validatedInfo, fEnumeration[i], schemaVersion)) {
+ present = true;
+ break;
}
}
+
if(!present){
StringBuffer sb = new StringBuffer();
appendEnumString(sb);
@@ -1720,10 +2023,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
//fractionDigits
if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
- int scale = fDVs[fValidationDV].getFractionDigits(ob);
- if (scale > fFractionDigits) {
+ int fracDigits = fDVs[fValidationDV].getFractionDigits(ob);
+ if (fracDigits > fFractionDigits) {
throw new InvalidDatatypeValueException("cvc-fractionDigits-valid",
- new Object[] {content, Integer.toString(scale), Integer.toString(fFractionDigits)});
+ new Object[] {content, Integer.toString(fracDigits), Integer.toString(fFractionDigits)});
}
}
@@ -1735,7 +2038,44 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
new Object[] {content, Integer.toString(totalDigits), Integer.toString(fTotalDigits)});
}
}
-
+
+ //maxScale
+ if ((fFacetsDefined & FACET_MAXSCALE) != 0) {
+ if (fDVs[fValidationDV].hasPrecision(ob)) {
+ int precision = fDVs[fValidationDV].getPrecision(ob);
+ if (precision > fMaxScale){
+ throw new InvalidDatatypeValueException("cvc-maxScale-valid",
+ new Object[] {content, Integer.toString(fMaxScale), fTypeName, Integer.toString(precision)});
+ }
+ }
+ }
+
+ //minScale
+ if ((fFacetsDefined & FACET_MINSCALE) != 0) {
+ if (fDVs[fValidationDV].hasPrecision(ob)) {
+ int precision = fDVs[fValidationDV].getPrecision(ob);
+ if (precision < fMinScale){
+ throw new InvalidDatatypeValueException("cvc-minScale-valid",
+ new Object[] {content, Integer.toString(fMinScale), fTypeName, Integer.toString(precision)} );
+ }
+ }
+ }
+
+ //explicitTimezone
+ if ( ( fFacetsDefined & FACET_EXPLICITTIMEZONE) !=0 ) {
+ boolean hasTimezone = fDVs[fValidationDV].hasTimeZone(ob);
+ if (hasTimezone) {
+ if (fExplicitTimezone == ET_PROHIBITED ) {
+ throw new InvalidDatatypeValueException("cvc-explicitTimezone-valid",
+ new Object[] {content, "prohibited", fTypeName});
+ }
+ }
+ else if (fExplicitTimezone == ET_REQUIRED) {
+ throw new InvalidDatatypeValueException("cvc-explicitTimezone-valid",
+ new Object[] {content, "required", fTypeName});
+ }
+ }
+
int compare;
//maxinclusive
@@ -1819,9 +2159,9 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
//we can still return object for internal use.
private Object getActualValue(Object content, ValidationContext context,
- ValidatedInfo validatedInfo, boolean needNormalize)
- throws InvalidDatatypeValueException{
-
+ ValidatedInfo validatedInfo, boolean needNormalize,
+ boolean enumerationValidation)
+ throws InvalidDatatypeValueException{
String nvalue;
if (needNormalize) {
nvalue = normalize(content, fWhiteSpace);
@@ -1848,17 +2188,19 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
if (fPatternType != SPECIAL_PATTERN_NONE) {
boolean seenErr = false;
+ final boolean isXML11 = context.getDatatypeXMLVersion() == Constants.XML_VERSION_1_1;
+ // if using XSD 1.1, use the XML 1.1 rules of validating the NMTOKEN, Name and NCName else use the XML 1.0 rules
if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
// PATTERN "\\c+"
- seenErr = !XMLChar.isValidNmtoken(nvalue);
+ seenErr = (isXML11) ? !XML11Char.isXML11ValidNmtoken(nvalue) : !XMLChar.isValidNmtoken(nvalue);
}
else if (fPatternType == SPECIAL_PATTERN_NAME) {
- // PATTERN "\\i\\c*"
- seenErr = !XMLChar.isValidName(nvalue);
+ // PATTERN "\\i\\c*"
+ seenErr = (isXML11) ? !XML11Char.isXML11ValidName(nvalue) : !XMLChar.isValidName(nvalue);
}
else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
// PATTERN "[\\i-[:]][\\c-[:]]*"
- seenErr = !XMLChar.isValidNCName(nvalue);
+ seenErr = (isXML11) ? !XML11Char.isXML11ValidNCName(nvalue) : !XMLChar.isValidNCName(nvalue);
}
if (seenErr) {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
@@ -1867,6 +2209,18 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
validatedInfo.normalizedValue = nvalue;
+
+ // XML Schema 1.1
+ // xs:Notation cannot be used directly to validate values
+ // without enumeration facet - exception is enumeration values
+ if (context.getTypeValidatorHelper().isXMLSchema11()) {
+ if (fValidationDV == DV_NOTATION &&
+ (getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0 &&
+ !enumerationValidation) {
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.4",
+ new Object[]{fTypeName, content});
+ }
+ }
Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
validatedInfo.actualValue = avalue;
validatedInfo.actualValueType = fBuiltInKind;
@@ -1891,10 +2245,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// 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);
+ avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false, enumerationValidation);
if (context.needFacetChecking() &&
(fItemType.fFacetsDefined != 0 && fItemType.fFacetsDefined != FACET_WHITESPACE)) {
- fItemType.checkFacets(validatedInfo);
+ fItemType.checkFacets(validatedInfo, context);
}
memberTypes[i] = (XSSimpleTypeDecl)validatedInfo.memberType;
if (isUnion)
@@ -1923,12 +2277,16 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
// 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);
+ Object aValue = fMemberTypes[i].getActualValue(_content, context, validatedInfo, true, enumerationValidation);
if (context.needFacetChecking() &&
(fMemberTypes[i].fFacetsDefined != 0 && fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) {
- fMemberTypes[i].checkFacets(validatedInfo);
+ fMemberTypes[i].checkFacets(validatedInfo, context);
}
- validatedInfo.memberType = fMemberTypes[i];
+
+ if (fMemberTypes[i].fVariety != VARIETY_UNION) {
+ validatedInfo.memberType = fMemberTypes[i];
+ }
+
// Need to set it here or it will become the member type
validatedInfo.actualType = this;
return aValue;
@@ -2096,6 +2454,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
return WS_FACET_STRING[ws];
}
+ private String explicitTimezoneValue(short et){
+ return ET_FACET_STRING[et];
+ }
+
/**
* Fundamental Facet: ordered.
*/
@@ -2224,6 +2586,12 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
return (fMinInclusive == null)?null:fMinInclusive.toString();
case FACET_TOTALDIGITS:
return (fTotalDigits == -1)?null:Integer.toString(fTotalDigits);
+ case FACET_MAXSCALE:
+ return ((fFacetsDefined & FACET_MAXSCALE) == 0)?null:Integer.toString(fMaxScale);
+ case FACET_MINSCALE:
+ return ((fFacetsDefined & FACET_MINSCALE) == 0)?null:Integer.toString(fMinScale);
+ case FACET_EXPLICITTIMEZONE:
+ return ET_FACET_STRING[fExplicitTimezone];
case FACET_FRACTIONDIGITS:
if (fValidationDV == DV_INTEGER) {
return "0";
@@ -2402,27 +2770,36 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
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 {
+
+ short firstMemberOrderVal = fMemberTypes[0].fOrdered;
+ // if any one of the memberTypes have partial order, set the order of this union to partial
+ if (firstMemberOrderVal==ORDERED_PARTIAL) {
this.fOrdered = ORDERED_PARTIAL;
+ return;
}
+
+ // if any of the memberTypes are of different order, set the order of this union to partial
+ short ancestorId = getPrimitiveDV(getFirstExpandedSimpleTypeValidationDV(fMemberTypes[0]));
+ boolean commonAnc = true;
+ for (int i=1; i<fMemberTypes.length; i++) {
+ if (fMemberTypes[i].fOrdered != firstMemberOrderVal) {
+ this.fOrdered = ORDERED_PARTIAL;
+ return;
+ }
+ if (commonAnc) {
+ commonAnc = (getPrimitiveDV(getFirstExpandedSimpleTypeValidationDV(fMemberTypes[i])) == ancestorId);
+ }
+ }
+
+ // if all the memberTypes are false order, set the order of this union to false
+ if (firstMemberOrderVal == ORDERED_FALSE) {
+ this.fOrdered = ORDERED_FALSE;
+ return;
+ }
+
+ // all the memberTypes are total order
+ // if they're from the same primitive type, set the order of this union to total, otherwise partial
+ this.fOrdered = commonAnc ? ORDERED_TOTAL : ORDERED_PARTIAL;
}
}//setOrdered
@@ -2473,11 +2850,11 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
short ancestorId = 0 ;
if(memberTypes.length > 0){
- ancestorId = getPrimitiveDV(memberTypes[0].fValidationDV);
+ ancestorId = getPrimitiveDV(getFirstExpandedSimpleTypeValidationDV(memberTypes[0]));
}
for(int i = 0 ; i < memberTypes.length ; i++){
- if(!memberTypes[i].getBounded() || (ancestorId != getPrimitiveDV(memberTypes[i].fValidationDV)) ){
+ if(!memberTypes[i].getBounded() || (ancestorId != getPrimitiveDV(getFirstExpandedSimpleTypeValidationDV(memberTypes[i]))) ){
this.fBounded = false;
return;
}
@@ -2487,6 +2864,20 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}//setBounded
+ // returns the validation DV of the first simple type not a union
+ private short getFirstExpandedSimpleTypeValidationDV(XSSimpleTypeDecl simpleType) {
+ if (simpleType.fVariety == VARIETY_UNION) {
+ for (int i=0; i<simpleType.fMemberTypes.length; i++) {
+ short validationDV = getFirstExpandedSimpleTypeValidationDV(simpleType.fMemberTypes[i]);
+ if (validationDV != -1) {
+ return validationDV;
+ }
+ }
+ return -1;
+ }
+ return simpleType.fValidationDV;
+ } // getFirstPrimitiveValidationDV()
+
private boolean specialCardinalityCheck(){
if( (fBase.fValidationDV == XSSimpleTypeDecl.DV_DATE) || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GYEARMONTH)
|| (fBase.fValidationDV == XSSimpleTypeDecl.DV_GYEAR) || (fBase.fValidationDV == XSSimpleTypeDecl.DV_GMONTHDAY)
@@ -2604,7 +2995,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
((ancestorNS == null && type.getNamespace() == null) ||
(ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
type != fAnySimpleType) { // reached anySimpleType
- type = (XSTypeDefinition)type.getBaseType();
+ type = type.getBaseType();
}
return type != fAnySimpleType;
@@ -2838,6 +3229,8 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
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);
+
+ static final XSSimpleTypeDecl fError = new XSSimpleTypeDecl(fAnySimpleType, "error", DV_ERROR, ORDERED_FALSE, false, true, false, true, XSSimpleTypeDecl.ERROR_DT);
/**
* Validation context used to validate facet values.
@@ -2886,6 +3279,14 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public Locale getLocale() {
return Locale.getDefault();
}
+
+ public TypeValidatorHelper getTypeValidatorHelper() {
+ return TypeValidatorHelper.getInstance(Constants.SCHEMA_VERSION_1_0);
+ }
+
+ public short getDatatypeXMLVersion() {
+ return Constants.XML_VERSION_1_0;
+ }
};
private boolean fAnonymous = false;
@@ -2958,6 +3359,14 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public Locale getLocale() {
return fExternal.getLocale();
}
+
+ public TypeValidatorHelper getTypeValidatorHelper() {
+ return fExternal.getTypeValidatorHelper();
+ }
+
+ public short getDatatypeXMLVersion() {
+ return fExternal.getDatatypeXMLVersion();
+ }
}
public void reset(){
@@ -2979,6 +3388,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
//for constraining facets
fWhiteSpace = 0;
+ fExplicitTimezone = ET_OPTIONAL;
fLength = -1;
fMinLength = -1;
fMaxLength = -1;
@@ -2996,6 +3406,8 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
fMaxExclusive = null;
fMinExclusive = null;
fMinInclusive = null;
+ fMaxScale = 0;
+ fMinScale = 0;
lengthAnnotation = null;
minLengthAnnotation = null;
maxLengthAnnotation = null;
@@ -3008,11 +3420,16 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
maxExclusiveAnnotation = null;
minInclusiveAnnotation = null;
minExclusiveAnnotation = null;
+ maxScaleAnnotation = null;
+ minScaleAnnotation = null;
+ explicitTimezoneAnnotation = null;
fPatternType = SPECIAL_PATTERN_NONE;
fAnnotations = null;
fFacets = null;
+ fContext = null;
+
// REVISIT: reset for fundamental facets
}
@@ -3026,6 +3443,17 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public void setNamespaceItem(XSNamespaceItem namespaceItem) {
fNamespaceItem = namespaceItem;
}
+
+ /**
+ *
+ */
+ public void setContext(XSObject context) {
+ fContext = context;
+ }
+
+ public XSObject getContext() {
+ return fContext;
+ }
/**
* @see java.lang.Object#toString()
@@ -3044,7 +3472,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
if (fFacets == null &&
(fFacetsDefined != 0 || fValidationDV == DV_INTEGER)) {
- XSFacetImpl[] facets = new XSFacetImpl[10];
+ XSFacetImpl[] facets = new XSFacetImpl[13];
int count = 0;
if ((fFacetsDefined & FACET_WHITESPACE) != 0 &&
fValidationDV != DV_ANYSIMPLETYPE &&
@@ -3169,6 +3597,39 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
minInclusiveAnnotation);
count++;
}
+ if ((fFacetsDefined & FACET_EXPLICITTIMEZONE) != 0) {
+ facets[count] =
+ new XSFacetImpl (
+ FACET_EXPLICITTIMEZONE,
+ ET_FACET_STRING[fExplicitTimezone],
+ 0,
+ null,
+ (fFixedFacet & FACET_EXPLICITTIMEZONE) != 0,
+ explicitTimezoneAnnotation);
+ count++;
+ }
+ if ((fFacetsDefined & FACET_MAXSCALE) != 0) {
+ facets[count] =
+ new XSFacetImpl (
+ FACET_MAXSCALE,
+ Integer.toString(fMaxScale),
+ fMaxScale,
+ null,
+ (fFixedFacet & FACET_MAXSCALE) != 0,
+ maxScaleAnnotation);
+ count++;
+ }
+ if ((fFacetsDefined & FACET_MINSCALE) != 0) {
+ facets[count] =
+ new XSFacetImpl (
+ FACET_MINSCALE,
+ Integer.toString(fMinScale),
+ fMinScale,
+ null,
+ (fFixedFacet & FACET_MINSCALE) != 0,
+ minScaleAnnotation);
+ count++;
+ }
fFacets = (count > 0) ? new XSObjectListImpl(facets, count) : XSObjectListImpl.EMPTY_LIST;
}
return (fFacets != null) ? fFacets : XSObjectListImpl.EMPTY_LIST;
@@ -3203,11 +3664,12 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public XSObjectList getMultiValueFacets() {
if (fMultiValueFacets == null &&
((fFacetsDefined & FACET_ENUMERATION) != 0 ||
+ (fFacetsDefined & FACET_ASSERT) != 0 ||
(fFacetsDefined & FACET_PATTERN) != 0 ||
fPatternType != SPECIAL_PATTERN_NONE ||
fValidationDV == DV_INTEGER)) {
- XSMVFacetImpl[] facets = new XSMVFacetImpl[2];
+ XSMVFacetImpl[] facets = new XSMVFacetImpl[3];
int count = 0;
if ((fFacetsDefined & FACET_PATTERN) != 0 ||
fPatternType != SPECIAL_PATTERN_NONE ||
@@ -3229,6 +3691,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
enumerationAnnotations);
count++;
}
+ if (fAssertion != null) {
+ facets[count] = new XSMVFacetImpl(FACET_ASSERT, fAssertion);
+ count++;
+ }
fMultiValueFacets = new XSObjectListImpl(facets, count);
}
return (fMultiValueFacets != null) ?
@@ -3319,7 +3785,7 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public Object getActualFacetValue() {
if (avalue == null) {
- if (kind == FACET_WHITESPACE) {
+ if (kind == FACET_WHITESPACE || kind == FACET_EXPLICITTIMEZONE) {
avalue = svalue;
}
else {
@@ -3377,13 +3843,25 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
final XSObjectList annotations;
final StringList svalues;
final ObjectList avalues;
+ final Vector asserts;
public XSMVFacetImpl(short kind, StringList svalues, ObjectList avalues, XSObjectList annotations) {
this.kind = kind;
this.svalues = svalues;
this.avalues = avalues;
this.annotations = (annotations != null) ? annotations : XSObjectListImpl.EMPTY_LIST;
+ this.asserts = null;
}
+ /*
+ * overloaded constructor. added to support assertions.
+ */
+ public XSMVFacetImpl(short kind, Vector asserts) {
+ this.kind = kind;
+ this.asserts = asserts;
+ this.svalues = null;
+ this.avalues = null;
+ this.annotations = null;
+ }
/* (non-Javadoc)
* @see org.apache.xerces.xs.XSFacet#getFacetKind()
@@ -3438,6 +3916,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
public short getType() {
return XSConstants.MULTIVALUE_FACET;
}
+
+ public Vector getAsserts() {
+ return asserts;
+ }
}
private static abstract class AbstractObjectList extends AbstractList implements ObjectList {
@@ -3460,23 +3942,6 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
return isDOMDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod);
}
- private short convertToPrimitiveKind(short valueType) {
- /** Primitive datatypes. */
- if (valueType <= XSConstants.NOTATION_DT) {
- return valueType;
- }
- /** Types derived from string. */
- if (valueType <= XSConstants.ENTITY_DT) {
- return XSConstants.STRING_DT;
- }
- /** Types derived from decimal. */
- if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
- return XSConstants.DECIMAL_DT;
- }
- /** Other types. */
- return valueType;
- }
-
private void appendEnumString(StringBuffer sb) {
sb.append('[');
for (int i = 0; i < fEnumerationSize; i++) {
@@ -3487,5 +3952,10 @@ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
}
sb.append(']');
}
+
+ public Vector getAssertions() {
+ return fAssertion;
+ }
+
} // class XSSimpleTypeDecl
diff --git a/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java b/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
index d720dc0e5..d115a45c3 100644
--- a/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
+++ b/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
@@ -178,7 +178,7 @@ public class XSSimpleTypeDelegate
return type.getType();
}
- public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
+ public void applyFacets(XSFacets facets, int presentFacet, int fixedFacet, ValidationContext context)
throws InvalidDatatypeFacetException {
type.applyFacets(facets, presentFacet, fixedFacet, context);
}
@@ -214,6 +214,10 @@ public class XSSimpleTypeDelegate
return type.validate(content, context, validatedInfo);
}
+ public XSObject getContext() {
+ return type.getContext();
+ }
+
public String toString() {
return type.toString();
}
diff --git a/src/org/apache/xerces/impl/dv/xs/YearDV.java b/src/org/apache/xerces/impl/dv/xs/YearDV.java
index d172f2df9..f8f03cf48 100644
--- a/src/org/apache/xerces/impl/dv/xs/YearDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/YearDV.java
@@ -44,7 +44,7 @@ public class YearDV extends AbstractDateTimeDV {
*/
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYear"});
}
@@ -58,7 +58,7 @@ public class YearDV extends AbstractDateTimeDV {
* @return normalized date representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException{
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException{
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -90,7 +90,7 @@ public class YearDV extends AbstractDateTimeDV {
date.day=1;
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java b/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java
index acf064f4a..b6d7ca8fb 100644
--- a/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java
+++ b/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java
@@ -43,7 +43,7 @@ public class YearMonthDV extends AbstractDateTimeDV{
*/
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{
try{
- return parse(content);
+ return parse(content, context.getTypeValidatorHelper().isXMLSchema11());
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYearMonth"});
}
@@ -57,7 +57,7 @@ public class YearMonthDV extends AbstractDateTimeDV{
* @return normalized date representation
* @exception SchemaDateTimeException Invalid lexical representation
*/
- protected DateTimeData parse(String str) throws SchemaDateTimeException{
+ protected DateTimeData parse(String str, boolean isXMLSchema11) throws SchemaDateTimeException{
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
@@ -68,7 +68,7 @@ public class YearMonthDV extends AbstractDateTimeDV{
//validate and normalize
- validateDateTime(date);
+ validateDateTime(date, isXMLSchema11);
//save unnormalized values
saveUnnormalized(date);
diff --git a/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties b/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
index 78ef9c7c0..c0f6eed65 100644
--- a/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
+++ b/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
@@ -44,6 +44,7 @@
KeyRefOutOfScope = Identity Constraint error: the keyref identity constraint \"{0}\" refers to a key or unique that is out of scope.
KeyRefReferNotFound = Key reference declaration \"{0}\" refers to unknown key with name \"{1}\".
UnknownField = Internal identity constraint error; unknown field \"{0}\" for identity constraint \"{2}\" specified for element \"{1}\".
+ ## KeyRefNotEnoughValues = cvc-identity-constraint.4.3.b: Not enough values specified for <keyref name=\"{1}\"> identity constraint specified for element \"{0}\".
# Ideally, we should only use the following error keys, not the ones under
# "Identity constraints". And we should cover all of the following errors.
@@ -75,6 +76,9 @@
cvc-datatype-valid.1.2.1 = cvc-datatype-valid.1.2.1: ''{0}'' is not a valid value for ''{1}''.
cvc-datatype-valid.1.2.2 = cvc-datatype-valid.1.2.2: ''{0}'' is not a valid value of list type ''{1}''.
cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: ''{0}'' is not a valid value of union type ''{1}''.
+ cvc-datatype-valid.1.2.4 = cvc-datatype-valid.1.2.4: The NOTATION type, ''{0}'' used to validate ''{1}'', must have an enumeration facet value which specifies the notation elements used by this type.
+ cvc-datatype-valid.4.1.4 = cvc-datatype-valid.4.1.4: The value ''{0}'' of element ''{1}'' is not valid with the required simple type. Value ''{2}'' is not valid with any member of union type ''{3}''.
+ cvc-datatype-valid_attr.4.1.4 = cvc-datatype-valid.4.1.4: The value ''{0}'' of attribute ''{2}'' on element ''{1}'' is not valid with the required simple type. Value ''{3}'' is not valid with any member of union type ''{4}''.
cvc-elt.1.a = cvc-elt.1.a: Cannot find the declaration of element ''{0}''.
cvc-elt.1.b = cvc-elt.1.b: The name of the element does not match the name of the element declaration. Saw ''{0}''. Expected ''{1}''.
cvc-elt.2 = cvc-elt.2: The value of '{'abstract'}' in the element declaration for ''{0}'' must be false.
@@ -107,7 +111,14 @@
cvc-type.3.1.1 = cvc-type.3.1.1: Element ''{0}'' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to ''http://www.w3.org/2001/XMLSchema-instance'' and whose [local name] is one of ''type'', ''nil'', ''schemaLocation'' or ''noNamespaceSchemaLocation''. However, the attribute, ''{1}'' was found.
cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' has the simple type ''{1}'', so it must have no element information item [children].
cvc-type.3.1.3 = cvc-type.3.1.3: The value ''{1}'' of element ''{0}'' is not valid.
-
+ cvc-assertion = cvc-assertion: Assertion evaluation (''{1}'') for element ''{0}'' on schema type ''{2}'' did not succeed. {3}
+ cvc-assertion-failure-mesg = cvc-assertion-failure-mesg: {0} {1}
+ cvc-assertions-valid = cvc-assertions-valid: Value ''{0}'' is not facet-valid with respect to assertion ''{1}''. {2}
+ cvc-assertions-valid-union-elem = cvc-assertions-valid-union-elem: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{2}'' on element ''{1}''.
+ cvc-assertions-valid-union-attr = cvc-assertions-valid-union-attr: Value ''{0}'' is not facet-valid with respect to the specified assertions, on type ''{3}'' on attribute ''{2}'/@'{1}''.
+ cvc-xpath.3.13.4.2a = cvc-xpath.3.13.4.2a: XPST0003 - Assertion XPath expression (''{0}'') on the schema type ''{1}'' couldn''t compile successfully.
+ cvc-xpath.3.13.4.2b = cvc-xpath.3.13.4.2b: An assert XPath expression such as (''{0}'') starting with / or // is not acceptable, on the schema type ''{1}'' (since an assert XPath tree is rooted at a parentless element).
+
#schema valid (3.X.3)
schema_reference.4 = schema_reference.4: Failed to read schema document ''{0}'', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
@@ -117,6 +128,10 @@
src-attribute.3.1 = src-attribute.3.1: One of 'ref' or 'name' must be present in a local attribute declaration.
src-attribute.3.2 = src-attribute.3.2: The content must match (annotation?) for the attribute reference ''{0}''.
src-attribute.4 = src-attribute.4: Attribute ''{0}'' has both a ''type'' attribute and an anonymous ''simpleType'' child. Only one of these is allowed for an attribute.
+ src-attribute.5 = src-attribute.5: The property ''fixed'' is present in attribute ''{0}'', so the value of ''use'' must not be ''prohibited''.
+ src-attribute.6.2 = src-attribute.6.2: Since attribute ''{0}'' contains the 'targetNamespace' attribute, the 'form' attribute must be absent.
+ src-attribute.6.3.1 = src-attribute.6.3.1: Since attribute ''{0}'' contains the 'targetNamespace' attribute and <schema> does not have a 'targetNamespace' attribute or its value is different from the value of 'targetNamespace' of ''{0}'', ''{0}'' must have a <complexType> as an ancestor.
+ src-attribute.6.3.2 = src-attribute.6.3.2: Since attribute ''{0}'' contains the 'targetNamespace' attribute and <schema> does not have a 'targetNamespace' attribute or its value is different from the value of 'targetNamespace' of ''{0}'', there must be a <restriction> ancestor between ''{0}'' and the nearest <complexType> ancestor, and the value of the 'base' attribute of <restriction> does not match the name of 'xs:anyType'.
src-attribute_group.2 = src-attribute_group.2: The intersection of wildcards is not expressible for attribute group ''{0}''.
src-attribute_group.3 = src-attribute_group.3: Circular definitions detected for attribute group ''{0}''. Recursively following attribute group references eventually leads back to itself.
src-ct.1 = src-ct.1: Complex Type Definition Representation Error for type ''{0}''. When <complexContent> is used, the base type must be a complexType. ''{1}'' is a simpleType.
@@ -124,16 +139,29 @@
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 <simpleType> among the children of <restriction>.
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-ct.6 = src-ct.5: Complex Type Definition Representation Error for type ''{0}''. If <openContent> is present and the actual value of its mode [attribute] is not 'none', then there must be an <any> among the [children] of <openContent>.
+ src-ct.7 = src-ct.7: Attribute group ''{0}'' is declared more than once within a complex type definition ''{1}''.
+ src-ct11.3 = src-ct11.3: Complex Type Definition Representation Error for type ''{0}''. If <openContent> is present and has mode = 'none', then there must not be an <any> among the [children] of <openContent>.
+ src-ct11.4 = src-ct11.4: Complex Type Definition Representation Error for type ''{0}''. If the <complexContent> alternative is chosen and the 'mixed' attribute is present on both <complexType> and <complexContent>, then the actual values of those attributes must be the same.
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-element.4.2 = src-element.4.2: Since element ''{0}'' contains the 'targetNamespace' attribute, the 'form' attribute must be absent.
+ src-element.4.3.1 = src-element.4.3.1: Since element ''{0}'' contains the 'targetNamespace' attribute and <schema> does not have a 'targetNamespace' attribute or its value is different from the value of 'targetNamespace' of ''{0}'', ''{0}'' must have a <complexType> as an ancestor.
+ src-element.4.3.2 = src-element.4.3.2: Since element ''{0}'' contains the 'targetNamespace' attribute and <schema> does not have a 'targetNamespace' attribute or its value is different from the value of 'targetNamespace' of ''{0}'', there must be a <restriction> ancestor between ''{0}'' and the nearest <complexType> ancestor, and the value of the 'base' attribute of <restriction> does not match the name of 'xs:anyType'.
+ src-element.5 = src-element.5: Element ''{0}'' has a type alternative with a missing ''test'' attribute. Only the last type alternative in the type table is allowed to be without a ''test'' attribute.
+ src-identity-constraint.1 = src-identity-constraint.1: One of ''ref'' or ''name'' must be present in an identity constraint declaration.
+ src-identity-constraint.5 = src-identity-constraint.5: The identity-constraint category of the identity-constraint definition resolved to by the actual value of the ''ref'' attribute does not match the name of the element information item ''{0}''.
src-import.1.1 = src-import.1.1: The namespace attribute ''{0}'' of an <import> 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 <import> 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 <import> element information item must be identical to the targetNamespace attribute, ''{1}'', of the imported document.
src-import.3.2 = src-import.3.2: An <import> 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.
src-include.1 = src-include.1: The root element of document ''{0}'' has to have the namespace name ''http://www.w3.org/2001/XMLSchema'' and the local name ''schema''.
+ src-override.2.1 = src-override.2.1: The targetNamespace of the overridden schema, currently ''{1}'', must be identical to that of the overriding schema, currently ''{0}''.
+ src-override-collision.1 = src-override-collision.1: The schema id ''{0}'' referenced by <{1}> is colliding with an already overridden schema. Referenced schema is being ignored.
+ src-override-collision.2 = src-override-collision.2: The override transformation of schema id ''{0}'' collides with an existing schema that was previously included, redefined, or overridden. Transformed schema is being ignored and override will not take place.
src-include.2.1 = src-include.2.1: The targetNamespace of the referenced schema, currently ''{1}'', must be identical to that of the including schema, currently ''{0}''.
src-redefine.2 = src-redefine.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-redefine.3.1 = src-redefine.3.1: The targetNamespace of the referenced schema, currently ''{1}'', must be identical to that of the redefining schema, currently ''{0}''.
@@ -160,6 +188,11 @@
src-simple-type.3.b = src-simple-type.3.b: A <list> element was found that has neither an itemType [attribute] nor a <simpleType> element among its [children]. One is required.
src-single-facet-value = src-single-facet-value: The facet ''{0}'' is defined more than once.
src-union-memberTypes-or-simpleTypes = src-union-memberTypes-or-simpleTypes: A <union> element must have either a non-empty memberTypes [attribute] or at least one <simpleType> element among its [children].
+ src-type-alternative.3.12.13.1 = src-type-alternative.3.12.13.1: Type atlernative has both a ''type'' attribute and a ''anonymous type'' child. Only one of these is allowed for a type alternative.
+ src-type-alternative.3.12.13.2 = src-type-alternative.3.12.13.2: Type definition missing for type atlernative. A ''type'' attribute, or a ''complexType'' child element, or a ''simpleType'' child element must be present.
+ src-wildcard.1 = src-wildcard.1: The properties ''namespace'' and ''notNamespace'' cannot both be present in a wildcard declaration. Use only one of them.
+ src-cip.1 = src-cip.1: The attribute ''{0}'' does not belong to schema versioning namespace (http://www.w3.org/2007/XMLSchema-versioning). Only following attributes are available for schema versioning namespace : ''minVersion'', ''maxVersion'', ''typeAvailable'', ''typeUnavailable'', ''facetAvailable'' and ''facetUnavailable''.
+ src-assert.3.13.1 = src-assert.3.13.1: The mandatory attribute ''test'' does not appear on the element ''{0}'', within type definition ''{1}''.
#constraint valid (3.X.6)
@@ -169,14 +202,23 @@
a-props-correct.3 = a-props-correct.3: Attribute ''{0}'' cannot use ''fixed'' or ''default'', because the attribute''s '{'type definition'}' is ID, or is derived from ID.
au-props-correct.2 = au-props-correct.2: In the attribute declaration of ''{0}'', a fixed value of ''{1}'' was specified. So if the attribute use referring to ''{0}'' also has a '{'value constraint'}', it must be fixed and its value must be ''{1}''.
cos-all-limited.1.2 = cos-all-limited.1.2: An 'all' model group must appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition.
+ cos-all-limited.1.3 = cos-all-limited.1.3: When an xs:group particle occurs as child of xs:all, then following condition must hold on xs:group particle, '{'min occurs'}' = '{'max occurs'}' = 1.
cos-all-limited.2 = cos-all-limited.2: The '{'max occurs'}' of an element in an ''all'' model group must be 0 or 1. The value ''{0}'' for element ''{1}'' is invalid.
+ cos-all-limited.2-xs11 = cos-all-limited.2-xs11: Incorrect schema instruction ''{0}'' found as child of ''xs:group'' that is referred by this group reference. Groups that are referred from ''xs:all'', are allowed to contain only ''xs:all'' themselves.
cos-applicable-facets = cos-applicable-facets: Facet ''{0}'' is not allowed by type {1}.
cos-ct-extends.1.1 = cos-ct-extends.1.1: Type ''{0}'' was derived by extension from type ''{1}''. However, the ''final'' attribute of ''{1}'' forbids derivation by extension.
cos-ct-extends.1.4.3.2.2.1.a = cos-ct-extends.1.4.3.2.2.1.a: The content type of a derived type and that of its base must both be mixed or both be element-only. Type ''{0}'' is element only, but its base type is not.
cos-ct-extends.1.4.3.2.2.1.b = cos-ct-extends.1.4.3.2.2.1.b: The content type of a derived type and that of its base must both be mixed or both be element-only. Type ''{0}'' is mixed, but its base type is not.
+ cos-ct-extends.1.4.3.2.2.3 = cos-ct-extends.1.4.3.2.2.3: The open content of the base type is not absent and the content type of the derived type must have a ''suffix'' or ''interleave'' mode. Type ''{0}'' has an open content with a ''none'' mode.
+ cos-ct-extends.1.4.3.2.2.3.3 = cos-ct-extends.1.4.3.2.2.3.3: The open content of a derived type and that of its base must both have a ''suffix'' mode. Type ''{0}'' has an open content with a ''suffix'' mode, but its base type is not.
+ cos-ct-extends.1.4.3.2.2.3.4 = cos-ct-extends.1.4.3.2.2.3.4: The namespace constraint of the wildcard on the open content of the base type must be a subset of the namespace constraint of the wildcard on the open content of the derived type. This is not the case for type ''{0}''.
+ cos-content-act-restrict.5.3 = cos-content-act-restrict.5.3: Error for type ''{0}''. The attribute use ''{1}'' in this type has value of ''inheritable'', which is inconsistent with the value in the base type.
cos-element-consistent = cos-element-consistent: Error for type ''{0}''. Multiple elements with name ''{1}'', with different types, appear in the model group.
+ cos-element-consistent.4.a = cos-element-consistent.4: A wildcard matched a global element ''{0}'' whose type ''{1}'' is not validly derived from the type definition, ''{2}'', of a local element with the same name.
+ cos-element-consistent.4.b = cos-element-consistent.4: Error for type ''{0}''. Multiple elements with name ''{1}'', with non equivalent type tables, appear in the model group.
cos-list-of-atomic = cos-list-of-atomic: In the definition of list type ''{0}'', type ''{1}'' is an invalid list element type because it is not atomic (''{1}'' is either a list type, or a union type which contains a list).
cos-nonambig = cos-nonambig: {0} and {1} (or elements from their substitution group) violate \"Unique Particle Attribution\". During validation against this schema, ambiguity would be created for those two particles.
+ cos-particle-extends.3.1 = cos-particle-extends.3.1: When both a derived type and its base have particles with <all> as their '{'term'}'s, the minOccurs of the derived particle needs to be equal to that of its base.
cos-particle-restrict.a = cos-particle-restrict.a: Derived particle is empty, and base is not emptiable.
cos-particle-restrict.b = cos-particle-restrict.b: Base particle is empty, but derived particle is not.
cos-particle-restrict.2 = cos-particle-restrict.2: Forbidden particle restriction: ''{0}''.
@@ -211,6 +253,7 @@
e-props-correct.4 = e-props-correct.4: The '{'type definition'}' of element ''{0}'' is not validly derived from the '{'type definition'}' of the substitutionHead ''{1}'', or the '{'substitution group exclusions'}' property of ''{1}'' does not allow this derivation.
e-props-correct.5 = e-props-correct.5: A '{'value constraint'}' must not be present on element ''{0}'', because the element''s '{'type definition'}' or '{'type definition'}'''s '{'content type'}' is ID, or is derived from ID.
e-props-correct.6 = e-props-correct.6: Circular substitution group detected for element ''{0}''.
+ e-props-correct.7 = e-props-correct.7: Type alternative ''{1}'' is not xs:error or is not validly derived from the type definition, ''{2}'', of 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.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}''.
@@ -230,7 +273,7 @@
maxInclusive-valid-restriction.3 = maxInclusive-valid-restriction.3: Error for type ''{2}''. The maxInclusive value =''{0}'' must be >= minInclusive of the base type ''{1}''.
maxInclusive-valid-restriction.4 = maxInclusive-valid-restriction.4: Error for type ''{2}''. The maxInclusive value =''{0}'' must be > minExclusive of the base type ''{1}''.
maxLength-valid-restriction = maxLength-valid-restriction: In the definition of {2}, maxLength value = ''{0}'' must be <= that of the base type ''{1}''.
- mg-props-correct.2 = mg-props-correct.2: Circular definitions detected for group ''{0}''. Recursively following the '{'term'}' values of the particles leads to a particle whose '{'term'}' is the group itself.
+ mg-props-correct.2 = mg-props-correct.2: Circular definitions detected for group ''{0}''. Recursively following the '{'term'}' values of the particles leads to a particle whose '{'term'}' is the group itself.
minExclusive-less-than-equal-to-maxExclusive = minExclusive-less-than-equal-to-maxExclusive: In the definition of {2}, minExclusive value = ''{0}'' must be <= maxExclusive value = ''{1}''.
minExclusive-less-than-maxInclusive = minExclusive-less-than-maxInclusive: In the definition of {2}, minExclusive value = ''{0}'' must be < maxInclusive value = ''{1}''.
minExclusive-valid-restriction.1 = minExclusive-valid-restriction.1: Error for type ''{2}''. The minExclusive value =''{0}'' must be >= minExclusive of the base type ''{1}''.
@@ -275,12 +318,23 @@
# We're using sch-props-correct.2 instead of the old src-redefine.1
# src-redefine.1 = src-redefine.1: The component ''{0}'' is begin redefined, but its corresponding component isn't in the schema document being redefined (with namespace ''{2}''), but in a different document, with namespace ''{1}''.
sch-props-correct.2 = sch-props-correct.2: An XSD schema cannot contain two global components with the same name. This schema contains two occurrences of ''{0}''.
+ st-props-correct.1 = st-props-correct.1: ''itemType'' of xs:list and ''memberTypes'' of xs:union cannot refer to special types, xs:anyAtomicType or xs:anySimpleType. The ''{1}'' component of simpleType ''{0}'' violates this constraint.
st-props-correct.2 = st-props-correct.2: Circular definitions have been detected for simple type ''{0}''. This means that ''{0}'' is contained in its own type hierarchy, which is an error.
st-props-correct.3 = st-props-correct.3: Error for type ''{0}''. The value of '{'final'}' of the '{'base type definition'}', ''{1}'', forbids derivation by restriction.
totalDigits-valid-restriction = totalDigits-valid-restriction: In the definition of {2}, the value ''{0}'' for the facet ''totalDigits'' is invalid, because it must be <= the value for ''totalDigits'' which was set to ''{1}'' in one of the ancestor types.
+ wc-props-correct.2 = wc-props-correct.2: When a wildcard has a {variety} of 'not, the {namespaces} has to have at least one member.
+ wc-props-correct.4 = wc-props-correct.4: The namespace ''{0}'' for disallowed name ''{1}"" is not allowed by the wildcard.
whiteSpace-valid-restriction.1 = whiteSpace-valid-restriction.1: In the definition of {0}, the value ''{1}'' for the facet ''whitespace'' is invalid, because the value for ''whitespace'' has been set to ''collapse'' in one of the ancestor types.
whiteSpace-valid-restriction.2 = whiteSpace-valid-restriction.2: In the definition of {0}, the value ''preserve'' for the facet ''whitespace'' is invalid, because the value for ''whitespace'' has been set to ''replace'' in one of the ancestor types.
+ minScale-totalDigits = minScale-totalDigits: In the definition of {2}, value of minScale = ''{0}'' must be <= value of maxScale = ''{1}''.
+ cvc-maxScale-valid = cvc-maxScale-valid: For type {2}, and value {0}, it is an error for the value of precision ''{3}'' to be greater than the value of maxScale ''{1}''.
+ cvc-minScale-valid = cvc-minScale-valid: For type {2}, and value {0}, it is an error for the value of precision ''{3}'' to be less than the value of minScale ''{1}''.
+ cvc-explicitTimezone-valid = cvc-explicitTimezone-valid: Value ''{0}'' is not facet-valid with respect to explicitTimezone ''{1}'' for type ''{2}''.
+ maxScale-valid-restriction = maxScale-valid-restriction: In the definition of {2}, maxScale value = ''{0}'' must be <= that of the base type ''{1}''.
+ minScale-valid-restriction = minScale-valid-restriction: In the definition of {2}, minScale value = ''{0}'' must be >= that of the base type ''{1}''.
+ timezone-valid-restriction = timezone-valid-restriction: In the definition of {0}, the value ''{1}'' for the facet ''explicitTimezone'' is invalid, because the value for ''explicitTimezone'' has been set to ''{2}'' in one of the ancestor types.
+
#schema for Schemas
s4s-att-invalid-value = s4s-att-invalid-value: Invalid attribute value for ''{1}'' in element ''{0}''. Recorded reason: {2}
@@ -301,6 +355,9 @@
c-fields-xpaths = c-fields-xpaths: The field value = ''{0}'' is not valid.
c-general-xpath = c-general-xpath: The expression ''{0}'' is not valid with respect to the XPath subset supported by XML Schema.
c-general-xpath-ns = c-general-xpath-ns: A namespace prefix in XPath expression ''{0}'' was not bound to a namespace.
+ c-cta-xpath = c-cta-xpath: The XPath expression ''{0}'' couldn''t compile successfully in ''{1}'' mode, during CTA evaluation.
+ c-cta-xpath-b = c-cta-xpath-b: The CTA XPath expression such as (''{0}'') starting with / or // is not acceptable, while in ''{1}'' mode (since a CTA XPath tree is rooted at a parentless element).
+ c-cta-xpath-serr = c-cta-xpath-serr: The XPath expression ''{0}'' couldn''t compile successfully in ''{1}'' mode, during CTA evaluation. A static error ''{2}'' occured in the XPath expression.
c-selector-xpath = c-selector-xpath: The selector value = ''{0}'' is not valid; selector xpaths cannot contain attributes.
EmptyTargetNamespace = EmptyTargetNamespace: In schema document ''{0}'', the value of the ''targetNamespace'' attribute cannot be an empty string.
FacetValueFromBase = FacetValueFromBase: In the declaration of type ''{0}'', value ''{1}'' of facet ''{2}'' must be from the value space of the base type, ''{3}''.
@@ -320,4 +377,4 @@
jaxp12-schema-source-type.1 = The ''http://java.sun.com/xml/jaxp/properties/schemaSource'' property cannot have a value of type ''{0}''. Possible types of the value supported are String, File, InputStream, InputSource or an array of these types.
jaxp12-schema-source-type.2 = The ''http://java.sun.com/xml/jaxp/properties/schemaSource'' property cannot have an array value of type ''{0}''. Possible types of the array supported are Object, String, File, InputStream and InputSource.
jaxp12-schema-source-ns = When using an array of Objects as the value of the 'http://java.sun.com/xml/jaxp/properties/schemaSource' property, it is illegal to have two schemas that share the same target namespace.
-
+
diff --git a/src/org/apache/xerces/impl/scd/Axis.java b/src/org/apache/xerces/impl/scd/Axis.java
new file mode 100644
index 000000000..ce13501f5
--- /dev/null
+++ b/src/org/apache/xerces/impl/scd/Axis.java
@@ -0,0 +1,92 @@
+/*
+ * 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 org.apache.xerces.impl.scd;
+
+/**
+ * This class represents an Axis of a Step
+ * @author Ishan Jayawardena udeshike@gmail.com
+ * @version $Id$
+ */
+final class Axis {
+ private Axis() {}
+ public static final String[] AXIS_TYPES = {
+ "schemaAttribute", "schemaElement", "type", "attributeGroup", "group",
+ "identityConstraint", "assertion", "alternative", "notation", "model",
+ "anyAttribute", "any", "facet", "scope", "context",
+ "substitutionGroup", "baseType", "itemType", "memberType", "primitiveType",
+ "key", "annotation", "component", "currentComponent", "attributeUse",
+ "particle", null};
+
+ public static final short SCHEMA_ATTRIBUTE = 0;
+ public static final short SCHEMA_ELEMENT = 1;
+ public static final short TYPE = 2;
+ public static final short ATTRIBUTE_GROUP = 3;
+ public static final short GROUP = 4;
+ public static final short IDENTITY_CONSTRAINT= 5;
+ public static final short ASSERTION = 6;
+ public static final short ALTERNATIVE = 7;
+ public static final short NOTATION = 8;
+ public static final short MODEL = 9;
+ public static final short ANY_ATTRIBUTE = 10;
+ public static final short ANY = 11;
+ public static final short FACET = 12;
+ public static final short SCOPE = 13;
+ public static final short CONTEXT = 14;
+ public static final short SUBSTITUTION_GROUP = 15;
+ public static final short BASE_TYPE = 16;
+ public static final short ITEM_TYPE = 17;
+ public static final short MEMBER_TYPE = 18;
+ public static final short PRIMITIVE_TYPE = 19;
+ public static final short KEY = 20;
+ public static final short ANNOTATION = 21;
+ public static final short COMPONENT = 22;
+ public static final short CURRENT_COMPONENT = 23;
+ public static final short ATTRIBUTE_USE = 24;
+ public static final short PARTICLE = 25;
+ public static final short EXTENSION_AXIS = 26;
+ public static final short SPECIAL_COMPONENT = 27;
+
+ private static final short UNKNOWN_AXIS = -1;
+ public static final short NO_AXIS = 100;
+
+ /**
+ * returns the string representation of an axis
+ * @param axis the input axis type
+ * @return the name of the axis type as a string
+ */
+ public static String axisToString(short axis) {
+ if (axis >= 0 && axis < AXIS_TYPES.length) {
+ return AXIS_TYPES[axis];
+ }
+ return null;
+ }
+
+ /**
+ * returns the axis type of a name
+ * @param name : the qname that needs to be tested against the axis names
+ * @return the axis type of the qname
+ */
+ public static short qnameToAxis(String name) {
+ for (short i = 0; i < AXIS_TYPES.length; ++i) {
+ if (AXIS_TYPES[i].equals(name)) {
+ return i;
+ }
+ }
+ return UNKNOWN_AXIS;
+ }
+} // class Axis
\ No newline at end of file
diff --git a/src/org/apache/xerces/impl/xs/identity/UniqueOrKey.java b/src/org/apache/xerces/impl/scd/SCDException.java
similarity index 53%
copy from src/org/apache/xerces/impl/xs/identity/UniqueOrKey.java
copy to src/org/apache/xerces/impl/scd/SCDException.java
index 51c4555eb..46992568d 100644
--- a/src/org/apache/xerces/impl/xs/identity/UniqueOrKey.java
+++ b/src/org/apache/xerces/impl/scd/SCDException.java
@@ -15,35 +15,39 @@
* limitations under the License.
*/
-package org.apache.xerces.impl.xs.identity;
+package org.apache.xerces.impl.scd;
/**
- * Schema unique or key identity constraint.
- * These two kinds of identity constraint have been combined to save
- * the creation of a separate Vector object for any element that
- * has both. A short int is used to distinguish which this object is.
- *
- * @xerces.internal
- *
- * @author Andy Clark, IBM
+ * @author Ishan Jayawardena udeshike@gmail.com
* @version $Id$
*/
-public class UniqueOrKey
- extends IdentityConstraint {
+public class SCDException extends Exception {
+ /** Serialization version. */
+ static final long serialVersionUID = -948482312169512085L;
+
+ // Data
+
+ // hold the value of the key this Exception refers to.
+ private final String fKey;
//
// Constructors
//
- /** Constructs a unique or a key identity constraint. */
- public UniqueOrKey(String namespace, String identityConstraintName,
- String elemName, short type) {
- super(namespace, identityConstraintName, elemName);
- this.type = type;
- } // <init>(String,String)
+ /** Constructs an exception. */
+ public SCDException() {
+ super();
+ fKey = "c-general-SCDParser";
+ } // <init>()
- //
- // Public methods
- //
+ /** Constructs an exception with the specified key. */
+ public SCDException(String key) {
+ super();
+ fKey = key;
+ } // <init>(String)
+
+ public String getKey() {
+ return fKey;
+ } // getKey(): String
-} // class Unique
+} // class SCDException
diff --git a/src/org/apache/xerces/impl/scd/SCDParser.java b/src/org/apache/xerces/impl/scd/SCDParser.java
new file mode 100644
index 000000000..77343da06
--- /dev/null
+++ b/src/org/apache/xerces/impl/scd/SCDParser.java
@@ -0,0 +1,488 @@
+/*
+ * 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 org.apache.xerces.impl.scd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.xerces.util.NamespaceSupport;
+import org.apache.xerces.util.XML11Char;
+//import org.apache.xml.serializer.utils.XML11Char;
+import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
+
+/**
+ * This class handles the parsing of relative/incomplete SCDs/SCPs
+ * @author Ishan Jayawardena udeshike@gmail.com
+ * @version $Id$
+ */
+class SCDParser {
+ private List steps;
+ private static final int CHARTYPE_AT = 1; // @
+ private static final int CHARTYPE_TILDE = 2; // ~
+ private static final int CHARTYPE_PERIOD = 3; // .
+ private static final int CHARTYPE_STAR = 4; // *
+ private static final int CHARTYPE_ZERO = 5; // 0
+ private static final int CHARTYPE_1_THROUGH_9 = 6; // [1-9]
+ private static final int CHARTYPE_NC_NAMESTART = 7; // XML11Char.NCNameStart
+ private static final int CHARTYPE_NC_NAME = 8; // XML11Char.NCName
+ private static final int CHARTYPE_OPEN_BRACKET = 9; // [
+ private static final int CHARTYPE_CLOSE_BRACKET = 10;// ]
+ private static final int CHARTYPE_OPEN_PAREN = 11; // (
+ private static final int CHARTYPE_CLOSE_PAREN = 12; // )
+ private static final int CHARTYPE_COLON = 13; // :
+ private static final int CHARTYPE_SLASH = 14; // /
+ private static final int CHARTYPE_NOMORE = 0;
+ private static final short LIST_SIZE = 15;
+
+ public SCDParser() {
+ steps = new ArrayList(LIST_SIZE);
+ }
+
+ private static int getCharType(int c) throws SCDException {
+ switch (c) {
+ case '@':
+ return CHARTYPE_AT;
+ case '~':
+ return CHARTYPE_TILDE;
+ case '.':
+ return CHARTYPE_PERIOD;
+ case '*':
+ return CHARTYPE_STAR;
+ case ':':
+ return CHARTYPE_COLON;
+ case '/':
+ return CHARTYPE_SLASH;
+ case '(':
+ return CHARTYPE_OPEN_PAREN;
+ case ')':
+ return CHARTYPE_CLOSE_PAREN;
+ case '[':
+ return CHARTYPE_OPEN_BRACKET;
+ case ']':
+ return CHARTYPE_CLOSE_BRACKET;
+ case '0':
+ return CHARTYPE_ZERO;
+ }
+ if (c == CHARTYPE_NOMORE) {
+ return CHARTYPE_NOMORE;
+ }
+ if (c >= '1' && c <= '9') {
+ return CHARTYPE_1_THROUGH_9;
+ }
+ if (XML11Char.isXML11NCNameStart(c)) {
+ return CHARTYPE_NC_NAMESTART;
+ }
+ if (XML11Char.isXML11NCName(c)) {
+ return CHARTYPE_NC_NAME;
+ }
+ throw new SCDException("Error in SCP: Unsupported character "
+ + (char) c + " (" + c + ")");
+ }
+
+ public static char charAt(String s, int position) {
+ if (position >= s.length()) {
+ return (char) -1; // TODO: throw and exception instead?
+ //throw new SCDException("Error in SCP: No more characters in the SCP string");
+ }
+ return s.charAt(position);
+ }
+
+ private static QName readQName(String step, int[] finalPosition, int currentPosition, NamespaceContext nsContext)
+ throws SCDException {
+ return readNameTest(step, finalPosition, currentPosition, nsContext);
+ }
+
+ /**
+ * TODO: this is the wild card name test
+ */
+ public static final QName WILDCARD = new QName(null, "*", "*", null);
+
+ /**
+ * TODO: this is the name test zero
+ */
+ public static final QName ZERO = new QName(null, "0", "0", null);
+
+ /*
+ * Similar to readQName() method. But this method additionally tests for another two types
+ * of name tests. i.e the wildcard name test and the zero name test.
+ */
+ private static QName readNameTest(String step, int[] finalPosition, int currentPosition, NamespaceContext nsContext)
+ throws SCDException {
+ int initialPosition = currentPosition;
+ int start = currentPosition;
+ String prefix = ""; // for the default namespace
+ String localPart = null;
+ if (charAt(step, currentPosition) == '*') {
+ finalPosition[0] = currentPosition + 1;
+ return WILDCARD;
+ } else if (charAt(step, currentPosition) == '0') {
+ finalPosition[0] = currentPosition + 1;
+ return ZERO;
+ // prefix, localPart, rawname, uri;
+ } else if (XML11Char.isXML11NCNameStart(charAt(step, currentPosition))) {
+ while (XML11Char.isXML11NCName(charAt(step, ++currentPosition))) {}
+ prefix = step.substring(initialPosition, currentPosition);
+ if (charAt(step, currentPosition) == ':') {
+ if (XML11Char
+ .isXML11NCNameStart(charAt(step, ++currentPosition))) {
+ initialPosition = currentPosition;
+ while (XML11Char.isXML11NCName(charAt(step,
+ currentPosition++))) {
+ }
+ localPart = step.substring(initialPosition,
+ currentPosition - 1);
+ }
+ if (localPart == null) {
+ localPart = prefix;
+ prefix = "";
+ }
+ finalPosition[0] = currentPosition - 1;
+ } else {
+ finalPosition[0] = currentPosition;
+ localPart = prefix;
+ prefix = "";
+ }
+ String rawname = step.substring(start, finalPosition[0]);
+ if (nsContext != null) {
+ // it a field
+ String uri = nsContext.getURI(prefix.intern());
+ if ("".equals(prefix)) { // default namespace.
+ return new QName(prefix, localPart, rawname, uri);
+ } else if (uri != null) {
+ // just use uri != null test here!
+ return new QName(prefix, localPart, rawname, uri);
+ }
+ throw new SCDException("Error in SCP: The prefix \"" + prefix
+ + "\" is undeclared in this context");
+ }
+ throw new SCDException("Error in SCP: Namespace context is null");
+ }
+ throw new SCDException("Error in SCP: Invalid nametest starting character \'"
+ + charAt(step, currentPosition) + "\'");
+ } // readNameTest()
+
+ private static int scanNCName(String data, int currentPosition) {
+ if (XML11Char.isXML11NCNameStart(charAt(data, currentPosition))) {
+ while (XML11Char.isXML11NCName(charAt(data, ++currentPosition))) {
+ }
+ }
+ return currentPosition;
+ }
+
+ /* scans a XML namespace Scheme Data section
+ * [2] EscapedNamespaceName ::= EscapedData*
+ * [6] SchemeData ::= EscapedData*
+ * [7] EscapedData ::= NormalChar | '^(' | '^)' | '^^' | '(' SchemeData ')'
+ * [8] NormalChar ::= UnicodeChar - [()^]
+ * [9] UnicodeChar ::= [#x0-#x10FFFF]
+ */
+ private static int scanXmlnsSchemeData(String data, int currentPosition) throws SCDException {
+ int c = 0;
+ int balanceParen = 0;
+ do {
+ c = charAt(data, currentPosition);
+ if (c >= 0x0 && c <= 0x10FFFF) { // unicode char
+ if (c != '^') { // normal char
+ ++currentPosition;
+ if (c == '(') {
+ ++balanceParen;
+ } else if (c == ')') { // can`t be empty '(' xmlnsSchemeData ')'
+ --balanceParen;
+ if (balanceParen == -1) {
+ // this is the end
+ return currentPosition - 1;
+ }
+ if (charAt(data, currentPosition - 2) == '(') {
+ throw new SCDException(
+ "Error in SCD: empty xmlns scheme data between '(' and ')'");
+ }
+ }
+ } else { // check if '^' is used as an escape char
+ if (charAt(data, currentPosition + 1) == '('
+ || charAt(data, currentPosition + 1) == ')'
+ || charAt(data, currentPosition + 1) == '^') {
+ currentPosition = currentPosition + 2;
+ } else {
+ throw new SCDException("Error in SCD: \'^\' character is used as a non escape character at position "
+ + ++currentPosition);
+ }
+ }
+ } else {
+ throw new SCDException("Error in SCD: the character \'" + c + "\' at position "
+ + ++currentPosition + " is invalid for xmlns scheme data");
+ }
+ } while (currentPosition < data.length());
+ String s = "";
+ if (balanceParen != -1) { // checks unbalanced l parens only.
+ s = "Unbalanced parentheses exist within xmlns scheme data section";
+ }
+ throw new SCDException("Error in SCD: Attempt to read an invalid xmlns Scheme data. " + s);
+ }
+
+ private static int skipWhiteSpaces(String data, int currentPosition) {
+ while (XML11Char.isXML11Space(charAt(data, currentPosition))) {
+ ++currentPosition; // this is important
+ }
+ return currentPosition;
+ }
+
+ // Scans a predicate from the input string step
+ private static int readPredicate(String step, int[] finalPosition,
+ int currentPosition) throws SCDException {
+ // we've already seen a '['
+ int end = step.indexOf(']', currentPosition);
+ if (end >= 0) {
+ try {
+ int i = Integer.parseInt(step.substring(currentPosition, end)); // toString?
+ if (i > 0) {
+ finalPosition[0] = end + 1;
+ return i;
+ }
+ throw new SCDException("Error in SCP: Invalid predicate value "
+ + i);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ throw new SCDException(
+ "Error in SCP: A NumberFormatException occurred while reading the predicate");
+ }
+ }
+ throw new SCDException(
+ "Error in SCP: Attempt to read an invalid predicate starting from position "
+ + ++currentPosition);
+ } // readPredicate()
+
+ /**
+ * Processes the scp input string and seperates it into Steps
+ * @param scp the input string that contains an SCDParser
+ * @return a list of Steps contained in the SCDParser
+ */
+ public List parseSCP(String scp, NamespaceContext nsContext, boolean isRelative)
+ throws SCDException {
+ steps.clear();
+ Step step;
+
+ if (scp.length() == 1 && scp.charAt(0) == '/') { // read a schema
+ // schema step.
+ //System.out.println("<SCHEMA STEP>");
+ steps.add(new Step(Axis.NO_AXIS, null, 0));
+ return steps;
+ }
+ // check if this is an incomplete SCP
+ if (isRelative) {
+ if ("./".equals(scp.substring(0, 2))) {
+ scp = scp.substring(1);
+ } else if (scp.charAt(0) != '/') {
+ scp = '/' + scp;
+ } else {
+ throw new SCDException("Error in incomplete SCP: Invalid starting character");
+ }
+ }
+ int stepStart = 0;
+ int[] currentPosition = new int[] { 0 };
+ while (currentPosition[0] < scp.length()) {
+ if (charAt(scp, currentPosition[0]) == '/') {
+ if (charAt(scp, currentPosition[0] + 1) == '/') {
+ if (currentPosition[0] + 1 != scp.length() - 1) {
+ steps.add(new Step(Axis.SPECIAL_COMPONENT, WILDCARD, 0));
+ stepStart = currentPosition[0] + 2;
+ } else {
+ stepStart = currentPosition[0] + 1;
+ }
+ } else {
+ if (currentPosition[0] != scp.length() - 1) {
+ stepStart = currentPosition[0] + 1;
+ } else {
+ stepStart = currentPosition[0];
+ }
+ }
+ step = processStep(scp, currentPosition, stepStart, nsContext);
+ steps.add(step);
+ } else { // error: invalid scp. should start with a slash
+ throw new SCDException("Error in SCP: Invalid character \'"
+ + charAt(scp, currentPosition[0]) + " \' at position"
+ + currentPosition[0]);
+ }
+ }
+ return steps;
+ }
+
+ private static Step processStep(String step, int[] newPosition, int currentPosition, NamespaceContext nsContext)
+ throws SCDException {
+ short axis = -1;
+ QName nameTest = null;
+ int predicate = 0;
+
+ switch (getCharType(charAt(step, currentPosition))) { // 0
+ case CHARTYPE_AT: // '@'
+ axis = Axis.SCHEMA_ATTRIBUTE;
+ nameTest = readNameTest(step, newPosition, currentPosition + 1,
+ nsContext); // 1 handles *, 0, and QNames.
+ break;
+ case CHARTYPE_TILDE: // '~'
+ axis = Axis.TYPE;
+ nameTest = readNameTest(step, newPosition, currentPosition + 1,
+ nsContext); // 1
+ break;
+ case CHARTYPE_PERIOD: // '.'
+ axis = Axis.CURRENT_COMPONENT;
+ nameTest = WILDCARD;
+ newPosition[0] = currentPosition + 1;
+ break;
+ case CHARTYPE_ZERO: // '0'
+ axis = Axis.SCHEMA_ELEMENT; // Element without a name. This will
+ // never match anything.
+ nameTest = ZERO;
+ newPosition[0] = currentPosition + 1;
+ break;
+ case CHARTYPE_STAR: // '*'
+ axis = Axis.SCHEMA_ELEMENT;
+ nameTest = WILDCARD;
+ newPosition[0] = currentPosition + 1;
+ break;
+ case CHARTYPE_NC_NAMESTART: // isXML11NCNameStart()
+ QName name = readQName(step, newPosition, currentPosition,
+ nsContext); // 0 handles a and a:b
+ int newPos = newPosition[0];
+ if (newPosition[0] == step.length()) {
+ axis = Axis.SCHEMA_ELEMENT;
+ nameTest = name;
+ } else if (charAt(step, newPos) == ':'
+ && charAt(step, newPos + 1) == ':') {
+ // TODO: what to do with extension axes?
+ // Could be a hashtable look up; fail if extension axis
+ axis = Axis.qnameToAxis(name.rawname);
+ if (axis == Axis.EXTENSION_AXIS) {
+ throw new SCDException(
+ "Error in SCP: Extension axis {"+name.rawname+"} not supported!");
+ }
+ nameTest = readNameTest(step, newPosition, newPos + 2,
+ nsContext);
+ } else if (charAt(step, newPos) == '(') {
+ throw new SCDException(
+ "Error in SCP: Extension accessor not supported!");
+ } else if (charAt(step, newPos) == '/') { // /abc:def/...
+ axis = Axis.SCHEMA_ELEMENT;
+ nameTest = name;
+ return new Step(axis, nameTest, predicate);
+ } else { // /abc:def[6]
+ axis = Axis.SCHEMA_ELEMENT;
+ nameTest = name;
+ }
+ break;
+ default:
+ throw new SCDException("Error in SCP: Invalid character \'"
+ + charAt(step, currentPosition) + "\' at position "
+ + currentPosition);
+ }
+ if (newPosition[0] < step.length()) {
+ if (charAt(step, newPosition[0]) == '[') {
+ predicate = readPredicate(step, newPosition, newPosition[0] + 1); // Also consumes right-bracket
+ } else if (charAt(step, newPosition[0]) == '/') { // /a::a/a...
+ return new Step(axis, nameTest, predicate);
+ } else {
+ throw new SCDException("Error in SCP: Unexpected character \'"
+ + charAt(step, newPosition[0]) + "\' at position "
+ + newPosition[0]);
+ }
+ // TODO: handle what if not?
+ }
+ if (charAt(step, newPosition[0]) == '/') {// /abc:def[6]/...
+ return new Step(axis, nameTest, predicate);
+ }
+ if (newPosition[0] < step.length()) {
+ throw new SCDException("Error in SCP: Unexpected character \'"
+ + step.charAt(newPosition[0]) + "\' at the end");
+ }
+ return new Step(axis, nameTest, predicate);
+ } // processStep()
+
+ /**
+ * Creates a list of Step objects from the input relative SCD string by
+ * parsing it
+ * @param relativeSCD
+ * @param isIncompleteSCD if the relative SCD in the first parameter an incomplete SCD
+ * @return the list of Step objects
+ */
+ public List parseRelativeSCD(String relativeSCD, boolean isIncompleteSCD) throws SCDException {
+ // xmlns(p=http://example.com/schema/po)xscd(/type::p:USAddress)
+ int[] currentPosition = new int[] { 0 };
+ NamespaceContext nsContext = new NamespaceSupport();
+ //System.out.println("Relative SCD## " + relativeSCD);
+ while (currentPosition[0] < relativeSCD.length()) {
+ if ("xmlns".equals(relativeSCD.substring(currentPosition[0], currentPosition[0] + 5))) { // TODO catch string out of bound exception
+ currentPosition[0] = readxmlns(relativeSCD, nsContext, currentPosition[0] + 5);
+ } else if ("xscd".equals(relativeSCD.substring(currentPosition[0], currentPosition[0] + 4))) { // (/type::p:USAddress) part
+ // process xscd() part
+ String data = relativeSCD.substring(currentPosition[0] + 4, relativeSCD.length());
+ if (charAt(data, 0) == '('
+ && charAt(data, data.length() - 1) == ')') {
+ return parseSCP(data.substring(1, data.length() - 1), nsContext, isIncompleteSCD);
+ }
+ throw new SCDException("Error in SCD: xscd() part is invalid at position "
+ + ++currentPosition[0]);
+ } else {
+ throw new SCDException("Error in SCD: Expected \'xmlns\' or \'xscd\' at position "
+ + ++currentPosition[0]);
+ }
+ }
+ throw new SCDException("Error in SCD: Error at position "
+ + ++currentPosition[0]);
+ } // createSteps()
+
+ private static int readxmlns(String data, NamespaceContext nsContext,
+ int currentPosition) throws SCDException {
+ if (charAt(data, currentPosition++) == '(') {
+ // readNCName
+ int pos = currentPosition;
+ currentPosition = scanNCName(data, currentPosition);
+ if (currentPosition == pos) {
+ throw new SCDException(
+ "Error in SCD: Missing namespace name at position "
+ + ++currentPosition);
+ }
+ String name = data.substring(pos, currentPosition);
+ // skip S
+ currentPosition = skipWhiteSpaces(data, currentPosition);
+ // read '='
+ if (charAt(data, currentPosition) != '=') {
+ throw new SCDException("Error in SCD: Expected a \'=\' character at position "
+ + ++currentPosition);
+ }
+ // skip S
+ currentPosition = skipWhiteSpaces(data, ++currentPosition);
+ // read uri
+ pos = currentPosition;
+ currentPosition = scanXmlnsSchemeData(data, currentPosition);
+ if (currentPosition == pos) {
+ throw new SCDException("Error in SCD: Missing namespace value at position "
+ + ++currentPosition);
+ }
+ String uri = data.substring(pos, currentPosition);
+ if (charAt(data, currentPosition) == ')') {
+ nsContext.declarePrefix(name.intern(), uri.intern());
+ return ++currentPosition;
+ }
+ throw new SCDException("Error in SCD: Invalid xmlns pointer part at position "
+ + ++currentPosition);
+ }
+ throw new SCDException("Error in SCD: Invalid xmlns pointer part at position "
+ + ++currentPosition);
+ } // readxmlns()
+
+}
diff --git a/src/org/apache/xerces/impl/scd/SCDResolver.java b/src/org/apache/xerces/impl/scd/SCDResolver.java
new file mode 100644
index 000000000..956ef315b
--- /dev/null
+++ b/src/org/apache/xerces/impl/scd/SCDResolver.java
@@ -0,0 +1,1019 @@
+/*
+ * 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 org.apache.xerces.impl.scd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xs.XSAttributeDeclaration;
+import org.apache.xerces.xs.XSAttributeGroupDefinition;
+import org.apache.xerces.xs.XSAttributeUse;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSFacet;
+import org.apache.xerces.xs.XSIDCDefinition;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSModelGroup;
+import org.apache.xerces.xs.XSModelGroupDefinition;
+import org.apache.xerces.xs.XSMultiValueFacet;
+import org.apache.xerces.xs.XSNamedMap;
+import org.apache.xerces.xs.XSNotationDeclaration;
+import org.apache.xerces.xs.XSObject;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSParticle;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTerm;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.apache.xerces.xs.XSWildcard;
+
+/**
+ * Implements XML Schema: Component Designators (SCD)
+ * Currently, this implementation has following limitations<br>
+ * 1. the Schema Step is not supported<br>
+ * 2. the axis types; Extension axis, Assertions axis, Alternative axis, Context axis<br>
+ * are not supported<br>
+ * 3. Extension accessors are not supported<br>
+ * 4. the top level Identity Constraint Definitions components are not supported.<br>
+ * 5. all the other Schema 1.1 constructs that are not listed here, are not supported.<br>
+ * 6. the schemaAttribute axis does not work as it is expected in the specification.<br>
+ * 7. in some situations, the SCPs that have been reduced by the elided-componet axis do not<br>
+ * produce expected results<br>
+ * 8. the fundamental facets are not supported (but the constraining facets are supported).<br>
+ * @author Ishan Jayawardena <ud...@gmail.com>
+ * @version $Id$
+ */
+public class SCDResolver {
+ private XSModel xsModel;
+ private List result;
+ private List currentComponents;
+ private SCDParser parser;
+ private static final short NO_FILTER = -1;
+ /*
+ * Please note that the spec has some flaws regarding some of the facts mentioned in it
+ * and therefore we could not interpret the correct meaning of them.
+ * But we assumed the intended behavior, i.e. the behavior the spec might have expected and
+ * implemented according to it.
+ * By setting the following variable's (i.e.IS_SPEC_COMPLIANT) value to false,
+ * we can test the behavior of the resolver as we assumed it,
+ * but it's not compliant with the spec. By setting its to true,
+ * we can test the resolver's behavior in the spec compliant manner
+ * (but under this behavior, the parser will not produce any output).
+ */
+ private static final boolean IS_SPEC_COMPLIANT = false;
+ private static final short LIST_SIZE = 30;
+
+ /**
+ * Constructor
+ * @param xsModel the schema description schema component
+ */
+ public SCDResolver(XSModel xsModel) {
+ this.xsModel = xsModel;
+ result = new ArrayList(LIST_SIZE);
+ currentComponents = new ArrayList(LIST_SIZE);
+ parser = new SCDParser();
+ }
+
+ /**
+ * Resolves a relative SCD against the schema description schema component (i.e. the XSModel).
+ * @param relativeSCD the input relative SCD string in the form of,<br>
+ * <code>[5] RelativeSchemaComponentDesignator ::= XmlnsPointerPart* XscdPointerPart</code><br>
+ * e.g. <code>xmlns(p=http://www.example.com/schema/po)xscd(/type::p:SKU/facet::pattern)</code>
+ * @return a list of XML schema components that are designated by the SCD, otherwise and empty
+ * <code>XSObjectList</code>
+ */
+ public XSObjectList resolve(String relativeSCD) throws SCDException {
+ List steps = parser.parseRelativeSCD(relativeSCD, false);
+ if (steps.size() == 1
+ && ((Step) steps.get(0)).getAxisType() == Axis.NO_AXIS
+ && ((Step) steps.get(0)).getNametest() == null
+ && ((Step) steps.get(0)).getPredicate() == 0) {
+ // this is the schema step. i.e the SCP '/'
+ // return xsModel; this is the ideal case
+ // we return an exception instead since XSModel does not implement
+ // XSObject interface yet
+ throw new SCDException("Error in SCD: Schema step is not supported");
+ }
+ // apply the first step out from out side
+ // TODO: this is strange but this what the spec says and this can be
+ // changed in a better way if the spec changes
+ result.clear();
+ applyFirstStep((Step) steps.get(0));
+ return evaluate(steps, 1);
+ }
+
+ /**
+ * Resolves an SCP against the schema description schema component (i.e. the XSModel).
+ * @param scp the input SCP to designate the components.<br>
+ * e.g. <code>/type::p:SKU/facet::pattern</code>
+ * @param nsContext namespace context details for the component names used in the SCP string
+ * @return a list of XML schema components that are designated by the SCP, otherwise and empty
+ * <code>XSObjectList</code>
+ */
+ public XSObjectList resolve(String scp, NamespaceContext nsContext)
+ throws SCDException {
+ List steps = parser.parseSCP(scp, nsContext, false);
+ if (steps.size() == 1
+ && ((Step) steps.get(0)).getAxisType() == Axis.NO_AXIS
+ && ((Step) steps.get(0)).getNametest() == null
+ && ((Step) steps.get(0)).getPredicate() == 0) {
+ // this is the schema step. i.e the SCP '/'
+ // return xsModel; this is the ideal case.
+ // we return an exception instead since XSModel does not implement
+ // XSObject interface yet
+ throw new SCDException("Error in SCD: Schema step is not supported");
+ }
+ // apply the first step out from out side
+ // TODO: this is strange but this what the spec says and this can be
+ // changed in a better way if the spec changes
+ result.clear();
+ applyFirstStep((Step) steps.get(0));
+ return evaluate(steps, 1);
+ }
+
+ /**
+ * Resolves an incomplete SCP against a given schema component
+ * @param incompleteSCP the incomplete SCP.
+ * To emphasize the incompleteness of such paths, the current component step syntax may be used
+ * (.) for the head step. For example, if the initial source component is a complex type,
+ * the following paths are equivalent and designate the element declaration with the QName
+ * my:section within the sequence model group of that type:<br>
+ * <code>model::sequence/schemaElement::my:section</code><br>
+ * <code>./model::sequence/schemaElement::my:section</code>
+ * @param nsContext namespace context details for the component names used in the
+ * incomplete SCP string
+ * @param currentComponent the initial source component
+ * @return the list of schema components that are designated by the incomplete SCP,
+ * otherwise an empty <code>XSObjectList</code>.
+ */
+ public XSObjectList resolve(String incompleteSCP,
+ NamespaceContext nsContext, XSObject currentComponent)
+ throws SCDException {
+ List steps = parser.parseSCP(incompleteSCP, nsContext, true);
+ result.clear();
+ result.add(currentComponent);
+ return evaluate(steps, 0);
+ }
+
+ /**
+ * Resolves an incomplete SCD against a given schema component
+ * @param incompleteSCD the incomplete SCD string. which is in the form of <br>
+ * <code>[5] RelativeSchemaComponentDesignator ::= XmlnsPointerPart* XscdPointerPart</code><br>
+ * but <code>XscdPointerPart</code> contains an incomplete SCP instead of a complete SCP. <br>
+ * e.g. <code>xmlns(p=http://www.example.com/schema/po)xscd(./type::p:SKU/facet::pattern)</code>
+ * or <code>xmlns(p=http://www.example.com/schema/po)xscd(type::p:SKU/facet::pattern)</code><br>
+ * i.e. an incomplete SCP must not start with a '/'.
+ * @param currentComponent the initial source component
+ * @return the list of schema components that are designated by the incomplete SCP,
+ * otherwise an empty <code>XSObjectList</code>.
+ */
+ public XSObjectList resolve(String incompleteSCD, XSObject currentComponent)
+ throws SCDException {
+ List steps = parser.parseRelativeSCD(incompleteSCD, true);
+ result.clear();
+ result.add(currentComponent);
+ return evaluate(steps, 0);
+ }
+
+ private XSObjectList evaluate(List steps, int startingStep) throws SCDException {
+ for (int i = startingStep, nSteps = steps.size(); i < nSteps; ++i) {
+ currentComponents.clear();
+ Step step = (Step)steps.get(i);
+ short axisType = step.getAxisType();
+ for (int j = 0, n = result.size(); j < n; ++j) {
+ currentComponents.add(result.get(j));
+ }
+ if (axisType != Axis.SPECIAL_COMPONENT) {
+ for (int j = 0, n = currentComponents.size(); j < n; ++j) {
+ addElidedComponents((XSObject)currentComponents.get(j));
+ }
+ }
+ result.clear();
+ applyStep(step);
+ if (axisType == Axis.SPECIAL_COMPONENT) {
+ step = (Step) steps.get(++i); // TODO: is this correct?
+ // copy result => currentComps
+ List tmp = currentComponents;
+ currentComponents = result;
+ result = tmp;
+ result.clear();
+ applyStep(step);
+ }
+ }
+ XSObjectListImpl resultComps = new XSObjectListImpl();
+ for (int i = 0, n = result.size(); i < n; ++i) {
+ resultComps.addXSObject((XSObject)result.get(i));
+ }
+ return resultComps;
+ }
+
+ private void addElidedComponents(XSObject sourceComponent) {
+ // these are the components returned from the term() accessor whose component-kind() is equal to xscd:model-group
+ // currentComponents.size() gets changed in each iteration
+ for (int i = currentComponents.size() - 1; i < currentComponents.size(); ++i) {
+ term((XSObject)currentComponents.get(i), XSConstants.MODEL_GROUP, SCDParser.WILDCARD, currentComponents);
+ }
+
+ switch (sourceComponent.getType()) {
+ case XSConstants.ELEMENT_DECLARATION: {
+ XSObject typeDef = ((XSElementDeclaration)sourceComponent).getTypeDefinition();
+ if (typeDef != null && !currentComponents.contains(typeDef)) {
+ currentComponents.add(typeDef);
+ }
+ }
+ break;
+ case XSConstants.ATTRIBUTE_DECLARATION: {
+ XSObject typeDef = ((XSAttributeDeclaration)sourceComponent).getTypeDefinition();
+ if (typeDef != null && !currentComponents.contains(typeDef)) {
+ currentComponents.add(typeDef);
+ }
+ }
+ break;
+ }
+ // TODO: we dont have type alternative for now.
+ } // getElidedComponents()
+
+ // apply the first step for the components of result
+ private void applyFirstStep(Step step) throws SCDException {
+ XSNamedMap map = null;
+
+ switch (step.getAxisType()) {
+ case Axis.ANNOTATION:
+ XSObjectList annotations = xsModel.getAnnotations();
+ for (int i = 0, n = annotations.size(); i < n; ++i) {
+ addComponent(annotations.item(i), step.getNametest(), result);
+ }
+ break;
+ case Axis.SCHEMA_ELEMENT:
+ map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+ break;
+ case Axis.TYPE:
+ map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
+ break;
+ case Axis.SCHEMA_ATTRIBUTE:
+ map = xsModel.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
+ break;
+ case Axis.ATTRIBUTE_GROUP:
+ map = xsModel.getComponents(XSConstants.ATTRIBUTE_GROUP);
+ break;
+ case Axis.GROUP:
+ map = xsModel.getComponents(XSConstants.MODEL_GROUP_DEFINITION); // TODO: correct?
+ break;
+ case Axis.NOTATION:
+ map = xsModel.getComponents(XSConstants.NOTATION_DECLARATION);
+ break;
+ case Axis.COMPONENT:
+ case Axis.SPECIAL_COMPONENT: {
+ currentComponents.clear();
+ addTopLevelComponents(step.getNametest());
+ int size = currentComponents.size();
+ for (int i = 0; i < currentComponents.size(); ++i) {
+ componentChildren((XSObject)currentComponents.get(i), NO_FILTER, SCDParser.WILDCARD, currentComponents);
+ }
+ int start = step.getAxisType() == Axis.SPECIAL_COMPONENT ? 0 : size;
+ for (int i = start; i < currentComponents.size(); ++i) {
+ addComponent((XSObject)currentComponents.get(i), step.getNametest(), result);
+ }
+ }
+ break;
+ default:
+ throw new SCDException("Error in SCD: Unsupported top level component type "
+ + step.getAxisName());
+ }
+ if (map != null && !map.isEmpty()) {
+ for (int i = 0, n = map.size(); i < n; ++i) {
+ addComponent(map.item(i), step.getNametest(), result);
+ }
+ }
+ applyPredicate(step.getPredicate());
+ } // applyFirstStep()
+
+ // apply the step for the components of result.
+ // starting from the second step of the step list of a given SCP
+ private void applyStep(Step step) throws SCDException {
+ switch (step.getAxisType()) {
+ case Axis.SCHEMA_ELEMENT:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ term((XSObject)currentComponents.get(i), XSConstants.ELEMENT_DECLARATION, step.getNametest(), result);
+ }
+ break;
+ case Axis.SCHEMA_ATTRIBUTE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.ATTRIBUTE_DECLARATION, step.getNametest(), result);
+ }
+ break;
+ case Axis.TYPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentChildren((XSObject)currentComponents.get(i), XSConstants.TYPE_DEFINITION, step.getNametest(), result);
+ }
+ break;
+ case Axis.CURRENT_COMPONENT:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ result.add(currentComponents.get(i));
+ }
+ return;
+ case Axis.COMPONENT: // TODO: correct?
+ case Axis.SPECIAL_COMPONENT: {
+ int size = currentComponents.size();
+ for (int i = 0; i < currentComponents.size(); ++i) {
+ componentChildren((XSObject)currentComponents.get(i), NO_FILTER, SCDParser.WILDCARD, currentComponents);
+ }
+ int start = step.getAxisType() == Axis.SPECIAL_COMPONENT ? 0 : size;
+ for (int i = start; i < currentComponents.size(); ++i) {
+ addComponent((XSObject)currentComponents.get(i), step.getNametest(), result);
+ }
+ }
+ break;
+ case Axis.ATTRIBUTE_GROUP:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.ATTRIBUTE_GROUP, step.getNametest(), result);
+ }
+ break;
+ case Axis.GROUP:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.MODEL_GROUP_DEFINITION, step.getNametest(), result);
+ }
+ break;
+ case Axis.IDENTITY_CONSTRAINT:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.IDENTITY_CONSTRAINT, step.getNametest(), result);
+ }
+ break;
+ case Axis.ASSERTION:
+ // TODO: we do not support this yet. Schema 1.1
+ throw new SCDException("Error in SCD: Assertion axis is not supported");
+ //break;
+ case Axis.ALTERNATIVE:
+ // TODO: we do not support this yet. is Schema 1.1
+ throw new SCDException("Error in SCD: Alternative axis is not supported");
+ //break;
+ case Axis.NOTATION:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.NOTATION_DECLARATION, step.getNametest(), result);
+ }
+ break;
+ case Axis.MODEL:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ term((XSObject)currentComponents.get(i), XSConstants.MODEL_GROUP, step.getNametest(), result);
+ }
+ break;
+ case Axis.ANY_ATTRIBUTE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ XSObject comp = ((XSObject)currentComponents.get(i));
+ short type = comp.getType();
+ if (type == XSConstants.TYPE_DEFINITION) {
+ type = ((XSTypeDefinition)comp).getTypeCategory();
+ if (type == XSTypeDefinition.COMPLEX_TYPE) {
+ addComponent(((XSComplexTypeDefinition)comp).getAttributeWildcard(),
+ step.getNametest(), result);
+ }
+
+ } else if (type == XSConstants.ATTRIBUTE_GROUP) {
+ addComponent(((XSAttributeGroupDefinition)comp).getAttributeWildcard(),
+ step.getNametest(), result);
+ }
+ }
+ break;
+ case Axis.ANY:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ term((XSObject)currentComponents.get(i), XSConstants.WILDCARD, step.getNametest(), result);
+ }
+ break;
+ case Axis.FACET: // we are returning the part of thefacets. a limitation
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentLinked((XSObject)currentComponents.get(i), XSConstants.FACET, step.getNametest(), result);
+ }
+ break;
+ case Axis.SCOPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ componentScope((XSObject)currentComponents.get(i), result);
+ }
+ break;
+ case Axis.CONTEXT:
+ // TODO: we do not support this yet. is Schema 1.1
+ throw new SCDException("Error in SCD: Context axis is not supported");
+ //break;
+ case Axis.SUBSTITUTION_GROUP:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (comp.getType() == XSConstants.ELEMENT_DECLARATION) {
+ addComponent(((XSElementDeclaration)comp).getSubstitutionGroupAffiliation(),
+ step.getNametest(), result);
+ }
+ }
+ break;
+ case Axis.BASE_TYPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ if (((XSObject)currentComponents.get(i)).getType() == XSConstants.TYPE_DEFINITION) {
+ addComponent((((XSTypeDefinition)currentComponents.get(i))).getBaseType(),
+ step.getNametest(), result);
+ }
+ }
+ break;
+ case Axis.ITEM_TYPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ if (((XSObject)currentComponents.get(i)).getType() == XSConstants.TYPE_DEFINITION) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ addComponent(((XSSimpleTypeDefinition)comp).getItemType(),
+ step.getNametest(), result);
+ }
+ }
+ }
+ break;
+ case Axis.MEMBER_TYPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ if (((XSObject)currentComponents.get(i)).getType() == XSConstants.TYPE_DEFINITION) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ XSObjectList memberTypes = ((XSSimpleTypeDefinition)comp).getMemberTypes();
+ for (int j = 0, nt = memberTypes.size(); j < nt; ++j) {
+ addComponent((XSObject)memberTypes.get(j), step.getNametest(), result);
+ }
+ }
+ }
+ }
+ break;
+ case Axis.PRIMITIVE_TYPE:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ if (((XSObject)currentComponents.get(i)).getType() == XSConstants.TYPE_DEFINITION) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ addComponent(((XSSimpleTypeDefinition)comp).getPrimitiveType(),
+ step.getNametest(), result);
+ }
+ }
+ }
+ break;
+ case Axis.KEY:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ if (((XSObject)currentComponents.get(i)).getType() == XSConstants.IDENTITY_CONSTRAINT) {
+ addComponent(((XSIDCDefinition)currentComponents.get(i)).getRefKey(),
+ step.getNametest(), result);
+ }
+ }
+ break;
+ case Axis.ANNOTATION:
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ annotations((XSObject)currentComponents.get(i), result);
+ }
+ break;
+ case Axis.ATTRIBUTE_USE: {
+ XSObjectList attribUses = null;
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (comp.getType() == XSConstants.TYPE_DEFINITION) {
+ if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+ attribUses = ((XSComplexTypeDefinition)comp).getAttributeUses();
+ }
+ } else if (comp.getType() == XSConstants.ATTRIBUTE_GROUP) {
+ attribUses = ((XSAttributeGroupDefinition)comp).getAttributeUses();
+ }
+ if (attribUses != null) {
+ for (int j = 0, na = attribUses.size(); j < na; ++j) {
+ addComponent((XSObject)attribUses.get(j),
+ step.getNametest(), result);
+ }
+ }
+ }
+ }
+ break;
+ case Axis.PARTICLE: {
+ for (int i = 0, n = currentComponents.size(); i < n; ++i) {
+ XSObject comp = (XSObject)currentComponents.get(i);
+ if (comp.getType() == XSConstants.MODEL_GROUP) {
+ XSObjectList particles = ((XSModelGroup)comp).getParticles();
+ for (int j = 0, np = particles.size(); j < np; ++j) {
+ addComponent((XSObject) particles.get(j),
+ step.getNametest(), result);
+ }
+ }
+ }
+ }
+ break;
+ case Axis.EXTENSION_AXIS:
+ throw new SCDException("Error in SCD: Extension axis is not supported");
+ //break;
+ default:
+ throw new SCDException("Error in SCD: Unsupported axis type " + step.getAxisName());
+ }
+ applyPredicate(step.getPredicate());
+ } // applyStep()
+
+ private void addTopLevelComponents(QName nameTest) {
+ // get the annotations() components
+ XSObjectList annotations = xsModel.getAnnotations();
+ for (int i = 0, n = annotations.size(); i < n; ++i) {
+ addComponent(annotations.item(i), nameTest, result);
+ }
+ final short[] SCHEMA_COMPONENTS = new short[] {
+ XSConstants.ELEMENT_DECLARATION, XSConstants.TYPE_DEFINITION, XSConstants.ATTRIBUTE_DECLARATION,
+ XSConstants.ATTRIBUTE_GROUP, XSConstants.MODEL_GROUP_DEFINITION, XSConstants.NOTATION_DECLARATION,
+ // XSConstants.IDENTITY_CONSTRAINT // TODO: return empty. we don't support IDC at top level
+ };
+ XSNamedMap map;
+ for (int i = 0; i < SCHEMA_COMPONENTS.length; ++i) {
+ map = xsModel.getComponents(SCHEMA_COMPONENTS[i]);
+ if (!map.isEmpty()) {
+ for (int j = 0, n =map.size(); j < n; ++j) {
+ addComponent(map.item(i), nameTest, result);
+ }
+ }
+ }
+ } // getTopLevelComponents()
+
+ private void applyPredicate(int predicate) throws SCDException {
+ if (predicate == 0) {
+ return;
+ } else if (predicate > 0 && predicate <= result.size()) {
+ XSObject component = (XSObject)result.get(predicate - 1);
+ result.clear();
+ result.add(component);
+ } else {
+ throw new SCDException("Error in SCD: Invalid predicate value ("
+ + predicate + ") detected");
+ }
+ } // processPredicate()
+
+ // Described in section 4.5.6; term Accessor
+ private void term(XSObject sourceComponent, short filter, QName nameTest, List outputComponents) {
+ switch (sourceComponent.getType()) {
+ case XSConstants.MODEL_GROUP_DEFINITION:
+ if (NO_FILTER == filter || XSConstants.MODEL_GROUP == filter) {
+ addComponent(((XSModelGroupDefinition) sourceComponent).getModelGroup()
+ , nameTest, outputComponents);
+ }
+ break;
+ case XSConstants.TYPE_DEFINITION:
+ if (((XSTypeDefinition) sourceComponent).getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+ XSParticle particle = ((XSComplexTypeDefinition) sourceComponent).getParticle();
+ if (particle != null) {
+ XSTerm term = particle.getTerm();
+ if (NO_FILTER == filter || (term != null && term.getType() == filter)) {
+ addComponent(term, nameTest, outputComponents);
+ }
+ }
+ }
+ break;
+ case XSConstants.PARTICLE: {
+ XSTerm term = ((XSParticle) sourceComponent).getTerm();
+ if (NO_FILTER == filter || (term != null && term.getType() == filter)) {
+ addComponent(term, nameTest, outputComponents);
+ }
+ }
+ break;
+ case XSConstants.MODEL_GROUP:
+ if (IS_SPEC_COMPLIANT == false) {
+ XSObjectList particles = ((XSModelGroup) sourceComponent).getParticles();
+ for (int i = 0, n = particles.size(); i < n; ++i) {
+ XSObject term = ((XSParticle) particles.item(i)).getTerm();
+ if (NO_FILTER == filter
+ || (term != null && term.getType() == filter)) {
+ addComponent(term, nameTest, outputComponents); // nameTest
+ }
+ }
+
+ }
+ break;
+ }
+ } // term()
+
+ // Described in section 4.5.3; component-variety Accessor
+ private String componentVariety(XSObject component) {
+ // TODO: we only care about these three types of components
+ short type = component.getType();
+ if (type == XSConstants.MODEL_GROUP) {
+ switch (((XSModelGroup)component).getCompositor()) {
+ case XSModelGroup.COMPOSITOR_SEQUENCE:
+ return "sequence";
+ case XSModelGroup.COMPOSITOR_ALL:
+ return "all";
+ case XSModelGroup.COMPOSITOR_CHOICE:
+ return "choice";
+ }
+ } else if (type == XSConstants.FACET
+ || type == XSConstants.MULTIVALUE_FACET) {
+ short kind = NO_FILTER;
+ if (type == XSConstants.FACET) {
+ kind = ((XSFacet)component).getFacetKind();
+ } else {
+ kind = ((XSMultiValueFacet)component).getFacetKind();
+ }
+ switch (kind) { // TODO: which ones are the most frequently used ones?
+ case XSSimpleTypeDefinition.FACET_ENUMERATION:
+ return "enumeration";
+ case XSSimpleTypeDefinition.FACET_FRACTIONDIGITS:
+ return "fractionDigits";
+ case XSSimpleTypeDefinition.FACET_LENGTH:
+ return "length";
+ case XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE:
+ return "maxExclusive";
+ case XSSimpleTypeDefinition.FACET_MAXINCLUSIVE:
+ return "maxInclusive";
+ case XSSimpleTypeDefinition.FACET_MAXLENGTH:
+ return "maxLength";
+ case XSSimpleTypeDefinition.FACET_MINEXCLUSIVE:
+ return "minExclusive";
+ case XSSimpleTypeDefinition.FACET_MININCLUSIVE:
+ return "minInclusive";
+ case XSSimpleTypeDefinition.FACET_MINLENGTH:
+ return "minLength";
+ case XSSimpleTypeDefinition.FACET_PATTERN:
+ return "pattern";
+ case XSSimpleTypeDefinition.FACET_TOTALDIGITS:
+ return "totalDigits";
+ case XSSimpleTypeDefinition.FACET_WHITESPACE:
+ return "whiteSpace";
+ }
+ }
+ return null;
+ } // componentVariety()
+
+ // Described in section 4.5.5; component-linked Accessor
+ private void componentLinked(XSObject sourceComponent, short filter,
+ QName nameTest, List targetComponents) throws SCDException {
+ switch (sourceComponent.getType()) {
+ case XSConstants.ATTRIBUTE_DECLARATION: {
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) { // TODO: correct? check with the caller
+ if (((XSAttributeDeclaration)sourceComponent).getScope() == XSConstants.SCOPE_LOCAL) {
+ addComponent(((XSAttributeDeclaration)sourceComponent).getEnclosingCTDefinition(),
+ nameTest, targetComponents);
+ }
+ }
+ }
+ break;
+ case XSConstants.ELEMENT_DECLARATION: {
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) { // TODO: correct? check again
+ if (((XSElementDeclaration)sourceComponent).getScope() == XSConstants.SCOPE_LOCAL) {
+ addComponent(((XSElementDeclaration)sourceComponent).getEnclosingCTDefinition(),
+ nameTest, targetComponents);
+ }
+ }
+ if (NO_FILTER == filter || XSConstants.IDENTITY_CONSTRAINT == filter) {
+ XSNamedMap idcs = ((XSElementDeclaration)sourceComponent).getIdentityConstraints();
+ for (int i = 0, n = idcs.size(); i < n; ++i) {
+ addComponent(idcs.item(i),
+ nameTest, targetComponents);
+ }
+ }
+ if (NO_FILTER == filter || XSConstants.ELEMENT_DECLARATION == filter) {
+ addComponent(((XSElementDeclaration)sourceComponent).getSubstitutionGroupAffiliation(),
+ nameTest, targetComponents);
+ }
+ }
+ break;
+ case XSConstants.TYPE_DEFINITION:
+ if (((XSTypeDefinition)sourceComponent).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) {
+ addComponent(((XSSimpleTypeDefinition)sourceComponent).getBaseType(),
+ nameTest, targetComponents);
+ addComponent(((XSSimpleTypeDefinition)sourceComponent).getPrimitiveType(),
+ nameTest, targetComponents);
+ addComponent(((XSSimpleTypeDefinition)sourceComponent).getItemType(),
+ nameTest, targetComponents);
+ XSObjectList list = ((XSSimpleTypeDefinition)sourceComponent).getMemberTypes();
+ for (int i = 0, n = list.size(); i < n; ++i) {
+ addComponent(list.item(i), nameTest, targetComponents);
+ }
+ }
+ // TODO: {context} not supported since it's defined in Schema 1.1
+ } else { // a complex type
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) {
+ addComponent(((XSComplexTypeDefinition)sourceComponent).getBaseType(),
+ nameTest, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.WILDCARD == filter) {
+ addComponent(((XSComplexTypeDefinition)sourceComponent).getAttributeWildcard(),
+ nameTest, targetComponents);
+ }
+ // TODO: how to get these other components?
+ // {context} this is Schema 1.1 stuff
+ // {assertions} this is Schema 1.1 stuff
+ // {wildcard} of {open content} of {content type} this is also schema 1.1 stuff
+ }
+ break;
+ case XSConstants.ATTRIBUTE_USE:
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.ATTRIBUTE_GROUP:
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.WILDCARD == filter) {
+ addComponent(((XSAttributeGroupDefinition)sourceComponent).getAttributeWildcard(),
+ nameTest, targetComponents);
+ }
+ break;
+ case XSConstants.MODEL_GROUP_DEFINITION:
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.MODEL_GROUP:
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.PARTICLE:
+ componentChildren(sourceComponent, filter, nameTest, targetComponents);
+ break;
+ case XSConstants.WILDCARD:
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.IDENTITY_CONSTRAINT:
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ if (NO_FILTER == filter || XSConstants.IDENTITY_CONSTRAINT == filter) {
+ addComponent(((XSIDCDefinition)sourceComponent).getRefKey(),
+ nameTest, targetComponents);
+ }
+ break; //
+ case XSConstants.NOTATION_DECLARATION:
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.FACET:
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ case XSConstants.MULTIVALUE_FACET:
+ if (NO_FILTER == filter || XSConstants.ANNOTATION == filter) {
+ annotations(sourceComponent, targetComponents);
+ }
+ break;
+ default: // this includes the case XSConstants.ANNOTATION
+ // TODO: we have to add support for, type alternative, assertion, schema, constraining facet and fundamental facet
+ break;
+ }
+ } // componentLinked()
+
+ // Described in section 4.5.4; component-children Accessor
+ private void componentChildren(XSObject sourceComponent, short filter, QName nameTest, List targetComponents) {
+ switch (sourceComponent.getType()) {
+ case XSConstants.ATTRIBUTE_DECLARATION: {
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) {
+ addComponent(((XSAttributeDeclaration)sourceComponent).getTypeDefinition(),
+ nameTest, targetComponents);
+ }
+ }
+ break;
+ case XSConstants.ELEMENT_DECLARATION: {
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) {
+ addComponent(((XSElementDeclaration)sourceComponent).getTypeDefinition(),
+ nameTest, targetComponents);
+ }
+ }
+ break;
+ case XSConstants.TYPE_DEFINITION:
+ if (((XSTypeDefinition)sourceComponent).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+ if (NO_FILTER == filter || XSConstants.FACET == filter) {
+ XSObjectList facets = ((XSSimpleTypeDefinition)sourceComponent).getFacets();
+ for (int i = 0, n = facets.size(); i < n; ++i) {
+ addComponent(facets.item(i), nameTest, targetComponents);
+ }
+ facets = ((XSSimpleTypeDefinition)sourceComponent).getMultiValueFacets();
+ for (int i = 0, n = facets.size(); i < n; ++i) {
+ addComponent(facets.item(i), nameTest, targetComponents);
+ }
+ }
+ } else { // complex type
+ XSComplexTypeDefinition cmplxType = ((XSComplexTypeDefinition)sourceComponent);
+ if (NO_FILTER == filter || XSConstants.ATTRIBUTE_USE == filter) {
+ XSObjectList attributeUses = cmplxType.getAttributeUses();
+ for (int i = 0, n = attributeUses.size(); i < n; ++i) {
+ addComponent(attributeUses.item(i), nameTest, targetComponents);
+ }
+ }
+ int componentVariety = cmplxType.getContentType();
+ switch (componentVariety) {
+ case XSComplexTypeDefinition.CONTENTTYPE_EMPTY:
+ break;
+ case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE:
+ if (NO_FILTER == filter || XSConstants.TYPE_DEFINITION == filter) {
+ addComponent(cmplxType.getSimpleType(), nameTest, targetComponents);
+ }
+ break;
+ default:
+ term(cmplxType, filter, nameTest, targetComponents);
+ break;
+ }
+ }
+ break;
+ case XSConstants.ATTRIBUTE_USE:
+ if (NO_FILTER == filter || XSConstants.ATTRIBUTE_DECLARATION == filter) {
+ addComponent(((XSAttributeUse)sourceComponent).getAttrDeclaration(),
+ nameTest, targetComponents);
+ }
+ break;
+ case XSConstants.ATTRIBUTE_GROUP:
+ if (NO_FILTER == filter || XSConstants.ATTRIBUTE_DECLARATION == filter) {
+ XSObjectList attrbuses = ((XSAttributeGroupDefinition) sourceComponent).getAttributeUses();
+ for (int i = 0, n = attrbuses.size(); i < n; ++i) {
+ addComponent(((XSAttributeUse) attrbuses.item(i)).getAttrDeclaration(),
+ nameTest, targetComponents);
+ }
+ }
+ break;
+ case XSConstants.MODEL_GROUP_DEFINITION:
+ if (NO_FILTER == filter || XSConstants.MODEL_GROUP == filter) {
+ addComponent(((XSModelGroupDefinition)sourceComponent).getModelGroup(),
+ nameTest, targetComponents);
+ }
+ break;
+ case XSConstants.MODEL_GROUP: {
+ XSObjectList particles = ((XSModelGroup)sourceComponent).getParticles();
+ for (int i = 0, n = particles.size(); i < n; ++i) {
+ XSTerm term = ((XSParticle)particles.item(i)).getTerm();
+ if (NO_FILTER == filter || term.getType() == filter) {
+ addComponent(term, nameTest, targetComponents);
+ }
+ }
+ }
+ break;
+ case XSConstants.PARTICLE: {
+ XSTerm term = ((XSParticle)sourceComponent).getTerm();
+ if (NO_FILTER == filter || term.getType() == filter) {
+ addComponent(term, nameTest, targetComponents);
+ }
+ }
+ break;
+ default:
+ break; // TODO: cases Schema and Type Alternative yet to be implemented
+ }
+ } // componentChildren()
+
+ // Described in section 4.5.9; annotations Accessor
+ private void annotations(XSObject sourceComponent, List targetComponents)
+ throws SCDException {
+ XSObjectList annotations;
+ switch (sourceComponent.getType()) {
+ case XSConstants.ATTRIBUTE_DECLARATION:
+ annotations = ((XSAttributeDeclaration)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.ELEMENT_DECLARATION:
+ annotations = ((XSElementDeclaration)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.TYPE_DEFINITION:
+ if (((XSTypeDefinition)sourceComponent).getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+ annotations = ((XSComplexTypeDefinition)sourceComponent).getAnnotations();
+ } else { // simple type def
+ annotations = ((XSSimpleTypeDefinition)sourceComponent).getAnnotations();
+ }
+ break;
+ case XSConstants.ATTRIBUTE_USE:
+ annotations = ((XSAttributeUse)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.ATTRIBUTE_GROUP:
+ annotations = ((XSAttributeGroupDefinition)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.MODEL_GROUP:
+ annotations = ((XSModelGroup)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.MODEL_GROUP_DEFINITION:
+ annotations = ((XSModelGroupDefinition)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.PARTICLE:
+ annotations = ((XSParticle)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.WILDCARD:
+ annotations = ((XSWildcard)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.IDENTITY_CONSTRAINT:
+ annotations = ((XSIDCDefinition)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.NOTATION_DECLARATION:
+ annotations = ((XSNotationDeclaration)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.FACET:
+ annotations = ((XSFacet)sourceComponent).getAnnotations();
+ break;
+ case XSConstants.MULTIVALUE_FACET:
+ annotations = ((XSMultiValueFacet)sourceComponent).getAnnotations();
+ break;
+ default: // TODO: no type alternative, assertion, schema, fundamental facet
+ throw new SCDException(
+ "Error in SCD: annotations accessor is not supported for the component type "
+ + sourceComponent.getType());
+ }
+ if (annotations != null) {
+ XSObject annotation;
+ for (int i = 0, n = annotations.size(); i < n; ++i) {
+ annotation = annotations.item(i);
+ if (annotation != null && !targetComponents.contains(annotation)) {
+ targetComponents.add(annotation);
+ }
+ }
+ }
+ } // annotations()
+
+ // Described in section 4.5.7; component-scope Accessor
+ private void componentScope(XSObject sourceComponent, List targetComponents) {
+ switch (sourceComponent.getType()) {
+ case XSConstants.ATTRIBUTE_DECLARATION:
+ if (((XSAttributeDeclaration)sourceComponent).getScope() != XSConstants.SCOPE_GLOBAL) {
+ XSObject type = ((XSAttributeDeclaration)sourceComponent).getEnclosingCTDefinition();
+ if (type != null && !targetComponents.contains(type)) {
+ targetComponents.add(type);
+ }
+ }
+ break;
+ case XSConstants.ELEMENT_DECLARATION:
+ if (((XSElementDeclaration)sourceComponent).getScope() != XSConstants.SCOPE_GLOBAL) {
+ XSObject type = ((XSElementDeclaration)sourceComponent).getEnclosingCTDefinition();
+ if (type != null && !targetComponents.contains(type)) {
+ targetComponents.add(type);
+ }
+ }
+ break;
+ }
+ } // componentScope()
+
+ private void addComponent(XSObject component, QName nameTest,
+ List resultComponents) {
+ if (component == null || resultComponents.contains(component)) {
+ return;
+ }
+ if (nameTest == SCDParser.ZERO) { // only for type defs without names
+ if (component.getType() == XSConstants.TYPE_DEFINITION
+ && component.getName() == null) {
+ resultComponents.add(component);
+ }
+ } else if (nameTest == SCDParser.WILDCARD) {
+ resultComponents.add(component);
+ } else {
+ String localPart = component.getName();
+ String uri = component.getNamespace();
+ if (uri != null && localPart != null) { // .../schemaElement::p:item
+ if (uri.equals(nameTest.uri)
+ && localPart.equals(nameTest.localpart)) {
+ resultComponents.add(component);
+ }
+ } else if (uri == null && localPart != null) { // .../schemaElement::item
+ if (nameTest.uri == null
+ && localPart.equals(nameTest.localpart)) {
+ resultComponents.add(component);
+ }
+ } else if (uri == null && localPart == null) { // .../model::sequence
+ String variety = null;
+ short type = component.getType();
+ if (type == XSConstants.MODEL_GROUP
+ || type == XSConstants.FACET
+ || type == XSConstants.MULTIVALUE_FACET) {
+ variety = componentVariety(component);
+ if (nameTest.uri == null && nameTest.localpart.equals(variety)) {
+ resultComponents.add(component);
+ }
+ }
+ }
+ }
+ }
+
+ public String toString() {
+ return "(current components="+currentComponents.toString()+", result="+result.toString()+")";
+ }
+} // SCDResolver
diff --git a/src/org/apache/xerces/impl/scd/Step.java b/src/org/apache/xerces/impl/scd/Step.java
new file mode 100644
index 000000000..432de631a
--- /dev/null
+++ b/src/org/apache/xerces/impl/scd/Step.java
@@ -0,0 +1,80 @@
+/*
+ * 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 org.apache.xerces.impl.scd;
+
+import org.apache.xerces.xni.QName;
+
+/**
+ * This class represents a step in an SCP/SCD string.
+ * @author Ishan Jayawardena udeshike@gmail.com
+ * @version $Id$
+ */
+class Step {
+ private final short axis;
+ private final QName nametest;
+ private final int predicate;
+
+ public Step(short axis, QName nametest, int predicate) {
+ this.axis = axis;
+ this.nametest = nametest;
+ this.predicate = predicate;
+ }
+
+ /**
+ * returns the axis type of the axis contained in the step
+ * @return the axis type
+ */
+ public short getAxisType() {
+ return this.axis;
+ }
+
+ /**
+ * the string representation of the axis of the step
+ * @return the axis name
+ */
+ public String getAxisName() {
+ return Axis.axisToString(axis);
+ }
+
+ /**
+ * returns the name test of the step
+ * @return the nametest
+ */
+ public QName getNametest() {
+ return this.nametest;
+ }
+
+ /**
+ * returns the predicate value of the step
+ * @return the predicate
+ */
+ public int getPredicate() {
+ return this.predicate;
+ }
+
+ /**
+ * prints the content of the axis
+ */
+ public String toString() {
+ return "(" +
+ "axis=" + Axis.axisToString(axis) +
+ ", nametest=" + ((nametest != null) ? ("{\"" + nametest.uri + "\"" + " \"" + nametest.rawname + "\"}") : null) +
+ ", predicate= " + predicate +
+ ")";
+ }
+} // class Step
diff --git a/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java b/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java
index 47c7fa656..206618b2f 100644
--- a/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java
+++ b/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java
@@ -28,12 +28,12 @@ import java.util.Iterator;
* @author Peter McCracken, IBM
* @version $Id$
*/
-public final class ConfigurableValidationState extends ValidationState {
+public class ConfigurableValidationState extends ValidationState {
/**
* Whether to check for ID/IDREF errors
*/
- private boolean fIdIdrefChecking;
+ protected boolean fIdIdrefChecking;
/**
* Whether to check for unparsed entity errors
@@ -56,7 +56,7 @@ public final class ConfigurableValidationState extends ValidationState {
* @param setting true to turn on error checking,
* false to turn off error checking
*/
- public void setIdIdrefChecking(boolean setting) {
+ public final void setIdIdrefChecking(boolean setting) {
fIdIdrefChecking = setting;
}
@@ -65,7 +65,7 @@ public final class ConfigurableValidationState extends ValidationState {
* @param setting true to turn on error checking,
* false to turn off error checking
*/
- public void setUnparsedEntityChecking(boolean setting) {
+ public final void setUnparsedEntityChecking(boolean setting) {
fUnparsedEntityChecking = setting;
}
@@ -74,7 +74,7 @@ public final class ConfigurableValidationState extends ValidationState {
* @return null, if ID/IDREF checking is turned off
* otherwise, returns the value of the super implementation
*/
- public Iterator checkIDRefID() {
+ public final Iterator checkIDRefID() {
return (fIdIdrefChecking) ? super.checkIDRefID() : null;
}
@@ -92,7 +92,7 @@ public final class ConfigurableValidationState extends ValidationState {
* @return true, if unparsed entity checking is turned off
* otherwise, returns the value of the super implementation
*/
- public boolean isEntityDeclared(String name) {
+ public final boolean isEntityDeclared(String name) {
return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true;
}
@@ -101,7 +101,7 @@ public final class ConfigurableValidationState extends ValidationState {
* @return true, if unparsed entity checking is turned off
* otherwise, returns the value of the super implementation
*/
- public boolean isEntityUnparsed(String name) {
+ public final boolean isEntityUnparsed(String name) {
return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true;
}
@@ -119,7 +119,7 @@ public final class ConfigurableValidationState extends ValidationState {
* Adds the IDREF, if ID/IDREF checking is enabled.
* @param name the IDREF to add
*/
- public void addIdRef(String name) {
+ public final void addIdRef(String name) {
if (fIdIdrefChecking) {
super.addIdRef(name);
}
diff --git a/src/org/apache/xerces/impl/validation/ValidationState.java b/src/org/apache/xerces/impl/validation/ValidationState.java
index 9baab0d42..ccb5da848 100644
--- a/src/org/apache/xerces/impl/validation/ValidationState.java
+++ b/src/org/apache/xerces/impl/validation/ValidationState.java
@@ -18,11 +18,14 @@
package org.apache.xerces.impl.validation;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Locale;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.NamespaceContext;
@@ -52,8 +55,11 @@ public class ValidationState implements ValidationContext {
//REVISIT: Should replace with a lighter structure.
private final HashMap fIdTable = new HashMap();
- private final HashMap fIdRefTable = new HashMap();
+ private final LinkedHashMap fIdRefTable = new LinkedHashMap();
private final static Object fNullValue = new Object();
+
+ private TypeValidatorHelper fTypeValidatorHelper = null;
+ private short fXMLVersion = Constants.XML_VERSION_1_0;
//
// public methods
@@ -92,14 +98,14 @@ public class ValidationState implements ValidationContext {
* a matching ID value.
*/
public Iterator checkIDRefID() {
- HashSet missingIDs = null;
+ LinkedHashSet missingIDs = null;
Iterator iter = fIdRefTable.keySet().iterator();
String key;
while (iter.hasNext()) {
key = (String) iter.next();
- if (!fIdTable.containsKey(key)) {
+ if (!containsID(key)) {
if (missingIDs == null) {
- missingIDs = new HashSet();
+ missingIDs = new LinkedHashSet();
}
missingIDs.add(key);
}
@@ -107,6 +113,9 @@ public class ValidationState implements ValidationContext {
return (missingIDs != null) ? missingIDs.iterator() : null;
}
+ protected boolean containsID(String name) {
+ return fIdTable.containsKey(name);
+ }
public void reset () {
fExtraChecking = true;
fFacetChecking = true;
@@ -205,4 +214,23 @@ public class ValidationState implements ValidationContext {
public Locale getLocale() {
return fLocale;
}
+
+ // TypeValidatorHelper
+
+ public void setTypeValidatorHelper(TypeValidatorHelper typeValidatorHelper) {
+ fTypeValidatorHelper = typeValidatorHelper;
+ }
+
+ public TypeValidatorHelper getTypeValidatorHelper() {
+ return fTypeValidatorHelper;
+ }
+
+ // Datatype XML Version
+ public void setDatatypeXMLVersion(short xmlVersion) {
+ fXMLVersion = xmlVersion;
+ }
+
+ public short getDatatypeXMLVersion() {
+ return fXMLVersion;
+ }
}
diff --git a/src/org/apache/xerces/impl/xpath/SimpleCharStream.java b/src/org/apache/xerces/impl/xpath/SimpleCharStream.java
new file mode 100644
index 000000000..7cd3c12fd
--- /dev/null
+++ b/src/org/apache/xerces/impl/xpath/SimpleCharStream.java
@@ -0,0 +1,461 @@
+/*
+ * 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 org.apache.xerces.impl.xpath;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (without unicode processing).
+ *
+ * (Parser generated using JavaCC)
+ *
+ * @author Hiranya Jayathilaka, University of Moratuwa
+ * @version $Id$
+ */
+public class SimpleCharStream {
+ /** Whether parser is static. */
+ public static final boolean staticFlag = false;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ /** Position in buffer. */
+ public int bufpos = -1;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) {
+ tabSize = i;
+ }
+
+ protected int getTabSize(int i) {
+ return tabSize;
+ }
+
+ protected void ExpandBuff(boolean wrapAround) {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize
+ - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin,
+ bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize
+ - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin,
+ bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0,
+ bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize
+ - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ } else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize
+ - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize
+ - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0,
+ bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ } catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException {
+ if (maxNextCharInd == available) {
+ if (available == bufsize) {
+ if (tokenBegin > 2048) {
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
+ } else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
+ else
+ ExpandBuff(false);
+ } else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd, available
+ - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
+ } else
+ maxNextCharInd += i;
+ return;
+ } catch (java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
+ }
+
+ /** Start. */
+ public char BeginToken() throws java.io.IOException {
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
+
+ return c;
+ }
+
+ protected void UpdateLineColumn(char c) {
+ column++;
+
+ if (prevCharIsLF) {
+ prevCharIsLF = false;
+ line += (column = 1);
+ } else if (prevCharIsCR) {
+ prevCharIsCR = false;
+ if (c == '\n') {
+ prevCharIsLF = true;
+ } else
+ line += (column = 1);
+ }
+
+ switch (c) {
+ case '\r':
+ prevCharIsCR = true;
+ break;
+ case '\n':
+ prevCharIsLF = true;
+ break;
+ case '\t':
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default:
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ /** Read a character. */
+ public char readChar() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
+
+ char c = buffer[bufpos];
+
+ UpdateLineColumn(c);
+ return c;
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ /** Get token end column number. */
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /** Get token end line number. */
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ /** Get token beginning column number. */
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ /** Get token beginning line number. */
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ /** Backup a number of characters. */
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.Reader dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.Reader dstream, int startline, int startcolumn,
+ int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ bufpos = -1;
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.Reader dstream, int startline, int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.Reader dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding,
+ int startline, int startcolumn, int buffersize)
+ throws java.io.UnsupportedEncodingException {
+ this(encoding == null ? new java.io.InputStreamReader(dstream)
+ : new java.io.InputStreamReader(dstream, encoding), startline,
+ startcolumn, buffersize);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn,
+ buffersize);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding,
+ int startline, int startcolumn)
+ throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream, String encoding)
+ throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ /** Constructor. */
+ public SimpleCharStream(java.io.InputStream dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding,
+ int startline, int startcolumn, int buffersize)
+ throws java.io.UnsupportedEncodingException {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream)
+ : new java.io.InputStreamReader(dstream, encoding), startline,
+ startcolumn, buffersize);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn,
+ buffersize);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding)
+ throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, String encoding,
+ int startline, int startcolumn)
+ throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ /** Reinitialise. */
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ /** Get token literal value. */
+ public String GetImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin)
+ + new String(buffer, 0, bufpos + 1);
+ }
+
+ /** Get the suffix. */
+ public char[] GetSuffix(int len) {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len
+ - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ /** Reset buffer when finished. */
+ public void Done() {
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol) {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin) {
+ len = bufpos - tokenBegin + inBuf + 1;
+ } else {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len
+ && bufline[j = start % bufsize] == bufline[k = ++start
+ % bufsize]) {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len) {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len) {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
+
diff --git a/src/org/apache/xerces/impl/xpath/Token.java b/src/org/apache/xerces/impl/xpath/Token.java
new file mode 100644
index 000000000..0a445857d
--- /dev/null
+++ b/src/org/apache/xerces/impl/xpath/Token.java
@@ -0,0 +1,150 @@
+/*
+ * 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 org.apache.xerces.impl.xpath;
+
+/**
+ * Describes the input token stream.
+ *
+ * (Parser generated using JavaCC)
+ *
+ * @author Hiranya Jayathilaka, University of Moratuwa
+ * @version $Id$
+ */
+public class Token implements java.io.Serializable {
+
+ /**
+ * The version identifier for this Serializable class.
+ * Increment only if the <i>serialized</i> form of the
+ * class changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /** The line number of the first character of this Token. */
+ public int beginLine;
+ /** The column number of the first character of this Token. */
+ public int beginColumn;
+ /** The line number of the last character of this Token. */
+ public int endLine;
+ /** The column number of the last character of this Token. */
+ public int endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * An optional attribute value of the Token.
+ * Tokens which are not used as syntactic sugar will often contain
+ * meaningful values that will be used later on by the compiler or
+ * interpreter. This attribute value is often different from the image.
+ * Any subclass of Token that actually wants to return a non-null value can
+ * override this method as appropriate.
+ */
+ public Object getValue() {
+ return null;
+ }
+
+ /**
+ * No-argument constructor
+ */
+ public Token() {}
+
+ /**
+ * Constructs a new token for the specified Image.
+ */
+ public Token(int kind)
+ {
+ this(kind, null);
+ }
+
+ /**
+ * Constructs a new token for the specified Image and Kind.
+ */
+ public Token(int kind, String image)
+ {
+ this.kind = kind;
+ this.image = image;
+ }
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simply add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken(ofKind, image);
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use sit in your lexical actions.
+ */
+ public static Token newToken(int ofKind, String image)
+ {
+ switch(ofKind)
+ {
+ default : return new Token(ofKind, image);
+ }
+ }
+
+ public static Token newToken(int ofKind)
+ {
+ return newToken(ofKind, null);
+ }
+
+}
+
diff --git a/src/org/apache/xerces/impl/xpath/XPath20.java b/src/org/apache/xerces/impl/xpath/XPath20.java
new file mode 100644
index 000000000..d7fba3955
--- /dev/null
+++ b/src/org/apache/xerces/impl/xpath/XPath20.java
@@ -0,0 +1,532 @@
+/*
+ * 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 org.apache.xerces.impl.xpath;
+
+import java.io.StringReader;
+
+import javax.xml.XMLConstants;
+
+import org.apache.xerces.impl.dv.SchemaDVFactory;
+import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.impl.dv.xs.TypeValidator;
+import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
+import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xs.ShortList;
+import org.apache.xerces.xs.XSConstants;
+
+/**
+ * Bare minimal XPath 2.0 implementation for schema type alternatives.
+ *
+ * @author Hiranya Jayathilaka, University of Moratuwa
+ * @version $Id$
+ */
+public class XPath20 {
+
+ protected final String fExpression;
+ protected final NamespaceContext fNsContext;
+
+ private XPathSyntaxTreeNode fRootNode;
+
+ public XPath20(String xpath, SymbolTable symbolTable, NamespaceContext nsContext) throws XPathException {
+ fExpression = xpath;
+ fNsContext = nsContext;
+
+ //The parser expects '\n' at the end of the expression. So insert it.
+ StringReader reader = new StringReader(fExpression + "\n");
+ XPath20Parser parser = new XPath20Parser(reader, nsContext);
+ fRootNode = parser.parseExpression();
+ }
+
+ /**
+ * Evaluate the test XPath expression using the attribute information and element information.
+ *
+ * @param element QName of the current element
+ * @param attributes attributes collection of the current element
+ * @return true if the test evaluates successfully and false otherwise
+ */
+ public boolean evaluateTest(QName element, XMLAttributes attributes) {
+ try {
+ return fRootNode.evaluate(element, attributes, fNsContext);
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public String getXPathStrValue() {
+ return fExpression;
+ }
+
+}
+
+abstract class XPathSyntaxTreeNode {
+
+ public static final int TYPE_UNDEFINED = -1;
+ public static final int TYPE_DOUBLE = 0; //for all numerics (double, integer, float, decimal etc)
+ public static final int TYPE_STRING = 1; //for strings (xs:string)
+ public static final int TYPE_UNTYPED = 2; //for attributes (untypedAtomic)
+ public static final int TYPE_OTHER = 3; //for everything else which should have some valid type
+
+ private static final String SCHEMA11_FACTORY_CLASS = "org.apache.xerces.impl.dv.xs.Schema11DVFactoryImpl";
+ protected static SchemaDVFactory dvFactory;
+
+ static {
+ dvFactory = SchemaDVFactory.getInstance(SCHEMA11_FACTORY_CLASS);
+ }
+
+ public abstract boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception;
+
+ public Object getValue(XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ return null;
+ }
+
+ public String getStringValue() {
+ return null;
+ }
+
+ public int getType() {
+ return TYPE_UNDEFINED;
+ }
+
+ public XSSimpleType getSimpleType() {
+ return null;
+ }
+}
+
+class LiteralNode extends XPathSyntaxTreeNode {
+ private String value;
+ private boolean isNumeric;
+
+ public LiteralNode(String value, boolean isNumeric) {
+ this.value = value;
+ this.isNumeric = isNumeric;
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ Object obj = getValue(attributes, nsContext);
+ if (isNumeric) {
+ return obj != null && 0.0 != ((Double) obj).doubleValue();
+ }
+ else {
+ return obj != null;
+ }
+ }
+
+ public Object getValue(XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ XSSimpleType type;
+ if (isNumeric) {
+ type = dvFactory.getBuiltInType("double");
+ } else {
+ type = dvFactory.getBuiltInType("string");
+ }
+ return type.validate(value, null, null);
+ }
+
+ public String getStringValue() {
+ return value;
+ }
+
+ public int getType() {
+ return isNumeric ? TYPE_DOUBLE : TYPE_STRING;
+ }
+}
+
+class ConjunctionNode extends XPathSyntaxTreeNode {
+ private int conjunction;
+ private XPathSyntaxTreeNode child1;
+ private XPathSyntaxTreeNode child2;
+
+ public static final int OR = 0;
+ public static final int AND = 1;
+
+ public ConjunctionNode(int conjunction, XPathSyntaxTreeNode child1, XPathSyntaxTreeNode child2) {
+ this.conjunction = conjunction;
+ this.child1 = child1;
+ this.child2 = child2;
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ boolean lhs = child1.evaluate(element, attributes, nsContext);
+ boolean rhs = child2.evaluate(element, attributes, nsContext);
+ if (conjunction == OR) {
+ return lhs || rhs;
+ } else {
+ return lhs && rhs;
+ }
+ }
+}
+
+class AttrNode extends XPathSyntaxTreeNode {
+ private QName name;
+
+ public AttrNode(QName name) {
+ this.name = name;
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ String attrValue = attributes.getValue(name.uri, name.localpart);
+ if (attrValue == null || attrValue.length() == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public Object getValue(XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ String attrValue = attributes.getValue(name.uri, name.localpart);
+ if (attrValue == null) {
+ throw new XPathException("Attribute value is null");
+ }
+ return attrValue;
+ }
+
+ public int getType() {
+ return TYPE_UNTYPED;
+ }
+}
+
+class CompNode extends XPathSyntaxTreeNode {
+ private int comp;
+ private XPathSyntaxTreeNode child1;
+ private XPathSyntaxTreeNode child2;
+
+ public static final int EQ = 0;
+ public static final int NE = 1;
+ public static final int LT = 2;
+ public static final int GT = 3;
+ public static final int LE = 4;
+ public static final int GE = 5;
+
+ public CompNode(int comp, XPathSyntaxTreeNode child1,
+ XPathSyntaxTreeNode child2) {
+ this.comp = comp;
+ this.child1 = child1;
+ this.child2 = child2;
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ int type1 = child1.getType();
+ int type2 = child2.getType();
+ Object obj1, obj2;
+ XSSimpleTypeDecl simpleType;
+
+ if (type1 == TYPE_UNTYPED && type2 == TYPE_DOUBLE) {
+ // attribute and numeral
+ String attrValue = child1.getValue(attributes, nsContext).toString();
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("double");
+ //cast the attribute value into double as per the XPath 2.0 general comparison rules
+ obj1 = simpleType.validate(attrValue, null, null);
+ obj2 = child2.getValue(attributes, nsContext);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_UNTYPED && type2 == TYPE_STRING) {
+ // attribute and string
+ String attrValue = child1.getValue(attributes, nsContext).toString();
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("string");
+ //cast the attribute value into string as per the XPath 2.0 general comparison rules
+ obj1 = simpleType.validate(attrValue, null, null);
+ obj2 = child2.getValue(attributes, nsContext);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_DOUBLE && type2 == TYPE_UNTYPED) {
+ // numeral and attribute
+ String attrValue = child2.getValue(attributes, nsContext).toString();
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("double");
+ obj1 = child1.getValue(attributes, nsContext);
+ //cast the attribute value into double as per the XPath 2.0 general comparison rules
+ obj2 = simpleType.validate(attrValue, null, null);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_STRING && type2 == TYPE_UNTYPED) {
+ // string and attribute
+ String attrValue = child2.getValue(attributes, nsContext).toString();
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("string");
+ obj1 = child1.getValue(attributes, nsContext);
+ //cast the attribute value into string as per the XPath 2.0 general comparison rules
+ obj2 = simpleType.validate(attrValue, null, null);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_UNTYPED && type2 == TYPE_UNTYPED) {
+ // attr and attr
+ String attrVal1 = child1.getValue(attributes, nsContext).toString();
+ String attrVal2 = child2.getValue(attributes, nsContext).toString();
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("string");
+ //cast the both attribute values into string as per the XPath 2.0 general comparison rules
+ obj1 = simpleType.validate(attrVal1, null, null);
+ obj2 = simpleType.validate(attrVal2, null, null);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_UNTYPED && type2 == TYPE_OTHER) {
+ // attr and cast expr
+ String attrVal = child1.getValue(attributes, nsContext).toString();
+
+ simpleType = (XSSimpleTypeDecl)child2.getSimpleType();
+ if (simpleType == null) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ //try to cast the attribute value into the type of the cast expression
+ obj1 = simpleType.validate(attrVal, null, null);
+ obj2 = child2.getValue(attributes, nsContext);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_OTHER && type2 == TYPE_UNTYPED) {
+ // cast expr and attr
+ String attrVal = child2.getValue(attributes, nsContext).toString();
+
+ simpleType = (XSSimpleTypeDecl)child1.getSimpleType();
+ if (simpleType == null) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ obj1 = child1.getValue(attributes, nsContext);
+ //try to cast the attribute value into the type of the cast expression
+ obj2 = simpleType.validate(attrVal, null, null);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_OTHER && type2 == TYPE_OTHER) {
+ //cast expr and cast expr
+ simpleType = (XSSimpleTypeDecl)child1.getSimpleType();
+ if (simpleType == null) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ short dt1 = simpleType.getBuiltInKind();
+
+ simpleType = (XSSimpleTypeDecl)child2.getSimpleType();
+ if (simpleType == null) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ short dt2 = simpleType.getBuiltInKind();
+
+ // check whether the two types are comparable
+ if (DataMatcher.isComparable(dt1, dt2, null, null)) {
+ obj1 = simpleType.validate(child1.getValue(attributes, nsContext), null, null);
+ obj2 = child2.getValue(attributes, nsContext);
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+ } else {
+ throw new XPathException("Invalid comparison between incompatible types");
+ }
+
+ } else if (type1 == TYPE_DOUBLE && type2 == TYPE_DOUBLE) {
+ // numeric and numeric
+ obj1 = child1.getValue(attributes, nsContext);
+ obj2 = child2.getValue(attributes, nsContext);
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("double");
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else if (type1 == TYPE_STRING && type2 == TYPE_STRING) {
+ // string and string
+ obj1 = child1.getValue(attributes, nsContext);
+ obj2 = child2.getValue(attributes, nsContext);
+ simpleType = (XSSimpleTypeDecl) dvFactory.getBuiltInType("string");
+ return DataMatcher.compareActualValues(obj1, obj2, comp, simpleType);
+
+ } else {
+ throw new XPathException("Invalid comparison");
+ }
+
+ }
+}
+
+class CastNode extends XPathSyntaxTreeNode {
+ private XSSimpleType castedType;
+ private XPathSyntaxTreeNode child;
+
+ public CastNode(XPathSyntaxTreeNode child, QName type) throws XPathException {
+ this.child = child;
+ if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type.uri)) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ castedType = dvFactory.getBuiltInType(type.localpart);
+ if (castedType == null) {
+ throw new XPathException("Casted type is not a built-in type");
+ }
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ Object obj = getValue(attributes, nsContext);
+ // Implement XPath fn:boolean() function:
+ // If $arg is the empty sequence, fn:boolean returns false.
+ // TODO: how is this checked?
+ if (obj == null) {
+ return false;
+ }
+ // If $arg is a sequence whose first item is a node, fn:boolean returns true.
+ // TODO: how to implement this?
+ // If $arg is a singleton value of type xs:boolean or a derived from xs:boolean, fn:boolean returns $arg.
+ if (obj instanceof Boolean) {
+ return ((Boolean)obj).booleanValue();
+ }
+ // If $arg is a singleton value of type xs:string or a type derived from xs:string, xs:anyURI or a type derived from xs:anyURI or xs:untypedAtomic, fn:boolean returns false if the operand value has zero length; otherwise it returns true.
+ if (obj instanceof String) {
+ return ((String)obj).length() > 0;
+ }
+ // If $arg is a singleton value of any numeric type or a type derived from a numeric type, fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.
+ // TODO: should check type and handle different numeric types differntly
+ if (obj instanceof Double) {
+ return ((Double)obj).doubleValue() != 0;
+ }
+ // In all other cases, fn:boolean raises a type error [err:FORG0006].
+ // TODO: need to distinguish between node (true) and other simple types (false).
+ return true;
+ }
+
+ public Object getValue(XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ XSSimpleType type = getSimpleType();
+
+ Object obj;
+ if (child.getType() == TYPE_UNTYPED) {
+ //attribute cast
+ String attrValue = child.getValue(attributes, nsContext).toString();
+ obj = type.validate(attrValue, null, null);
+ } else {
+ //literal cast (perform using the string value of the literal node)
+ obj = type.validate(child.getStringValue(), null, null);
+ }
+
+ //Workaround (this is here because double validator can only validate double values)
+ if (type.getNumeric()) {
+ obj = dvFactory.getBuiltInType("double").validate(obj, null, null);
+ }
+ return obj;
+ }
+
+ public XSSimpleType getSimpleType() {
+ return castedType;
+ }
+
+ public int getType() {
+ if (castedType.getNumeric()) {
+ return TYPE_DOUBLE;
+ } else if (castedType.getName().equals("string")) {
+ return TYPE_STRING;
+ } else {
+ return TYPE_OTHER;
+ }
+ }
+}
+
+class FunctionNode extends XPathSyntaxTreeNode {
+ private QName name;
+ private XPathSyntaxTreeNode child;
+
+ public FunctionNode(QName name, XPathSyntaxTreeNode child) throws XPathException {
+ if (!"not".equals(name.localpart) || !"http://www.w3.org/2005/xpath-functions".equals(name.uri)) {
+ throw new XPathException("Only support fn:not function.");
+ }
+ this.name = name;
+ this.child = child;
+ }
+
+ public boolean evaluate(QName element, XMLAttributes attributes, NamespaceContext nsContext) throws Exception {
+ return !child.evaluate(element, attributes, nsContext);
+ }
+
+ public String getValue(QName element, XMLAttributes attributes) {
+ return null;
+ }
+}
+
+class DataMatcher {
+
+ public static boolean compareActualValues(Object value1, Object value2, int comparator, XSSimpleTypeDecl type) {
+
+ TypeValidator typeValidator = type.getTypeValidator();
+ short ordered = type.getOrdered();
+
+ if (ordered == XSSimpleTypeDecl.ORDERED_FALSE) {
+ //if the type is not ordered then only equality can be tested. delegate the test to the type.
+ if (comparator == CompNode.EQ) {
+ return type.isEqual(value1, value2);
+ }
+ else if (comparator == CompNode.NE) {
+ return !type.isEqual(value1, value2);
+ }
+ else {
+ //only equality can be tested upon unordered types
+ return false;
+ }
+ }
+
+ //if the type is ordered then the corresponding TypeValidator should know how to compare the values
+ switch (comparator) {
+ case CompNode.EQ: return typeValidator.compare(value1, value2) == 0;
+ case CompNode.NE: return typeValidator.compare(value1, value2) != 0;
+ case CompNode.GT: return typeValidator.compare(value1, value2) > 0;
+ case CompNode.GE: return typeValidator.compare(value1, value2) >= 0;
+ case CompNode.LT: return typeValidator.compare(value1, value2) < 0;
+ case CompNode.LE: return typeValidator.compare(value1, value2) <= 0;
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Checks whether two specified data types are comparable. The types passed
+ * into this method should be defined in XSConstants as *_DT values.
+ */
+ public static boolean isComparable(short type1, short type2, ShortList typeList1, ShortList typeList2) {
+
+ short primitiveType1 = convertToPrimitiveKind(type1);
+ short primitiveType2 = convertToPrimitiveKind(type2);
+
+ if (primitiveType1 != primitiveType2) {
+ return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
+ primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
+ }
+ else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
+ final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0;
+ final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0;
+ if (typeList1Length != typeList2Length) {
+ return false;
+ }
+ for (int i = 0; i < typeList1Length; ++i) {
+ final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i));
+ final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i));
+ if (primitiveItem1 != primitiveItem2) {
+ if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
+ primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
+ continue;
+ }
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static short convertToPrimitiveKind(short valueType) {
+ //Primitive data types
+ if (valueType <= XSConstants.NOTATION_DT) {
+ return valueType;
+ }
+ // Types derived from string
+ if (valueType <= XSConstants.ENTITY_DT) {
+ return XSConstants.STRING_DT;
+ }
+ // Types derived from decimal
+ if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
+ return XSConstants.DECIMAL_DT;
+ }
+ // Other types
+ return valueType;
+ }
+
+} // class XPath20
+
+
diff --git a/src/org/apache/xerces/impl/xpath/XPath20Parser.java b/src/org/apache/xerces/impl/xpath/XPath20Parser.java
new file mode 100644
index 000000000..f8ec19a59
--- /dev/null
+++ b/src/org/apache/xerces/impl/xpath/XPath20Parser.java
@@ -0,0 +1,409 @@
+/*
+ * 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 org.apache.xerces.impl.xpath;
+
+import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
+
+/**
+ * Lexical analyzer and parser for test XPath expressions. This parser
+ * implementation constructs a syntax tree for valid test XPath expressions
+ * which can be later evaluated.
+ *
+ * (Parser generated using JavaCC)
+ *
+ * @author Hiranya Jayathilaka, University of Moratuwa
+ * @version $Id$
+ */
+public class XPath20Parser {
+
+ public static final int EOF = 0;
+ public static final int KEYWORD_AND = 2;
+ public static final int KEYWORD_OR = 3;
+ public static final int KEYWORD_CAST = 4;
+ public static final int KEYWORD_AS = 5;
+
+ public static final int SYMBOL_COLON = 6;
+ public static final int SYMBOL_AT = 7;
+ public static final int SYMBOL_QUESTION = 8;
+ public static final int OPEN_PARAN = 9;
+ public static final int CLOSE_PARAN = 10;
+ public static final int SYMBOL_EQ = 11;
+ public static final int SYMBOL_NE = 12;
+ public static final int SYMBOL_LT = 13;
+ public static final int SYMBOL_GT = 14;
+ public static final int SYMBOL_LE = 15;
+ public static final int SYMBOL_GE = 16;
+
+ public static final int NUMERIC_LITERAL = 17;
+ public static final int DIGITS = 18;
+ public static final int NCNAME = 19;
+ public static final int NCNAME_START_CHAR = 20;
+ public static final int NCNAME_CHAR = 21;
+ public static final int ESCAPE_QUOTE = 22;
+ public static final int ESCAPE_APOS = 23;
+ public static final int STRING_LITERAL = 24;
+
+ /** Lexical state. */
+ public static final int DEFAULT = 0;
+
+ /** Literal token values. */
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"and\"",
+ "\"or\"",
+ "\"cast\"",
+ "\"as\"",
+ "\":\"",
+ "\"@\"",
+ "\"?\"",
+ "\"(\"",
+ "\")\"",
+ "\"=\"",
+ "\"!=\"",
+ "\"<\"",
+ "\">\"",
+ "\"<=\"",
+ "\">=\"",
+ "<NUMERIC_LITERAL>",
+ "<DIGITS>",
+ "<NCNAME>",
+ "<NCNAME_START_CHAR>",
+ "<NCNAME_CHAR>",
+ "\"\\\"\\\"\"",
+ "\"\\\'\\\'\"",
+ "<STRING_LITERAL>",
+ "\"\\n\"",
+ };
+
+ protected final NamespaceContext fNsContext;
+
+ public XPathSyntaxTreeNode parseExpression() throws XPathException {
+ return Test();
+ }
+
+ private XPathSyntaxTreeNode Test() throws XPathException {
+ XPathSyntaxTreeNode n;
+ n = OrExpr();
+ consumeToken(25);
+ return n;
+ }
+
+ private XPathSyntaxTreeNode OrExpr() throws XPathException {
+ XPathSyntaxTreeNode n1, n2;
+ n1 = AndExpr();
+ label_1: while (true) {
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case KEYWORD_OR:
+ break;
+
+ default:
+ array1[0] = gen;
+ break label_1;
+ }
+ consumeToken(KEYWORD_OR);
+ n2 = AndExpr();
+ return new ConjunctionNode(ConjunctionNode.OR, n1, n2);
+ }
+ return n1;
+ }
+
+ private XPathSyntaxTreeNode AndExpr() throws XPathException {
+ XPathSyntaxTreeNode n1, n2;
+ n1 = BooleanExpr();
+ label_2: while (true) {
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case KEYWORD_AND:
+ break;
+
+ default:
+ array1[1] = gen;
+ break label_2;
+ }
+
+ consumeToken(KEYWORD_AND);
+ n2 = BooleanExpr();
+ return new ConjunctionNode(ConjunctionNode.AND, n1, n2);
+ }
+ return n1;
+ }
+
+ private XPathSyntaxTreeNode BooleanExpr() throws XPathException {
+ XPathSyntaxTreeNode n1, n2;
+ QName name;
+ int comp;
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case OPEN_PARAN:
+ consumeToken(OPEN_PARAN);
+ n1 = OrExpr();
+ consumeToken(CLOSE_PARAN);
+ return n1;
+
+ case NCNAME:
+ name = QName();
+ consumeToken(OPEN_PARAN);
+ if ("not".equals(name.localpart) && "http://www.w3.org/2005/xpath-functions".equals(name.uri)) {
+ n1 = OrExpr();
+ consumeToken(CLOSE_PARAN);
+ return new FunctionNode(name, n1);
+ }
+ n1 = SimpleValue();
+ consumeToken(CLOSE_PARAN);
+ n1 = new CastNode(n1, name);
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_EQ:
+ case SYMBOL_NE:
+ case SYMBOL_LT:
+ case SYMBOL_GT:
+ case SYMBOL_LE:
+ case SYMBOL_GE:
+ comp = Comparator();
+ n2 = ValueExpr();
+ return new CompNode(comp, n1, n2);
+
+ default:
+ array1[2] = gen;
+ }
+ return n1;
+ case SYMBOL_AT:
+ case NUMERIC_LITERAL:
+ case STRING_LITERAL:
+ n1 = CastExpr();
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_EQ:
+ case SYMBOL_NE:
+ case SYMBOL_LT:
+ case SYMBOL_GT:
+ case SYMBOL_LE:
+ case SYMBOL_GE:
+ comp = Comparator();
+ n2 = CastExpr();
+ return new CompNode(comp, n1, n2);
+
+ default:
+ array1[2] = gen;
+ }
+ return n1;
+
+ default:
+ array1[3] = gen;
+ consumeToken(-1);
+ throw new XPathException("c-general-xpath");
+ }
+ }
+
+ private QName QName() throws XPathException {
+ Token t1, t2;
+ QName name;
+ t1 = consumeToken(NCNAME);
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_COLON:
+ consumeToken(SYMBOL_COLON);
+ t2 = consumeToken(NCNAME);
+ // TODO: better way to intern the strings
+ String prefix = t1.image.intern();
+ String local = t2.image.intern();
+ name = new QName(prefix, local, prefix + ':' + local, fNsContext.getURI(prefix));
+ break;
+ default:
+ // TODO: better way to intern the strings
+ local = t1.image.intern();
+ name = new QName(null, local, local, null);
+ array1[4] = gen;
+ }
+ return name;
+ }
+
+ private int Comparator() throws XPathException {
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_EQ:
+ consumeToken(SYMBOL_EQ);
+ return CompNode.EQ;
+
+ case SYMBOL_NE:
+ consumeToken(SYMBOL_NE);
+ return CompNode.NE;
+
+ case SYMBOL_GT:
+ consumeToken(SYMBOL_GT);
+ return CompNode.GT;
+
+ case SYMBOL_LT:
+ consumeToken(SYMBOL_LT);
+ return CompNode.LT;
+
+ case SYMBOL_GE:
+ consumeToken(SYMBOL_GE);
+ return CompNode.GE;
+
+ case SYMBOL_LE:
+ consumeToken(SYMBOL_LE);
+ return CompNode.LE;
+
+ default:
+ array1[5] = gen;
+ consumeToken(-1);
+ throw new XPathException("c-general-xpath");
+ }
+ }
+
+ private XPathSyntaxTreeNode ValueExpr() throws XPathException {
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case NCNAME:
+ QName name = QName();
+ consumeToken(OPEN_PARAN);
+ XPathSyntaxTreeNode n1 = SimpleValue();
+ consumeToken(CLOSE_PARAN);
+ return new CastNode(n1, name);
+ case SYMBOL_AT:
+ case NUMERIC_LITERAL:
+ case STRING_LITERAL:
+ return CastExpr();
+ default:
+ array1[3] = gen;
+ consumeToken(-1);
+ throw new XPathException("c-general-xpath");
+ }
+ }
+
+ private XPathSyntaxTreeNode CastExpr() throws XPathException {
+ XPathSyntaxTreeNode n;
+ QName name;
+ n = SimpleValue();
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case KEYWORD_CAST:
+ consumeToken(KEYWORD_CAST);
+ consumeToken(KEYWORD_AS);
+ name = QName();
+ switch ((nextTokenIndex == -1) ? nextToken() : nextTokenIndex) {
+ case SYMBOL_QUESTION:
+ consumeToken(SYMBOL_QUESTION);
+ break;
+ default:
+ array1[6] = gen;
... 36006 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org