Index: DynClassExportHelper.java
===================================================================
--- DynClassExportHelper.java	(revision 1404)
+++ DynClassExportHelper.java	(revision 1405)
@@ -8,9 +8,12 @@
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
 import org.gvsig.tools.dynobject.DynClass;
+import org.gvsig.tools.dynobject.DynClass_v2;
 import org.gvsig.tools.dynobject.DynField;
 import org.gvsig.tools.dynobject.DynObjectValueItem;
+import org.gvsig.tools.script.Script;
 
 public class DynClassExportHelper implements DynClassImportExportTags {
 
@@ -18,9 +21,13 @@
 
         private String tagname;
         private Map attributes = new LinkedHashMap();
+        private String text = null;
+        private boolean close = false;
+        private int indent = -1;
 
-        public XMLTag(String tagname) {
+        public XMLTag(String tagname, int indent) {
             this.tagname = tagname;
+            this.indent = indent;
         }
 
         public String getTagname() {
@@ -49,6 +56,14 @@
             this.attributes.put(name, value? "true":"false");
         }
         
+        public void close() {
+            this.close = true;
+        }
+        
+        public void setText(String text) {
+            this.text = text;
+        }
+        
         public String toString() {
             StringBuffer buffer = new StringBuffer();
             buffer.append("<");
@@ -64,9 +79,36 @@
                     buffer.append("\"");
                 }
             }
-            buffer.append(">\n");
+            buffer.append(">");
+            if( !StringUtils.isEmpty(this.text) ) {
+                if( StringUtils.isAlphanumeric(this.text) ) {
+                    buffer.append(this.text);
+                } else {
+                    buffer.append("\n<![CDATA[\n");
+                    buffer.append(this.text);
+                    buffer.append("\n]]>\n");
+                }
+            } else {
+                buffer.append("\n");
+            }
+            if( this.close ) {
+                buffer.append(this.spaces(indent));
+                buffer.append("</").append(this.tagname).append(">\n");
+            }
             return buffer.toString();
         }
+        
+        private String spaces(int indent) {
+            if( indent<1 ) {
+                return "";
+            }
+            String spaces = "                                                                      ";
+            if( indent*2 > spaces.length() ) {
+                return spaces;
+            } else {
+                return spaces.substring(0, indent*2);
+            }
+        }
     }
 
     private class XMLHelper {
@@ -115,9 +157,13 @@
         }
 
         public XMLTag createTag(String tagname) {
-            return new XMLTag(tagname);
+            return new XMLTag(tagname, -1);
         }
         
+        public XMLTag createTag(String tagname, int indent) {
+            return new XMLTag(tagname, indent);
+        }
+        
         public XMLHelper append(int indent, XMLTag tag) {
             this.indent(indent);
             this.buffer.append(tag.toString());
@@ -180,11 +226,24 @@
                 tag.set(CLASS_NAMESPACE_TAG, superDynClass.getNamespace());
                 tag.set(CLASS_NAME_TAG, superDynClass.getName());
                 buffer.append(indent, tag);
+                buffer.close(indent,tag);
             }
         }
         buffer.close(--indent, CLASS_EXTENDS_TAG);
         
         buffer.append(indent, CLASS_DESCRIPTION_TAG, dynClass.getDescription());
+
+        if( dynClass instanceof DynClass_v2 ) {
+            Script script = ((DynClass_v2)dynClass).getScript();
+            if( script != null ) {
+                tag = buffer.createTag(CLASS_CODE_TAG);
+                tag.set(CLASS_LANGCODE_TAG, script.getTypeName());
+                tag.setText(script.getCode());
+                tag.close();
+                buffer.append(indent, tag);
+            }
+        }
+
         
         buffer.append(indent++, CLASS_FIELDS_TAG);
         
