You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2010/11/10 20:19:05 UTC

svn commit: r1033652 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/ xs/ xs/traversers/ xs/traversers/override/ xs/traversers/override/exception/

Author: knoaman
Date: Wed Nov 10 19:19:05 2010
New Revision: 1033652

URL: http://svn.apache.org/viewvc?rev=1033652&view=rev
Log:
Implementation of <xs:override> by Udayanga Wickramasinghe (with some minor changes).
Jira bug: https://issues.apache.org/jira/browse/XERCESJ-1433

Added:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java   (with props)
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java   (with props)
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java   (with props)
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java   (with props)
Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDDescription.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1033652&r1=1033651&r2=1033652&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Wed Nov 10 19:19:05 2010
@@ -148,6 +148,8 @@
         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-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}''.

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java?rev=1033652&r1=1033651&r2=1033652&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java Wed Nov 10 19:19:05 2010
@@ -90,6 +90,7 @@ public final class SchemaSymbols {
     public static final String ELT_MINSCALE               = "minScale".intern();
     public static final String ELT_NOTATION               = "notation".intern();
     public static final String ELT_OPENCONTENT            = "openContent".intern();
+    public static final String ELT_OVERRIDE               = "override".intern();
     public static final String ELT_PATTERN                = "pattern".intern();
     public static final String ELT_REDEFINE               = "redefine".intern();
     public static final String ELT_RESTRICTION            = "restriction".intern();

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDDescription.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDDescription.java?rev=1033652&r1=1033651&r2=1033652&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDDescription.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDDescription.java Wed Nov 10 19:19:05 2010
@@ -90,6 +90,13 @@ public class XSDDescription extends XMLR
      * until a component from that namespace is referenced from the instance.
      */
     public final static short CONTEXT_XSITYPE   = 7;
+    
+    /**
+     * Indicate that the current schema document is being <override>n by another
+     * schema document.
+     */
+    
+    public final static short CONTEXT_OVERRIDE  = 8;
 
     // REVISIT: write description of these fields	
     protected short fContextType;

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java?rev=1033652&r1=1033651&r2=1033652&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java Wed Nov 10 19:19:05 2010
@@ -1052,6 +1052,8 @@ public class XSAttributeChecker {
         // XML Schema 1.1 - same list
         fEleAttrs11MapG.put(SchemaSymbols.ELT_INCLUDE, attrList);
         fEleAttrs11MapG.put(SchemaSymbols.ELT_REDEFINE, attrList);
+        // for element "override" - global
+        fEleAttrs11MapG.put(SchemaSymbols.ELT_OVERRIDE, attrList);
 
         // for element "import" - global
         attrList = Container.getContainer(3);

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=1033652&r1=1033651&r2=1033652&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java Wed Nov 10 19:19:05 2010
@@ -61,6 +61,8 @@ import org.apache.xerces.impl.xs.identit
 import org.apache.xerces.impl.xs.opti.ElementImpl;
 import org.apache.xerces.impl.xs.opti.SchemaDOMParser;
 import org.apache.xerces.impl.xs.opti.SchemaParsingConfig;
+import org.apache.xerces.impl.xs.traversers.override.DOMOverrideImpl;
+import org.apache.xerces.impl.xs.traversers.override.OverrideTransformationManager;
 import org.apache.xerces.impl.xs.util.SimpleLocator;
 import org.apache.xerces.impl.xs.util.XSInputSource;
 import org.apache.xerces.parsers.SAXParser;
@@ -341,11 +343,13 @@ public class XSDHandler {
     // use Schema Element to lookup the SystemId.
     private String doc2SystemId(Element ele) {
         String documentURI = null;
-        /**
-         * REVISIT: Casting until DOM Level 3 interfaces are available. -- mrglavas
-         */
-        if(ele.getOwnerDocument() instanceof org.apache.xerces.impl.xs.opti.SchemaDOM){
-            documentURI = ((org.apache.xerces.impl.xs.opti.SchemaDOM) ele.getOwnerDocument()).getDocumentURI();
+        final Document ownerDoc = ele.getOwnerDocument();
+
+        if (ownerDoc instanceof org.apache.xerces.impl.xs.opti.SchemaDOM) {
+            documentURI = ((org.apache.xerces.impl.xs.opti.SchemaDOM) ownerDoc).getDocumentURI();
+        }
+        else if (ownerDoc.getImplementation().hasFeature("Core", "3.0")) {
+            documentURI = ownerDoc.getDocumentURI();
         }
         return documentURI != null ? documentURI : (String) fDoc2SystemId.get(ele);
     }
@@ -418,6 +422,9 @@ public class XSDHandler {
     // the Grammar Pool
     private XMLGrammarPool fGrammarPool;
     
+    //override Manager
+    private OverrideTransformationManager fOverrideHandler;
+    
     //************ Traversers **********
     XSDAttributeGroupTraverser fAttributeGroupTraverser;
     XSDAttributeTraverser fAttributeTraverser;
@@ -648,11 +655,17 @@ public class XSDHandler {
             	fDoc2SystemId.put(schemaRoot, schemaId);
             }
         }
-        
+
         // before constructing trees and traversing a schema, need to reset
         // all traversers and clear all registries
         prepareForTraverse();
-        
+
+        // Tell override handler about the original schema root
+        // Need to know if that schema would be later overriden - possible collision
+        if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+            fOverrideHandler.addSchemaRoot((String)fDoc2SystemId.get(schemaRoot), schemaRoot);
+        }
+
         fRoot = constructTrees(schemaRoot, is.getSystemId(), desc, grammar != null);
         if (fRoot == null) {
             return null;
@@ -840,7 +853,8 @@ public class XSDHandler {
             int secondIdx = 0;
             // for include and redefine
             if (referType == XSDDescription.CONTEXT_INCLUDE ||
-                    referType == XSDDescription.CONTEXT_REDEFINE) {
+                    referType == XSDDescription.CONTEXT_REDEFINE ||
+                    referType == XSDDescription.CONTEXT_OVERRIDE ) {
                 // if the referred document has no targetNamespace,
                 // it's a chameleon schema
                 if (currSchemaInfo.fTargetNamespace == null) {
@@ -907,7 +921,8 @@ public class XSDHandler {
             updateImportListFor(sg);
         }
         else if (referType == XSDDescription.CONTEXT_INCLUDE ||
-                referType == XSDDescription.CONTEXT_REDEFINE) {
+                        referType == XSDDescription.CONTEXT_REDEFINE || 
+                        referType == XSDDescription.CONTEXT_OVERRIDE) {
             sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
         }
         else if(fHonourAllSchemaLocations && referType == XSDDescription.CONTEXT_IMPORT) {
@@ -1047,7 +1062,8 @@ public class XSDHandler {
                 newSchemaRoot = resolveSchema(fSchemaGrammarDescription, false, child, isg == null);
             }
             else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
-                    (localName.equals(SchemaSymbols.ELT_REDEFINE))) {
+                    (localName.equals(SchemaSymbols.ELT_REDEFINE)) ||
+                    (localName.equals(SchemaSymbols.ELT_OVERRIDE) && fSchemaVersion == Constants.SCHEMA_VERSION_1_1)) {
                 // validation for redefine/include will be the same here; just
                 // make sure TNS is right (don't care about redef contents
                 // yet).
@@ -1111,32 +1127,66 @@ public class XSDHandler {
                 }
                 // pass the systemId of the current document as the base systemId
                 boolean mustResolve = false;
+                boolean isOverride = false;
                 refType = XSDDescription.CONTEXT_INCLUDE;
-                if(localName.equals(SchemaSymbols.ELT_REDEFINE)) {
+                if (localName.equals(SchemaSymbols.ELT_REDEFINE)) {
                     mustResolve = nonAnnotationContent(child);
                     refType = XSDDescription.CONTEXT_REDEFINE;
                 }
+                else if (localName.equals(SchemaSymbols.ELT_OVERRIDE)){
+                    mustResolve = nonAnnotationContent(child);
+                    refType = XSDDescription.CONTEXT_OVERRIDE;
+                    isOverride = true;
+                }
                 fSchemaGrammarDescription.reset();
                 fSchemaGrammarDescription.setContextType(refType);
                 fSchemaGrammarDescription.setBaseSystemId(doc2SystemId(schemaRoot));
                 fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
                 fSchemaGrammarDescription.setTargetNamespace(callerTNS);
-                
-                boolean alreadyTraversed = false;
+
                 XMLInputSource schemaSource = resolveSchemaSource(fSchemaGrammarDescription, mustResolve, child, true);
-                if (fNamespaceGrowth && refType == XSDDescription.CONTEXT_INCLUDE) {
-                    try {
-                        final String schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
-                        alreadyTraversed = sg.getDocumentLocations().contains(schemaId);
-                    }
-                    catch(MalformedURIException e) {
-                        
-                    }
+                String schemaId = null;
+                try {
+                    schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);                     
+                }
+                catch(MalformedURIException e) {
                 }
 
+                // If namespace growth is enabled, and we have already
+                // processed the same schema (ie. same system id), we
+                // treat the schema as duplicate, since we cannot replace
+                // the existing global components
+                boolean alreadyTraversed = (fNamespaceGrowth) ? sg.getDocumentLocations().contains(schemaId) : false;
                 if (!alreadyTraversed) {
                     newSchemaRoot = resolveSchema(schemaSource, fSchemaGrammarDescription, mustResolve, child);
                     schemaNamespace = currSchemaInfo.fTargetNamespace;
+                    if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+                        if (isOverride) {
+                            final Element transformedSchemaRoot = (Element) fOverrideHandler.transform(schemaId, child, newSchemaRoot);
+
+                            // Either we had a collision where the transformed
+                            // schema has global components or we hit a
+                            // transformation cycle
+                            if (transformedSchemaRoot == null) {
+                                fLastSchemaWasDuplicate = true;
+                            }
+                            // In case of a collision where the transformed
+                            // schema has no global components, the override
+                            // transformer will return the new transformed
+                            // schema. We need to process that new schema,
+                            // so we set the duplicate schema flag to false
+
+                            else if (fLastSchemaWasDuplicate && transformedSchemaRoot != newSchemaRoot) {
+                                fLastSchemaWasDuplicate = false;
+                            }
+
+                            newSchemaRoot = transformedSchemaRoot;
+                        }
+                        else {
+                            // check for override collision
+                            fOverrideHandler.checkSchemaRoot(schemaId, child, newSchemaRoot);
+                        }
+                    }
                 }
                 else {
                     fLastSchemaWasDuplicate = true;
@@ -1174,7 +1224,7 @@ public class XSDHandler {
         fDependencyMap.put(currSchemaInfo, dependencies);
         return currSchemaInfo;
     } // end constructTrees
-    
+
     private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
         SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
         if (sg == null) {
@@ -1288,7 +1338,8 @@ public class XSDHandler {
                     continue;
                 }
                 else if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_INCLUDE) ||
-                        DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_IMPORT)) {
+                        DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_IMPORT) ||
+                        (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_OVERRIDE) && fSchemaVersion == Constants.SCHEMA_VERSION_1_1)) {
                     if (!dependenciesCanOccur) {
                         reportSchemaError("s4s-elt-invalid-content.3", new Object [] {DOMUtil.getLocalName(globalComp)}, globalComp);
                     }
@@ -1502,8 +1553,22 @@ public class XSDHandler {
                     currSG.addAnnotation(fElementTraverser.traverseAnnotationDecl(globalComp, currSchemaDoc.getSchemaAttrs(), true, currSchemaDoc));
                     sawAnnotation = true;
                 }
-                else if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && componentType.equals(SchemaSymbols.ELT_DEFAULTOPENCONTENT)) {
-                    currSchemaDoc.fDefaultOpenContent = fComplexTypeTraverser.traverseOpenContent(globalComp, currSchemaDoc, currSG, true);
+                else if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+                    if (componentType.equals(SchemaSymbols.ELT_DEFAULTOPENCONTENT)) {
+                        currSchemaDoc.fDefaultOpenContent = fComplexTypeTraverser.traverseOpenContent(globalComp, currSchemaDoc, currSG, true);
+                    }
+                    // if component is of override type - currently we do not
+                    // attempt to validate <override> Element since it will
+                    // be reflected on schema anyway
+                    //
+                    // REVISIT - is it required to validate Override components
+                    // that do not affect any schema..?
+                    else if (componentType.equals(SchemaSymbols.ELT_OVERRIDE)){
+                        continue;
+                    }
+                    else {
+                        reportSchemaError("s4s-elt-invalid-content.1", new Object [] {SchemaSymbols.ELT_SCHEMA, DOMUtil.getLocalName(globalComp)}, globalComp);
+                    }
                 }
                 else {
                     reportSchemaError("s4s-elt-invalid-content.1", new Object [] {SchemaSymbols.ELT_SCHEMA, DOMUtil.getLocalName(globalComp)}, globalComp);
@@ -3601,6 +3666,10 @@ public class XSDHandler {
         fGlobalNotationDecls.clear();
         fGlobalIDConstraintDecls.clear();
         fGlobalTypeDecls.clear();
+        
+        if (fOverrideHandler != null) {
+            fOverrideHandler.reset();
+        }
     }
     public void setDeclPool (XSDeclarationPool declPool){
         fDeclPool = declPool;
@@ -3708,8 +3777,7 @@ public class XSDHandler {
         } catch (XMLConfigurationException e) {
         }
         
-        fTypeValidatorHelper = TypeValidatorHelper.getInstance(fSchemaVersion);
-        
+        fTypeValidatorHelper = TypeValidatorHelper.getInstance(fSchemaVersion);        
     } // reset(XMLComponentManager)
     
     
@@ -4445,6 +4513,9 @@ public class XSDHandler {
         }
         else {
             fSupportedVersion = SUPPORTED_VERSION_1_1;
+            if (fOverrideHandler == null) {
+                fOverrideHandler = new OverrideTransformationManager(this, new DOMOverrideImpl(this));
+            }
         }
         fSchemaParser.setSupportedVersion(fSupportedVersion);
     }

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java?rev=1033652&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java Wed Nov 10 19:19:05 2010
@@ -0,0 +1,327 @@
+/*
+ * 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.traversers.override;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.traversers.XSDHandler;
+import org.apache.xerces.impl.xs.traversers.override.exception.OverrideTransformException;
+import org.apache.xerces.util.DOMUtil;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+/**
+ * @version $Id$
+ */
+public class DOMOverrideImpl extends OverrideTransformer {
+
+    // records all the override schema components and it's properties
+    private ArrayList fOverrideComponents = new ArrayList();
+
+    // overridden schema document 
+    private Document fOverridenDoc;
+
+    // <override> schema Element
+    private Element fOverrideElem;
+
+    // indicates transformer that it has performed at least single transformation
+    private boolean hasPerformedTransformations = false;
+
+    // DOM implementation for Document creation
+    private DOMImplementation fDOMImpl;
+    
+    // XSDHandler - error reporting
+    private XSDHandler fSchemaHandler;
+
+    public DOMOverrideImpl(XSDHandler schemaHandler){
+        fSchemaHandler = schemaHandler;
+        try {
+            //System.setProperty(DOMImplementationRegistry.PROPERTY,"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
+            //get a DOM registry base
+            final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+            // get a DOM implementation the Level 3 XML module
+            fDOMImpl = registry.getDOMImplementation("XML 3.0");
+        } catch (ClassCastException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ClassNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (InstantiationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        };
+    }      
+
+    public void clearState(){
+        fOverrideComponents.clear();
+        fOverridenDoc = null;
+        fOverrideElem = null;            
+        hasPerformedTransformations = false;
+    }
+
+    /**
+     * Given an override Schema Element ie:- <override> and a schema B ,this method will 
+     * try to produce override transformations on schema B and generate a overridden schema version B' 
+     * Or It will return a null if override transformations cannot be applied on B
+     * ie:- B does not have overriden schema elements as specified in override Schema Element
+     * 
+     * @param overrideElement -an override Schema Element ie:- <override> 
+     * @param overridenSchema -an overridden schema B   
+     */
+    public Element transform(Element overrideElement, Element overridenSchema)
+            throws OverrideTransformException {
+        fOverridenDoc = cloneOverridenSchema(overridenSchema);
+        final Element overridenSchemaRoot = fOverridenDoc.getDocumentElement();
+
+        fOverrideElem = overrideElement;
+        fillOverrideElementMap(fOverrideElem);
+        transform(overridenSchemaRoot,false);
+
+        if (hasOverrideTransformations()){
+            clearState();
+            return overridenSchemaRoot;
+        }
+
+        clearState();
+        return null;
+    }
+
+    public boolean hasOverrideTransformations(){
+        return hasPerformedTransformations;
+    }
+
+    /**
+     * Main <override> transform method , It will go through all global schema components of the overridden document
+     * and perform override transformations as necessary. Transformations are recursively applied on <redefine> and 
+     * <override> elements of  the overridden schema. This also handles deferred transformations on <include> and 
+     * <override> elements.
+     * 
+     * @param overrideSchemaRoot -root of overridden Schema Element  
+     * @param isOverrideRoot -indicates whether transformations are currently applied on a <override> element located 
+     *                        in overridden schema document. useful for <override> merge transformations.  
+     */
+    private void transform(Element overridenSchemaRoot, boolean isOverrideRoot) {
+        for (Element child = DOMUtil.getFirstChildElement(overridenSchemaRoot);
+             child != null;
+             child = DOMUtil.getNextSiblingElement(child)){
+
+            final String localName = getLocalName(child);
+            if (localName.equals(SchemaSymbols.ELT_ANNOTATION)){
+                continue;
+            }
+            else if (localName.equals(SchemaSymbols.ELT_INCLUDE)){
+                //create new <Override> Element for this Document 
+                final Element temp = fOverrideElem;
+                //set schemaLocation to the same location as <include>
+                String newSchemaLocation = child.getAttribute(SchemaSymbols.ATT_SCHEMALOCATION);
+                child = performDOMOverride(overridenSchemaRoot, temp, child);
+                child.setAttribute(SchemaSymbols.ATT_SCHEMALOCATION, newSchemaLocation);
+                hasPerformedTransformations = true;
+            }
+            else if(localName.equals(SchemaSymbols.ELT_REDEFINE)){
+                transform(child,false);
+            }
+            else if(localName.equals(SchemaSymbols.ELT_OVERRIDE)){
+                transform(child,true);
+                //do <override> merging
+                mergeOverride(child);
+            }
+            else {
+                final String componentName = DOMUtil.getAttrValue(child, SchemaSymbols.ATT_NAME);
+                if (componentName.length() == 0) {
+                    continue;
+                }
+                int componentType = getOverrideType(localName);
+                if (componentType == 0) {
+                    continue;
+                }
+                OverrideElement newNode = getMatchingOverrideElement(componentType, componentName);
+                Element oldNode = child;
+                //check if element needs to be overridden     
+                if (newNode != null){
+                    child = performDOMOverride(overridenSchemaRoot, newNode.originalElement, oldNode);
+                    if (!child.isEqualNode(oldNode)) {
+                        hasPerformedTransformations = true;
+                    }
+
+                    if (isOverrideRoot){
+                        newNode.overrideCloned = true;   
+                    }
+                }
+            }
+        }
+    }
+    
+    /**
+     * Register elements of the <override> schema component for later processing 
+     */
+    private void fillOverrideElementMap(Element overrideElement){
+        for (Element child = DOMUtil.getFirstChildElement(overrideElement);
+             child != null;
+             child = DOMUtil.getNextSiblingElement(child)){
+
+            final String localName = getLocalName(child);
+            if (localName.equals(SchemaSymbols.ELT_ANNOTATION)){
+                continue;
+            }
+            else {
+                final int componentOverrideType = getOverrideType(localName);
+                if (componentOverrideType != 0) {
+                    addOverrideElement(componentOverrideType, child);
+                }
+                else {
+                    fSchemaHandler.reportSchemaError("s4s-elt-must-match.1", new Object[]{"override", "(annotation | (simpleType | complexType | group | attributeGroup | element | attribute | notation))*", DOMUtil.getLocalName(child)}, child);
+                }
+            }            
+        }
+    }
+
+    /**
+     * Create a new OverrideElemnt and record it into <override> components
+     */
+    private void addOverrideElement(int componentType, Element elem) {
+        String cName = DOMUtil.getAttrValue(elem, SchemaSymbols.ATT_NAME);
+        OverrideElement e = new OverrideElement(componentType, elem,cName);
+        fOverrideComponents.add(e);
+    }
+
+    /**
+     * Check for override transformations with respect to the current schema Element
+     * in the overriden schema Document
+     */
+    private OverrideElement getMatchingOverrideElement(int componentType, String cName){
+        Iterator iter = fOverrideComponents.iterator();
+        while (iter.hasNext()) {
+            OverrideElement oElem = (OverrideElement) iter.next();
+            if (oElem.componentType == componentType && oElem.cName.equals(cName)) {
+                return oElem;
+            }
+        }
+
+        return null;
+    }
+    
+    private int getOverrideType(String localName){
+        if (localName.equals(SchemaSymbols.ELT_SIMPLETYPE) || localName.equals(SchemaSymbols.ELT_COMPLEXTYPE )){
+            return OVERRIDE_TYPE_DEFINITION;                              
+        }
+        else if (localName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ){
+            return OVERRIDE_ATTRIBUTE_GROUP;   
+        }
+        else if (localName.equals(SchemaSymbols.ELT_GROUP)){
+            return OVERRIDE_GROUP;           
+        }
+        else if (localName.equals(SchemaSymbols.ELT_ELEMENT)){
+            return OVERRIDE_ELEMENT;   
+        }
+        else if (localName.equals(SchemaSymbols.ELT_NOTATION)){
+            return OVERRIDE_NOTATION;   
+        }
+        else if (localName.equals(SchemaSymbols.ELT_ATTRIBUTE)){
+            return OVERRIDE_ATTRIBUTE;   
+        }
+        
+        return 0;
+    }
+    
+    /** 
+     * produce a schema B' identical to the overridden schema document B for override transformations
+     */
+    private Document cloneOverridenSchema(Element overridenRoot){
+        final Document newDoc = fDOMImpl.createDocument(null, null, null);
+        final Node newRoot = newDoc.importNode(overridenRoot, true);
+
+        // Document URI need to be set for proper schema resolving
+        newDoc.setDocumentURI(overridenRoot.getOwnerDocument().getDocumentURI());
+        newDoc.appendChild(newRoot);
+
+        return newDoc;
+    }
+    
+    /**
+     * Create a node identical to the given node
+     */
+    private Node getChildClone(Node child){
+        return fOverridenDoc.importNode(child,true);
+    }
+    
+    /**
+     * Perform merge override transformations on <override> element 
+     */
+    private void mergeOverride(Element overrideElement){
+        Iterator iter = fOverrideComponents.iterator();
+        while (iter.hasNext()){
+            OverrideElement oElem = (OverrideElement) iter.next();
+            if (!oElem.overrideCloned){
+                overrideElement.appendChild(getChildClone(oElem.originalElement));
+                hasPerformedTransformations = true;
+            }
+            else {
+                oElem.overrideCloned = false;
+            }
+        }
+    }
+
+    /**
+     * Perform general override transformations on <override> element
+     * replace current element with the new override element
+     * 
+     */
+    private Element performDOMOverride(Element overridenSchemaRoot,Element overrideNode, Element oldNode) {
+        Element clonedNode = (Element)getChildClone(overrideNode);
+        overridenSchemaRoot.replaceChild(clonedNode,oldNode);
+        return clonedNode;
+    }
+    
+    private String getLocalName(Node node){
+        String localName = "";
+        localName = DOMUtil.getLocalName(node);
+        if(localName.indexOf(":") > -1){
+            return localName.split(":")[1];
+        }
+        
+        return localName;
+    }
+
+    /**
+     * Override Element class
+     * 
+     * Used to store override elements and properties for later processing
+     */
+    private static class OverrideElement{
+        int componentType;
+        Element originalElement;
+        boolean overrideCloned = false; 
+        String cName ;
+        
+        OverrideElement(int componentType, Element elem,String cName) {
+            this.componentType = componentType;
+            originalElement = elem;
+            this.cName = cName; 
+        }
+    }
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/DOMOverrideImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java?rev=1033652&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java Wed Nov 10 19:19:05 2010
@@ -0,0 +1,379 @@
+/*
+ * 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.traversers.override;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.traversers.XSDHandler;
+import org.apache.xerces.impl.xs.traversers.override.exception.OverrideTransformException;
+import org.apache.xerces.util.DOMUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+final public class OverrideTransformationManager {
+
+    // public static data
+    public final static int STATE_INCLUDE = 1;
+    public final static int STATE_CONTINUE = 2;
+    public final static int STATE_DUPLICATE = 3;
+    public final static int STATE_COLLISION = 4;
+
+    // private static data
+    private static String[] fGlobalComponentNames = {
+        SchemaSymbols.ELT_ATTRIBUTEGROUP,
+        SchemaSymbols.ELT_ATTRIBUTE,
+        SchemaSymbols.ELT_COMPLEXTYPE,
+        SchemaSymbols.ELT_SIMPLETYPE,
+        SchemaSymbols.ELT_ELEMENT,
+        SchemaSymbols.ELT_NOTATION,
+        SchemaSymbols.ELT_GROUP
+        };
+
+    private static String[] fCompositeComponentNames = {
+        SchemaSymbols.ELT_INCLUDE,
+        SchemaSymbols.ELT_OVERRIDE,
+        SchemaSymbols.ELT_REDEFINE 
+        };
+
+    // private data 
+    private OverrideTransformer fOverrideTransformationHandler;
+    private Hashtable fSystemId2ContextMap = new Hashtable();
+    private int fCurrentState = STATE_INCLUDE;
+    private XSDHandler fSchemaHandler;
+
+    // Constructor
+    public OverrideTransformationManager(XSDHandler handler, OverrideTransformer overrideHandler){
+        fSchemaHandler = handler;
+        fOverrideTransformationHandler = overrideHandler;
+    }
+
+    /**
+     * Reset state
+     */
+    public void reset() {
+        fCurrentState = STATE_INCLUDE;
+        if (fSystemId2ContextMap.size() != 0) {
+            fSystemId2ContextMap.clear();
+        }
+    }
+
+    /**
+     * Perform override transformations on target schema. If transformation
+     * takes place and we do not have a collision, we return the transformed
+     * schema. If no transformation and no collision, we return the original
+     * target schema, otherwise we return null to prevent the target schema
+     * from being added to the dependency list.
+     */
+    public Element transform(String schemaId, Element overrideElement, Element targetSchema) {
+        Element transformedSchema;
+        boolean hasPerformedTransformations = false;
+
+        // do transformations if an <override> element is parsed
+        // else just an include/redefined scenario we want to check dependency only
+        try {
+            transformedSchema = fOverrideTransformationHandler.transform(overrideElement,targetSchema);
+        }
+        catch (OverrideTransformException e) {
+            // NOTE: Exception is only throw when doing JAXP transformation
+            //       For now, we just return the original schema
+            return targetSchema;
+        }
+
+        if (transformedSchema != null) {
+            hasPerformedTransformations = true;                    
+        }                
+        else { // if no override transformations has taken place let transformed be the original
+            transformedSchema = targetSchema;
+        }
+
+        // include current schema (transformed/not) into context
+        final String schemaIdString = nullToEmptyString(schemaId);
+        if (checkSchemaDependencies(schemaIdString, overrideElement, transformedSchema, hasPerformedTransformations)) {
+            return transformedSchema;
+        }
+
+        return null;
+    }
+
+    /**
+     * Add a schema to the list of processed schemas. 
+     */
+    public void addSchemaRoot(String schemaId, Element schemaRoot) {
+        final String schemaIdString = nullToEmptyString(schemaId);
+        setDocumentMapForSystemId(schemaIdString ,
+                createDocumentMap(schemaRoot,DocumentContext.IS_ORIGINAL));
+    }
+
+    /**
+     * Check original schema root for possible collision
+     * 
+     * @param schemaId The system id of the schema
+     * @param schemaRoot The root of the schema
+     */
+    public void checkSchemaRoot(String schemaId, Element decl, Element schemaRoot) {
+        final String schemaIdString = nullToEmptyString(schemaId);
+
+        if (includeSchemaDependencies(schemaIdString, schemaRoot, DocumentContext.IS_ORIGINAL)) {
+            fCurrentState = STATE_INCLUDE;
+            return;
+        }
+
+        DocumentContext dCtxt = getDocumentMapForSystemId(schemaIdString);            
+        Iterator mappedRoots = dCtxt.getSchemaArray();
+
+        // for each schema root stored in the context compare for duplicates 
+        while (mappedRoots.hasNext()){
+            final Element mRoot = (Element) mappedRoots.next();
+            if (DocumentContext.IS_ORIGINAL == dCtxt.getSchemaState(mRoot)) {
+                fCurrentState = STATE_DUPLICATE;
+                return;
+            }
+        }
+
+        // We have a collision - schema id was overridden
+        fCurrentState = STATE_COLLISION;
+        fSchemaHandler.reportSchemaError("src-override-collision.1", new Object [] {
+                schemaId, DOMUtil.getLocalName(decl)}, decl);
+    }
+
+    /**
+     * Return the state after immediate transformation 
+     */
+    public int getCurrentState(){
+        return fCurrentState;
+    }
+
+    /**
+     * Set <code>override</code> transformer
+     * 
+     * @param overrideHandler <code>override</code> transformer handler to set
+     */
+    public void setOverrideHandler(OverrideTransformer overrideHandler){
+        fOverrideTransformationHandler = overrideHandler ;
+    }
+
+    /**
+     * Tries to create a Document Map for a schemaElement
+     * records different Schema Component Types within the created Document Map 
+     */
+    private DocumentContext createDocumentMap(Element schemaRootElement, Boolean state){
+        DocumentContext dCtxt = new DocumentContext();
+        dCtxt.addSchemasToArray(schemaRootElement,state);
+        
+        return dCtxt;
+    }
+
+    public boolean hasGlobalDecl(Element schemaRoot){
+        return hasComponentsTypes(schemaRoot, fGlobalComponentNames);
+    }
+
+    public boolean hasCompositionalDecl(Element schemaRoot){
+        return hasComponentsTypes(schemaRoot, fCompositeComponentNames);
+    }
+
+    /**
+     * Check the dependency state of the given schema document (ie:-include it in the dependency list/not ,etc )
+     * during <override>'s and <include>'s
+     * There are four dependency states
+     * --> INCLUDE - first time inclusion to dependency tree
+     * --> CONTINUE - Ok to include into dependency tree
+     * --> COLLISION - there is a name collision between the current schema and the corresponding schemas in dependency tree
+     * --> DUPLICATE - Sometimes during overrides inclusion may be valid but would be repeated due to a cycle. This state indicates
+     *                 Transformer/caller to stop further inclusion of the schema
+     *
+     * Dependencies are first checked for the global elements of the current schema with respect to the corresponding schemas of the 
+     * dependency tree. If no collisions are detected it checks for any cycles else indicate continuation with inclusion of current schema
+     *
+     */
+    private boolean checkSchemaDependencies(String schemaId, Element decl, Element schemaRoot, boolean hasTransformationsOnSchema){
+        Boolean newSchemaState = (hasTransformationsOnSchema == true) 
+            ? DocumentContext.IS_TRANSFORMED : DocumentContext.IS_ORIGINAL;
+
+        // First time to see the schema, we store the information and return
+        if (includeSchemaDependencies(schemaId, schemaRoot,newSchemaState)) {
+            fCurrentState = STATE_INCLUDE;
+            return true;
+        }
+
+        // We have seen the schema before, so either it's the same or
+        // we have a collision
+        boolean collisionState = false;
+        DocumentContext dCtxt = getDocumentMapForSystemId(schemaId);            
+        Iterator mappedRoots = dCtxt.getSchemaArray();
+
+        // for each schema root stored in the context compare for duplicates 
+        while (mappedRoots.hasNext()) {
+            Element mRoot = (Element) mappedRoots.next();
+            if (checkDuplicateElements(dCtxt,mRoot, schemaRoot, newSchemaState)){
+                // Either the schema is original and being referenced multiple
+                // times or we hit an override cycle
+                fCurrentState = STATE_DUPLICATE;
+                return false;
+            }
+            else {
+                collisionState = true;
+            }
+        } //end of while
+
+        // if no duplicates were found ,here state can only be COLLISON or CONTINUE 
+        if (collisionState) {
+            //check for any actual collison                                                     
+            if (!hasGlobalDecl(schemaRoot)) {     
+                dCtxt.addSchemasToArray(schemaRoot);
+            }
+            else {
+                // We have a collision - schema id was previously included/redefined/overridden
+                fCurrentState = STATE_COLLISION;
+                fSchemaHandler.reportSchemaError("src-override-collision.2", new Object [] {
+                        schemaId }, decl);   
+                return false;
+            }
+        }//end of If
+        
+        fCurrentState = STATE_CONTINUE;
+        return true;
+    }
+
+    /**
+     * Include this schema into the dependency map for the respective schema ID
+     */
+    private boolean includeSchemaDependencies(String schemaId,Element schemaRoot, Boolean state){
+        if (!isSchemaAlreadyTraversed(schemaId)){
+            setDocumentMapForSystemId(schemaId,createDocumentMap(schemaRoot,state));
+            return true;
+        }
+
+        return false;
+    }
+    
+    /**
+     * Check whether schema corresponding to this schema ID has already been included in the map
+     */
+    private boolean isSchemaAlreadyTraversed(String schemaId){        
+        return (fSystemId2ContextMap.get(schemaId) != null);
+    }
+
+    /**
+     * Checks for equality on two global components (with same name Attribute)
+     *       true --> if two components are equal in content 
+     *       false --> otherwise
+     */
+    private boolean checkDuplicateElements(DocumentContext dCtxt,Element contextComponent, Element newComponent, Boolean stateNewSchema){
+        Boolean stateCtxtElement = dCtxt.getSchemaState(contextComponent);
+        //if both schemas are transformed check #isEquals
+        if (stateCtxtElement == DocumentContext.IS_TRANSFORMED && stateNewSchema == DocumentContext.IS_TRANSFORMED ){    
+            return compareComponents(contextComponent,newComponent);
+        }
+        
+        // if both schemas are original ==> compared schemas are duplicates
+        // if one of the schemas is Transformed ==> then they are not duplicates hence possibility of Collision
+        return (stateCtxtElement == DocumentContext.IS_ORIGINAL && stateNewSchema == DocumentContext.IS_ORIGINAL);
+    }
+
+    private boolean compareComponents(Element component1,Element component2){
+        //normalize two elements before comparing
+        component1.normalize();
+        component2.normalize();
+        //perform a deep equality comparison on two nodes
+        return component1.isEqualNode(component2);
+    }
+    
+    private DocumentContext getDocumentMapForSystemId(String systemId){        
+        return (DocumentContext) fSystemId2ContextMap.get(systemId);
+    }
+
+    private void setDocumentMapForSystemId(String systemId, DocumentContext map){
+        fSystemId2ContextMap.put(systemId, map);
+        
+    }
+
+    private String nullToEmptyString(String input) {
+        return (input == null) ? "" : input;
+    }
+
+    private boolean hasComponentsTypes(Element schemaRoot,String[] types){                
+        for (Element child = DOMUtil.getFirstChildElement(schemaRoot);
+                child != null;
+                child = DOMUtil.getNextSiblingElement(child)){  
+            String localName = getLocalName(child);
+            for(int i=0;i<types.length;i++){
+                if(types[i].equals(localName)){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }   
+
+    private String getLocalName(Node node){
+        String localName = "";
+        localName = DOMUtil.getLocalName(node);
+        if(localName.indexOf(":") > -1){
+            return localName.split(":")[1];
+        }
+        
+        return localName;
+    }
+
+    /**
+     * A context to store schema related information related to any schema corresponding to a particular 
+     * schemaId location 
+     * It records ,
+     * --> global elements of a particular schema and
+     * --> override elements list corresponding to each schema with respect to a given schemaId location
+     */
+    private static final class DocumentContext {     
+        
+        private ArrayList fRootElementList = new ArrayList();
+        private Hashtable fSchema2StateMap = new Hashtable();
+        
+        //indicate Transformation handler that this schema root is original
+        private final static Boolean IS_ORIGINAL = Boolean.TRUE;
+        //indicate Transformation handler that this schema root is transformed
+        private final static Boolean IS_TRANSFORMED = Boolean.FALSE;
+        
+        DocumentContext() {
+
+        }
+
+        void addSchemasToArray(Element schemaRoot){
+            fRootElementList.add(schemaRoot);
+        }
+        
+        void addSchemasToArray(Element schemaRoot, Boolean state){
+            addSchemasToArray(schemaRoot);
+            fSchema2StateMap.put(schemaRoot, state);
+        }
+
+        Boolean getSchemaState(Element schemaRoot){
+            return ((Boolean) fSchema2StateMap.get(schemaRoot));
+        }
+        
+        Iterator getSchemaArray(){
+            return fRootElementList.iterator();
+        }
+        
+        void clear() {
+            fRootElementList.clear();
+            fSchema2StateMap.clear();
+        }
+    }
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformationManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java?rev=1033652&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java Wed Nov 10 19:19:05 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.traversers.override;
+
+import org.apache.xerces.impl.xs.traversers.override.exception.OverrideTransformException;
+import org.w3c.dom.Element;
+
+
+public abstract class OverrideTransformer {
+
+    // different type definitions needed to record type of OverrideElement
+    // before processing is done 
+    protected final static int OVERRIDE_TYPE_DEFINITION = 1 ;
+    protected final static int OVERRIDE_ATTRIBUTE_GROUP = 2 ;
+    protected final static int OVERRIDE_GROUP = 3 ;
+    protected final static int OVERRIDE_ELEMENT = 4 ;
+    protected final static int OVERRIDE_NOTATION = 5 ;
+    protected final static int OVERRIDE_ATTRIBUTE = 6 ;  
+
+    // Constructor - not accessible
+    protected OverrideTransformer(){
+    }
+
+    /**
+     * Any transformer Implementation should implement this method
+     * given a DOM overrideElement, and overridden schema. This method
+     * should give the transformed DOM element.
+     *
+     */
+    public abstract Element transform(Element overrideElement, Element overridenSchema) throws OverrideTransformException;
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/OverrideTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java?rev=1033652&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java Wed Nov 10 19:19:05 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.traversers.override.exception;
+
+/**
+ * @version $Id$
+ */
+public class OverrideTransformException extends Exception {
+
+    private static final long serialVersionUID = 5800328170981546685L;
+
+    public OverrideTransformException() {
+        // TODO Auto-generated constructor stub
+    }
+
+    public OverrideTransformException(String message) {
+        super(message);
+        // TODO Auto-generated constructor stub
+    }
+
+    public OverrideTransformException(Throwable cause) {
+        super(cause);
+        // TODO Auto-generated constructor stub
+    }
+
+    public OverrideTransformException(String message, Throwable cause) {
+        super(message, cause);
+        // TODO Auto-generated constructor stub
+    }
+
+}
+

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/override/exception/OverrideTransformException.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