You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2010/08/05 06:41:01 UTC
svn commit: r982466 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs:
SubstitutionGroupHandler.java XMLSchemaLoader.java XMLSchemaValidator.java
XSElementDeclHelper.java
Author: mrglavas
Date: Thu Aug 5 04:41:01 2010
New Revision: 982466
URL: http://svn.apache.org/viewvc?rev=982466&view=rev
Log:
Fixing JIRA Issue #1463: http://issues.apache.org/jira/browse/XERCESJ-1463. A call to findSchemaGrammar() was missing for substitution groups. This could lead to an error reported for the substitution element if its declaration has not been loaded yet.
Added:
xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java (with props)
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java?rev=982466&r1=982465&r2=982466&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java Thu Aug 5 04:41:01 2010
@@ -39,14 +39,14 @@ public class SubstitutionGroupHandler {
private static final XSElementDecl[] EMPTY_GROUP = new XSElementDecl[0];
- // grammar resolver
- XSGrammarBucket fGrammarBucket;
+ // global element declaration resolver
+ private final XSElementDeclHelper fXSElementDeclHelper;
/**
* Default constructor
*/
- public SubstitutionGroupHandler(XSGrammarBucket grammarBucket) {
- fGrammarBucket = grammarBucket;
+ public SubstitutionGroupHandler(XSElementDeclHelper elementDeclHelper) {
+ fXSElementDeclHelper = elementDeclHelper;
}
// 3.9.4 Element Sequence Locally Valid (Particle) 2.3.3
@@ -68,14 +68,8 @@ public class SubstitutionGroupHandler {
return null;
}
- // get grammar of the element
- SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri);
- if (sGrammar == null) {
- return null;
- }
-
// get the decl for the element
- XSElementDecl eDecl = sGrammar.getGlobalElementDecl(element.localpart);
+ XSElementDecl eDecl = fXSElementDeclHelper.getGlobalElementDecl(element);
if (eDecl == null) {
return null;
}
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=982466&r1=982465&r2=982466&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Thu Aug 5 04:41:01 2010
@@ -51,6 +51,7 @@ import org.apache.xerces.util.ParserConf
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.XMLSymbols;
import org.apache.xerces.util.URI.MalformedURIException;
+import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.grammars.Grammar;
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
@@ -93,7 +94,7 @@ import org.xml.sax.InputSource;
* @author Neil Graham, IBM
* @version $Id$
*/
-public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent,
+public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent, XSElementDeclHelper,
// XML Component API
XSLoader, DOMConfiguration {
@@ -326,8 +327,8 @@ XSLoader, DOMConfiguration {
grammarBucket = new XSGrammarBucket();
}
fGrammarBucket = grammarBucket;
- if(sHandler == null) {
- sHandler = new SubstitutionGroupHandler(fGrammarBucket);
+ if (sHandler == null) {
+ sHandler = new SubstitutionGroupHandler(this);
}
fSubGroupHandler = sHandler;
@@ -1405,6 +1406,15 @@ XSLoader, DOMConfiguration {
return xis;
}
+
+ // Implements XSElementDeclHelper interface
+ public XSElementDecl getGlobalElementDecl(QName element) {
+ SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri);
+ if (sGrammar != null) {
+ return sGrammar.getGlobalElementDecl(element.localpart);
+ }
+ return null;
+ }
} // XMLGrammarLoader
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=982466&r1=982465&r2=982466&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Thu Aug 5 04:41:01 2010
@@ -109,7 +109,7 @@ import org.apache.xerces.xs.XSTypeDefini
* @version $Id$
*/
public class XMLSchemaValidator
- implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler {
+ implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler, XSElementDeclHelper {
//
// Constants
@@ -1162,7 +1162,7 @@ public class XMLSchemaValidator
/** Schema grammar resolver. */
private final XSGrammarBucket fGrammarBucket = new XSGrammarBucket();
- private final SubstitutionGroupHandler fSubGroupHandler = new SubstitutionGroupHandler(fGrammarBucket);
+ private final SubstitutionGroupHandler fSubGroupHandler = new SubstitutionGroupHandler(this);
/** the DV usd to convert xsi:type to a QName */
// REVISIT: in new simple type design, make things in DVs static,
@@ -1647,6 +1647,21 @@ public class XMLSchemaValidator
matcher.startDocumentFragment();
}
+ // Implements XSElementDeclHelper interface
+ public XSElementDecl getGlobalElementDecl(QName element) {
+ final SchemaGrammar sGrammar =
+ findSchemaGrammar(
+ XSDDescription.CONTEXT_ELEMENT,
+ element.uri,
+ null,
+ element,
+ null);
+ if (sGrammar != null) {
+ return sGrammar.getGlobalElementDecl(element.localpart);
+ }
+ return null;
+ }
+
//
// Protected methods
//
Added: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java?rev=982466&view=auto
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java (added)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java Thu Aug 5 04:41:01 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.xs;
+
+import org.apache.xerces.xni.QName;
+
+/**
+ * @xerces.internal
+ *
+ * @version $Id$
+ */
+public interface XSElementDeclHelper {
+
+ public XSElementDecl getGlobalElementDecl(QName element);
+}
Propchange: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSElementDeclHelper.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org