<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">ElementDeclarationComponent.java</a></tt> </td><td></td><td align="right" id="added">+22</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">154 -&gt; 155</td></tr>
<tr class="alt"><td><tt>test/resources/xsd/<a href="#file2">ElementRefTest.xsd</a></tt> </td><td></td><td align="right" id="added">+9</td><td></td><td nowrap="nowrap" align="center">154 -&gt; 155</td></tr>
<tr><td></td><td></td><td align="right" id="added">+31</td><td align="right" id="removed">-3</td><td></td></tr>
</table>
<small id="info">2 modified files</small><br />
<pre class="comment">
fix marshal method generation for global element with simpleType content
</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>ElementDeclarationComponent.java</b></big> <small id="info">154 -&gt; 155</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-09-10 23:39:39 UTC (rev 154)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/ElementDeclarationComponent.java        2007-09-17 21:42:39 UTC (rev 155)
@@ -62,14 +62,33 @@
</small></pre><pre class="diff" id="context">                                 context.generateCode(typeDef);
                         }
                 } else if (role == CodegenRole.MARSHAL) {
</pre><pre class="diff" id="added">+                        XSDTypeDefinition typeDef = elementDecl.getType();
</pre><pre class="diff" id="context">                         if (elementDecl.isGlobal()) {
</pre><pre class="diff" id="removed">-                                context.generateCode(elementDecl.getType());
</pre><pre class="diff" id="added">+                                if (typeDef instanceof XSDSimpleTypeDefinition) {
+                                        StatementContainer block = context.getCurrentMethodCode();
+                                        block.addStmt("var _result:XML = &lt;"+elementDecl.getName()+"/&gt;");
+                                        MappingFunction conv = context.functionFor(elementDecl);
+                                        String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
+                                        String converted = conv.appliedTo(accessExpr);
+                                        block.addStmt("_result.appendChild("+converted+")");
+                                        block.addStmt("return _result");
+                                } else {
+                                        if (XSDUtils.isAnonymous(typeDef)) {
+                                                context.generateCode(typeDef);
+                                        } else {
+                                                StatementContainer block = context.getCurrentMethodCode();
+                                                block.addStmt("var _result:XML = &lt;"+elementDecl.getName()+"/&gt;");
+                                                MappingFunction conv = context.functionFor(elementDecl);
+                                                String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
+                                                block.addStmt(conv.appliedTo("_result, "+accessExpr));
+                                                block.addStmt("return _result");
+                                        }
+                                }
</pre><pre class="diff" id="context">                         } else {
                                 StatementContainer block = context.getCurrentMethodCode();
                                 String propertyName = context.variableNameFor(elementDecl);
                                 String accessExpr = MarshalBuilder.getCurrentSourceExpr(context);
                                 String targetParentExpr = MarshalBuilder.getCurrentTargetParentElementExpr(context);
</pre><pre class="diff" id="removed">-                                XSDTypeDefinition typeDef = elementDecl.getType();
</pre><pre class="diff" id="context">                                 if (typeDef instanceof XSDSimpleTypeDefinition) {
                                         block.addStmt("var "+propertyName+":XML = &lt;"+elementDecl.getName()+"/&gt;");
                                         MappingFunction conv = context.functionFor(elementDecl);
</pre><pre class="diff"><small id="info">@@ -95,7 +114,7 @@
</small></pre><pre class="diff" id="context">                         ASClassType clazz = TypeBuilder.getCurrentType(context);
                         TypeDescriptor typeDesc = context.getTypeDescriptor(elementDecl);
                         ASField field = clazz.newField(context.variableNameFor(elementDecl.getResolvedElementDeclaration()), Visibility.PUBLIC, typeDesc.getTypeName());
</pre><pre class="diff" id="removed">-                        field.setDescription(typeDesc.getDocumentation());<span id="removedchars">                        </span>
</pre><pre class="diff" id="added">+                        field.setDescription(typeDesc.getDocumentation());
</pre><pre class="diff" id="context">                 } else {
                         throw new RuntimeException(getClass().getName()+" does not suppport operation generateCodeFor(role="+role+")");
                 }
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">asxsd/trunk/src/test/resources/xsd</span><br />
<div class="fileheader"><big><b>ElementRefTest.xsd</b></big> <small id="info">154 -&gt; 155</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/resources/xsd/ElementRefTest.xsd        2007-09-10 23:39:39 UTC (rev 154)
+++ trunk/src/test/resources/xsd/ElementRefTest.xsd        2007-09-17 21:42:39 UTC (rev 155)
@@ -7,6 +7,7 @@
</small></pre><pre class="diff" id="context">     &lt;sequence&gt;
       &lt;element ref="t:a"/&gt;
       &lt;element ref="t:b" minOccurs="0"/&gt;
</pre><pre class="diff" id="added">+      &lt;element ref="t:c"/&gt;
</pre><pre class="diff" id="context">     &lt;/sequence&gt;
   &lt;/complexType&gt;
 
</pre><pre class="diff"><small id="info">@@ -14,4 +15,12 @@
</small></pre><pre class="diff" id="context"> 
   &lt;element name="b" type="t:Test"/&gt;
 
</pre><pre class="diff" id="added">+  &lt;element name="c"&gt;
+    &lt;complexType&gt;
+      &lt;sequence&gt;
+        &lt;element ref="t:a"/&gt;
+      &lt;/sequence&gt;
+    &lt;/complexType&gt;
+  &lt;/element&gt;
+
</pre><pre class="diff" id="context"> &lt;/schema&gt;
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.12</small></center>
</body></html>