Author: mrglavas
Date: Sat Nov 15 21:35:57 2008
New Revision: 717983

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

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

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=717983&r1=717982&r2=717983&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
 Sat Nov 15 21:35:57 2008
@@ -570,7 +570,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;
+            }
         }
         else if (propertyId.equals(XML_SCHEMA_VERSION)) {
             // TODO: do we use fSchemaLoader.setProperty
@@ -1233,6 +1244,7 @@
     private final QName fTempQName = new QName();
     
     private javax.xml.namespace.QName fRootTypeQName = null;
+    private XSTypeDefinition fRootTypeDefinition = null;
     
     private int fIgnoreXSITypeDepth;
     
@@ -1430,10 +1442,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;
@@ -1932,26 +1957,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