Hi,

i'm using the 'redefine'-tag to extend an already existing XML schema.
When i try to compile the extending schema i get a NullPointerException.
Looking into the code, it came out the problem is in the StscJavaizer
class, which was missing the line:

allSeenTypes.addAll(Arrays.asList(state.redefinedGlobalTypes()));

.. in order to 'javaize' all extending elements.

I also added the following code to the SchemaTypeSystemImpl class, so
the generated beans can compile:

        SchemaType[] result = new SchemaType[_globalTypes.size() +
_redefinedGlobalTypes.size()];
        int j = 0;
        for (Iterator i = _globalTypes.values().iterator(); i.hasNext();
j++)
            result[j] = ((SchemaType.Ref)i.next()).get();
        for (Iterator i = _redefinedGlobalTypes.iterator(); i.hasNext();
j++)
            result[j] = ((SchemaType.Ref)i.next()).get();



However this is just a fast fix and remains just a proposal. Please let
me know if the code is ok and it gets commited to the svn, or some other
fix is applied.

For the code above, see the attached patches.


Best regards,
Simeon Penev
Index: /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
===================================================================
--- /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java	(revision 396846)
+++ /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java	(working copy)
@@ -3593,10 +3593,12 @@
         if (_globalTypes.isEmpty())
             return EMPTY_ST_ARRAY;
 
-        SchemaType[] result = new SchemaType[_globalTypes.size()];
+        SchemaType[] result = new SchemaType[_globalTypes.size() + _redefinedGlobalTypes.size()];
         int j = 0;
         for (Iterator i = _globalTypes.values().iterator(); i.hasNext(); j++)
             result[j] = ((SchemaType.Ref)i.next()).get();
+        for (Iterator i = _redefinedGlobalTypes.iterator(); i.hasNext(); j++)
+            result[j] = ((SchemaType.Ref)i.next()).get();        
         return result;
     }
 
Index: /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
===================================================================
--- /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java	(revision 397224)
+++ /home/simeon/workspace/xmlbeans-trunc/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java	(working copy)
@@ -49,6 +49,7 @@
         allSeenTypes.addAll(Arrays.asList(state.documentTypes()));
         allSeenTypes.addAll(Arrays.asList(state.attributeTypes()));
         allSeenTypes.addAll(Arrays.asList(state.globalTypes()));
+        allSeenTypes.addAll(Arrays.asList(state.redefinedGlobalTypes()));
 
         // First distribute the global names among the top entities.
         if (javaize)

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

Reply via email to