<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"><span id="added">SimpleContentComponent.java</span></a></tt> </td><td></td><td align="right" id="added">+75</td><td></td><td nowrap="nowrap" align="right">added 168</td></tr>
<tr class="alt"><td><tt>test/java/uk/co/badgersinfoil/asxsd/schemas/<a href="#file2"><span id="added">SimpleContentTest.java</span></a></tt> </td><td></td><td align="right" id="added">+19</td><td></td><td nowrap="nowrap" align="right">added 168</td></tr>
<tr><td><tt>test/resources/xsd/<a href="#file3"><span id="added">SimpleContentTest.xsd</span></a></tt> </td><td></td><td align="right" id="added">+12</td><td></td><td nowrap="nowrap" align="right">added 168</td></tr>
<tr><td></td><td></td><td align="right" id="added">+106</td><td></td><td></td></tr>
</table>
<small id="info">3 added files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: how to derive the correct type?</a></li>
</ul></div>
<pre class="comment">
simplistic support for simpleContent in a complexType
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/main/java/uk/co/badgersinfoil/asxsd/components</span><br />
<div class="fileheader" id="added"><big><b>SimpleContentComponent.java</b></big> <small id="info">added at 168</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SimpleContentComponent.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/asxsd/components/SimpleContentComponent.java        2007-10-14 21:38:23 UTC (rev 168)
@@ -0,0 +1,75 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.components;
+
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import uk.co.badgersinfoil.asxsd.CodegenContext;
+import uk.co.badgersinfoil.asxsd.CodegenRole;
+import uk.co.badgersinfoil.asxsd.MappingFunction;
+import uk.co.badgersinfoil.asxsd.MarshalBuilder;
+import uk.co.badgersinfoil.asxsd.StringUtils;
+import uk.co.badgersinfoil.asxsd.TypeBuilder;
+import uk.co.badgersinfoil.asxsd.UnmarshalBuilder;
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+import uk.co.badgersinfoil.metaas.dom.ASField;
+import uk.co.badgersinfoil.metaas.dom.StatementContainer;
+import uk.co.badgersinfoil.metaas.dom.Visibility;
+
+public class SimpleContentComponent extends AbstractMappingComponent {
+
+        
+        public void generateCode(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                CodegenRole role = context.getCurrentRole();
+                XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)component;
+                if (role == CodegenRole.UNMARSHAL) {
+                        StatementContainer code = context.getCurrentMethodCode();
+                        String sourceExpr = UnmarshalBuilder.getCurrentSourceExpr(context);
+                        String attrAccessExpr = sourceExpr+".text()";
+//                        MappingFunction function = context.functionFor(component);
+//                        String converted = function.appliedTo(attrAccessExpr);
+                        String converted = attrAccessExpr;
+                        code.addStmt("_result."+context.variableNameFor(simpleType)+" = "+converted);
+                } else if (role == CodegenRole.MARSHAL) {
+                        StatementContainer code = context.getCurrentMethodCode();
+                        String sourceExpr = MarshalBuilder.getCurrentSourceExpr(context);
+                        String propertyNameExpr = sourceExpr+"."+context.variableNameFor(simpleType);
+//                        MappingFunction function = context.functionFor(component);
+//                        String converted = function.appliedTo(propertyNameExpr);
+                        String converted = propertyNameExpr;
+                        code.addStmt("_result.append("+converted+")");
+                } else if (role == CodegenRole.TYPE) {
+                        ASClassType clazz = TypeBuilder.getCurrentType(context);
<a name="task1" />+                        // <span class="task">TODO</span>: how to derive the correct type?
+                        String asType = "String";
+                        String fieldName = context.variableNameFor(component);
+//                        String fieldName = context.createTypeNameFor(elementDecl) + "Value";
+                        ASField field = clazz.newField(fieldName, Visibility.PUBLIC, asType);
+                        field.setDescription("The value of the element body");
+                } else {
+                        super.generateCode(context, component);
+                }
+        }
+        
+        
+
+        public String variableNameFor(CodegenContext context,
+         XSDConcreteComponent component)
+        {
+                String typeName = context.createTypeNameFor(component.getContainer());
+                int pos = typeName.lastIndexOf('.');
+                if (pos > 0) {
+                        typeName = typeName.substring(pos + 1);
+                }
+                return typeName + "Value";
+        }
+
+
+
+        public boolean willAccept(XSDConcreteComponent component) {
+                return component instanceof XSDSimpleTypeDefinition && component.getContainer() instanceof XSDComplexTypeDefinition;
+        }
+
+}
</pre></div>
<hr /><a name="file2" /><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>SimpleContentTest.java</b></big> <small id="info">added at 168</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/SimpleContentTest.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/asxsd/schemas/SimpleContentTest.java        2007-10-14 21:38:23 UTC (rev 168)
@@ -0,0 +1,19 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.asxsd.schemas;
+
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
+import uk.co.badgersinfoil.metaas.dom.ASField;
+
+public class SimpleContentTest extends SchemaTestCase {
+        public void testClassName() {
+                ASCompilationUnit unit = (ASCompilationUnit)project.getCompilationUnits().get(0);
+                ASClassType clazz = (ASClassType)unit.getType();
+                assertEquals("Test", clazz.getName());
+
+                ASField field = clazz.getField("prop");
+                assertEquals("String", field.getType());
+
+                ASField body = clazz.getField("TestValue");
+                assertEquals("String", body.getType());
+        }
+}
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added">asxsd/trunk/src/test/resources/xsd</span><br />
<div class="fileheader" id="added"><big><b>SimpleContentTest.xsd</b></big> <small id="info">added at 168</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/resources/xsd/SimpleContentTest.xsd         (rev 0)
+++ trunk/src/test/resources/xsd/SimpleContentTest.xsd        2007-10-14 21:38:23 UTC (rev 168)
@@ -0,0 +1,12 @@
</small></pre><pre class="diff" id="added">+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="http://example.org/test"
+ xmlns:t="http://example.org/test">
+ <complexType name="Test">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="prop" type="string"/>
+ </extension>
+ </simpleContent>
+ </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>