<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#copied {background-color:#ccccff;}
tr.alt #copied {background-color:#bbbbf7;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>asxsd/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/asxsd/components/<a href="#file1">OptionallyOccuringParticleComponent.java</a></tt> </td><td></td><td align="right" id="added">+7</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">186 -> 187</td></tr>
<tr class="alt"><td><tt> /<a href="#file2">SequenceMappingComponent.java</a></tt> </td><td></td><td align="right" id="added">+49</td><td></td><td nowrap="nowrap" align="center">186 -> 187</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/asxsd/schemas/<a href="#file3"><span id="added">OptionalSequenceTest.java</span></a></tt> </td><td></td><td align="right" id="added">+12</td><td></td><td nowrap="nowrap" align="right">added 187</td></tr>
<tr class="alt"><td><tt>test/resources/xsd/<a href="#file4"><span id="added">OptionalSequenceTest.xsd</span></a></tt> </td><td></td><td align="right" id="added">+10</td><td></td><td nowrap="nowrap" align="right">added 187</td></tr>
<tr><td></td><td></td><td align="right" id="added">+78</td><td align="right" id="removed">-1</td><td></td></tr>
</table>
<small id="info">2 added + 2 modified, total 4 files</small><br />
<pre class="comment">
handle <sequence minOccurs="0">
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>OptionallyOccuringParticleComponent.java</b></big> <small id="info">186 -> 187</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/OptionallyOccuringParticleComponent.java        2007-11-12 00:44:25 UTC (rev 186)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/OptionallyOccuringParticleComponent.java        2007-11-15 22:41:44 UTC (rev 187)
@@ -4,6 +4,7 @@
</small></pre><pre class="diff" id="context">
package uk.co.badgersinfoil.asxsd.components;
</pre><pre class="diff" id="added">+import org.eclipse.xsd.XSDElementDeclaration;
</pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDParticle;
import org.eclipse.xsd.XSDParticleContent;
import uk.co.badgersinfoil.asxsd.CodegenContext;
</pre><pre class="diff"><small id="info">@@ -35,7 +36,12 @@
</small></pre><pre class="diff" id="context">                         StatementContainer ifBlock = containingBlock.newIf(detectExpr);
                        context.pushAttrScope();
                        String src = MarshalBuilder.getCurrentSourceExpr(context);
</pre><pre class="diff" id="removed">-                        String access = src + "." + context.variableNameFor(content);
</pre><pre class="diff" id="added">+                        String access;
+                        if (content instanceof XSDElementDeclaration) {
+                                access = src + "." + context.variableNameFor(content);
+                        } else {
+                                access = src;
+                        }
</pre><pre class="diff" id="context">                         MarshalBuilder.setCurrentSourceExpr(context, access);
                        context.setCurrentMethodCode(ifBlock);
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader"><big><b>SequenceMappingComponent.java</b></big> <small id="info">186 -> 187</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SequenceMappingComponent.java        2007-11-12 00:44:25 UTC (rev 186)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SequenceMappingComponent.java        2007-11-15 22:41:44 UTC (rev 187)
@@ -12,6 +12,9 @@
</small></pre><pre class="diff" id="context"> import org.eclipse.xsd.XSDParticle;
import uk.co.badgersinfoil.asxsd.CodegenContext;
import uk.co.badgersinfoil.asxsd.CodegenRole;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.asxsd.XSDUtils;
+import uk.co.badgersinfoil.metaas.ActionScriptFactory;
+import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.StatementContainer;
public class SequenceMappingComponent extends AbstractMappingComponent {
</pre><pre class="diff"><small id="info">@@ -50,6 +53,52 @@
</small></pre><pre class="diff" id="context">                 }
        }
</pre><pre class="diff" id="added">+        public ASExpression createExpression(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                XSDModelGroup modelGroup = (XSDModelGroup)component;
+                ActionScriptFactory fact = context.getFactory();
+                List particles = modelGroup.getParticles();
+                if (role == CodegenRole.UNMARSHAL_DETECT) {
+                        if (particles.isEmpty()) {
+                                return fact.newExpression("false");
+                        }
+                        Iterator i=particles.iterator();
+                        ASExpression detect = context.createExpression((XSDParticle)i.next());
+                        while (i.hasNext()) {
+                                XSDParticle part = (XSDParticle)i.next();
+                                ASExpression rhs = context.createExpression(part);
+                                detect = fact.newOrExpression(detect, rhs);
+                                if (XSDUtils.isRequiredToAppear(part)) {
+                                        // Don't need to check for other
+                                        // elements if this one is mandatory,
+                                        break;
+                                }
+                        }
+                        return detect;
+                }
+                if (role == CodegenRole.MARSHAL_DETECT) {
+                        if (particles.isEmpty()) {
+                                return fact.newExpression("false");
+                        }
+                        Iterator i = particles.iterator();
+                        ASExpression detect = context.createExpression((XSDParticle)i.next());
+                        while (i.hasNext()) {
+                                XSDParticle part = (XSDParticle)i.next();
+                                ASExpression rhs = context.createExpression(part);
+                                detect = fact.newOrExpression(detect, rhs);
+                                if (XSDUtils.isRequiredToAppear(part)) {
+                                        // Don't need to check for other
+                                        // elements if this one is mandatory,
+                                        break;
+                                }
+                        }
+                        return detect;
+                }
+                return super.createExpression(context, component);
+        }
+
</pre><pre class="diff" id="context">         public String createTypeNameFor(CodegenContext context,
         XSDConcreteComponent component)
        {
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas</span><br />
<div class="fileheader" id="added"><big><b>OptionalSequenceTest.java</b></big> <small id="info">added at 187</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/OptionalSequenceTest.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/OptionalSequenceTest.java        2007-11-15 22:41:44 UTC (rev 187)
@@ -0,0 +1,12 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.schemas;
+
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+
+public class OptionalSequenceTest extends SchemaTestCase {
+        public void testIt() {
+                ASClassType type = getTestASClass();
+
+                assertNotNull(type.getField("a"));
+                assertNotNull(type.getField("b"));
+        }
+}
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/resources/xsd</span><br />
<div class="fileheader" id="added"><big><b>OptionalSequenceTest.xsd</b></big> <small id="info">added at 187</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/resources/xsd/OptionalSequenceTest.xsd         (rev 0)
+++ trunk/src/test/resources/xsd/OptionalSequenceTest.xsd        2007-11-15 22:41:44 UTC (rev 187)
@@ -0,0 +1,10 @@
</small></pre><pre class="diff" id="added">+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://example.org/test">
+ <complexType name="Test">
+ <sequence minOccurs="0">
+ <element name="a" type="string" minOccurs="0"/>
+ <element name="b" type="string"/>
+ </sequence>
+ </complexType>
+</schema>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>