Author: mrglavas
Date: Sat Nov 15 21:35:13 2008
New Revision: 717982

URL: http://svn.apache.org/viewvc?rev=717982&view=rev
Log:
JIRA Issue #1337:
http://issues.apache.org/jira/browse/XERCESJ-1337

Support XSTypeDefinition as value of the "root-type-definition" property.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java

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=717982&r1=717981&r2=717982&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 Sat 
Nov 15 21:35:13 2008
@@ -552,7 +552,18 @@
      */
     public void setProperty(String propertyId, Object value) throws 
XMLConfigurationException {
         if (propertyId.equals(ROOT_TYPE_DEF)) {
-            fRootTypeQName = (javax.xml.namespace.QName)value;
+            if (value == null) {
+                fRootTypeQName = null;
+                fRootTypeDefinition = null;
+            }
+            else if (value instanceof javax.xml.namespace.QName) {
+                fRootTypeQName = (javax.xml.namespace.QName) value;
+                fRootTypeDefinition = null;
+            }
+            else {
+                fRootTypeDefinition = (XSTypeDefinition) value;
+                fRootTypeQName = null;
+            }
         }
     } // setProperty(String,Object)
 
@@ -1209,6 +1220,7 @@
     private final QName fTempQName = new QName();
     
     private javax.xml.namespace.QName fRootTypeQName = null;
+    private XSTypeDefinition fRootTypeDefinition = null;
     
     private int fIgnoreXSITypeDepth;
     
@@ -1402,10 +1414,23 @@
         fValidationState.setSymbolTable(fSymbolTable);
         
         try {
-            fRootTypeQName = 
(javax.xml.namespace.QName)componentManager.getProperty(ROOT_TYPE_DEF);
+            final Object rootType = 
componentManager.getProperty(ROOT_TYPE_DEF);
+            if (rootType == null) {
+                fRootTypeQName = null;
+                fRootTypeDefinition = null;
+            }
+            else if (rootType instanceof javax.xml.namespace.QName) {
+                fRootTypeQName = (javax.xml.namespace.QName) rootType;
+                fRootTypeDefinition = null;
+            }
+            else {
+                fRootTypeDefinition = (XSTypeDefinition) rootType;
+                fRootTypeQName = null;
+            }
         } 
         catch (XMLConfigurationException e) {
             fRootTypeQName = null;
+            fRootTypeDefinition = null;
         }
         
         boolean ignoreXSIType;
@@ -1895,26 +1920,31 @@
         }
         
         // 1.2.1.1 A type definition was stipulated by the processor
-        if (fElementDepth == 0 && fRootTypeQName != null) {
-            String rootTypeNamespace = fRootTypeQName.getNamespaceURI();
-            if (rootTypeNamespace != null && 
rootTypeNamespace.equals(XMLConstants.NULL_NS_URI)) {
-                rootTypeNamespace = null;
-            }
-            if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(rootTypeNamespace)) {
-                fCurrentType = 
SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+        if (fElementDepth == 0) {
+            if (fRootTypeDefinition != null) {
+                fCurrentType = fRootTypeDefinition;
             }
-            else {
-                SchemaGrammar grammarForRootType = findSchemaGrammar(
-                    XSDDescription.CONTEXT_ELEMENT, rootTypeNamespace, null, 
null, null);
-                if (grammarForRootType != null) {
-                    fCurrentType = 
grammarForRootType.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+            else if (fRootTypeQName != null) {
+                String rootTypeNamespace = fRootTypeQName.getNamespaceURI();
+                if (rootTypeNamespace != null && 
rootTypeNamespace.equals(XMLConstants.NULL_NS_URI)) {
+                    rootTypeNamespace = null;
+                }
+                if 
(SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(rootTypeNamespace)) {
+                    fCurrentType = 
SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+                }
+                else {
+                    SchemaGrammar grammarForRootType = findSchemaGrammar(
+                            XSDDescription.CONTEXT_ELEMENT, rootTypeNamespace, 
null, null, null);
+                    if (grammarForRootType != null) {
+                        fCurrentType = 
grammarForRootType.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+                    }
+                }
+                if (fCurrentType == null) {
+                    String typeName = 
(fRootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
+                            fRootTypeQName.getLocalPart() :
+                                
fRootTypeQName.getPrefix()+":"+fRootTypeQName.getLocalPart();
+                            reportSchemaError("cvc-type.1", new Object[] 
{typeName});
                 }
-            }
-            if (fCurrentType == null) {
-                String typeName = 
(fRootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
-                    fRootTypeQName.getLocalPart() :
-                    
fRootTypeQName.getPrefix()+":"+fRootTypeQName.getLocalPart();
-                reportSchemaError("cvc-type.1", new Object[] {typeName});
             }
         }
         



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to