geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1189729 - in /geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator: MappingGeneratorTask.java XsdGenerator.java
Date Thu, 27 Oct 2011 12:59:56 GMT
Author: chirino
Date: Thu Oct 27 12:59:56 2011
New Revision: 1189729

URL: http://svn.apache.org/viewvc?rev=1189729&view=rev
Log:
Fixes XBEAN-191 : Support unordered elements in the XSD generated by XBean.

Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java

Modified: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java?rev=1189729&r1=1189728&r2=1189729&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
Thu Oct 27 12:59:56 2011
@@ -42,6 +42,7 @@ public class MappingGeneratorTask extend
     private File destFile = new File("target/classes/schema.xsd");
     private String metaInfDir = "target/classes/";
     private String propertyEditorPaths = "org.apache.xbean.spring.context.impl";
+    private boolean strictXsdOrder = true;
 
     public File getDestFile() {
         return destFile;
@@ -83,6 +84,14 @@ public class MappingGeneratorTask extend
         this.propertyEditorPaths = propertyEditorPaths;
     }
 
+    public boolean isStrictXsdOrder() {
+        return strictXsdOrder;
+    }
+
+    public void setStrictXsdOrder(boolean strictXsdOrder) {
+        this.strictXsdOrder = strictXsdOrder;
+    }
+
     public void execute() throws BuildException {
         if (namespace == null) {
             throw new BuildException("'namespace' must be specified");
@@ -113,7 +122,7 @@ public class MappingGeneratorTask extend
             GeneratorPlugin[] plugins = new GeneratorPlugin[]{
                 new XmlMetadataGenerator(metaInfDir, destFile),
                 new DocumentationGenerator(destFile),
-                new XsdGenerator(destFile)
+                new XsdGenerator(destFile, strictXsdOrder)
             };
 
             // load the mappings

Modified: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java?rev=1189729&r1=1189728&r2=1189729&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
Thu Oct 27 12:59:56 2011
@@ -31,9 +31,14 @@ import java.util.List;
 public class XsdGenerator implements GeneratorPlugin {
     private final File destFile;
     private LogFacade log;
+    private boolean strictOrder;
 
     public XsdGenerator(File destFile) {
+        this(destFile, true);
+    }
+    public XsdGenerator(File destFile, boolean strictOrder) {
         this.destFile = destFile;
+        this.strictOrder = strictOrder;
     }
 
     public void generate(NamespaceMapping namespaceMapping) throws IOException {
@@ -92,7 +97,11 @@ public class XsdGenerator implements Gen
             }
         }
         if (complexCount > 0) {
-            out.println("      <xs:sequence>");
+            if(strictOrder){
+                out.println("      <xs:sequence>");
+            } else {
+                out.println("      <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\"><xs:choice>");
+            }
             for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();)
{
                 AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
                 if (!namespaceMapping.isSimpleType(attributeMapping.getType())) {
@@ -100,7 +109,11 @@ public class XsdGenerator implements Gen
                 }
             }
             out.println("        <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/>");
-            out.println("      </xs:sequence>");
+            if(strictOrder){
+                out.println("      </xs:sequence>");
+            } else {
+                out.println("      </xs:choice></xs:choice>");
+            }
         }
 
         for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();)
{



Mime
View raw message