[Libreoffice-commits] core.git: Branch 'aoo/trunk' - ooxml/source

Andre Fischer af at apache.org
Tue Jun 17 07:10:00 PDT 2014


 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionDescriptor.java                 |   93 ---
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionIterator.java                   |   97 ---
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionManager.java                    |  142 ----
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionTrigger.java                    |   10 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeDescriptor.java              |  112 ---
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeManager.java                 |  220 -------
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeProvider.java                |   99 ---
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeValues.java                  |   49 -
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ElementContext.java                   |    2 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/IAction.java                          |   27 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Log.java                              |   27 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NameMap.java                          |   13 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NamespaceMap.java                     |    2 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/OOXMLParser.java                      |    8 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ParseTableReader.java                 |   26 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Parser.java                           |   14 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/StateMachine.java                     |   43 +
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionDescriptor.java          |   93 +++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionIterator.java            |   97 +++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionManager.java             |  144 ++++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionTrigger.java             |   10 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/IAction.java                   |   29 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeDescriptor.java    |  109 +++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeManager.java       |  265 ++++++++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeProvider.java      |   99 +++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeValues.java        |   71 ++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/BlobParser.java                  |   81 ++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/DateTimeParser.java              |   21 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ISimpleTypeParser.java           |   10 
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ListParser.java                  |   32 +
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/NumberParser.java                |  250 ++++++++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/SimpleTypeManager.java           |   90 ++
 ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/StringParser.java                |  101 +++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/SchemaReader.java                        |   62 +-
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/Test.java                                |    1 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/CreatorBase.java               |   77 --
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/DFACreator.java                |   15 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomaton.java           |   17 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomatonContainer.java  |    1 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/HopcroftMinimizer.java         |   10 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/NonValidatingCreator.java      |   44 -
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/State.java                     |   49 +
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateContext.java              |   29 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateSet.java                  |   21 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/ValidatingCreator.java         |  137 ++--
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/LogGenerator.java              |   19 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/ParserTablesGenerator.java     |  310 +++++++++-
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/misc/Log.java                            |  105 +++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Location.java                 |    8 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/CopyVisitor.java          |    1 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/RequestVisitor.java       |    6 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/schema/SchemaBase.java             |   18 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/simple/BuiltIn.java                |   73 --
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/simple/BuiltInType.java            |   88 ++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/simple/Restriction.java            |  189 +++++-
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/simple/SimpleType.java             |   19 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/parser/SchemaParser.java                 |    9 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/parser/XmlNamespace.java                 |   22 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/parser/XsdNamespace.java                 |   29 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/BlobNode.java                     |  110 +++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/DateTimeNode.java                 |   71 ++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/EnumerationNode.java              |    6 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/ISimpleTypeNode.java              |   27 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/ISimpleTypeNodeVisitor.java       |   10 
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/NumberNode.java                   |  289 +++++++++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/SimpleTypeContainer.java          |   81 ++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/SimpleTypeDescriptor.java         |   65 ++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/SimpleTypeDescriptorFactory.java  |  286 +++++++++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/SimpleTypeNodeVisitorAdapter.java |   39 +
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/StringNode.java                   |  248 ++++++++
 ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/simple/UnionNode.java                    |  130 ++++
 71 files changed, 4016 insertions(+), 1191 deletions(-)

New commits:
commit c69abc15e1d7c07482e72ac9d862993fab239870
Author: Andre Fischer <af at apache.org>
Date:   Tue Jun 17 13:01:38 2014 +0000

    125035: Added support for attribute types (simple types).

diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeValues.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeValues.java
deleted file mode 100644
index 0d21486..0000000
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeValues.java
+++ /dev/null
@@ -1,49 +0,0 @@
-
-package org.apache.openoffice.ooxml.parser;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-/** Container of attribute values of an opening tag.
- */
-public class AttributeValues
-{
-    AttributeValues ()
-    {
-        maAttributes = new TreeMap<>();
-    }
-
-
-
-
-    public void AddAttribute (
-        final AttributeDescriptor aAttributeDescriptor,
-        final String sValue)
-    {
-        maAttributes.put(
-            aAttributeDescriptor.GetName(),
-            sValue);
-    }
-
-
-
-
-    public Iterable<Entry<String,Object>> GetAttributes ()
-    {
-        return maAttributes.entrySet();
-    }
-
-
-
-
-    public int GetAttributeCount ()
-    {
-        return maAttributes.size();
-    }
-
-
-
-
-    private Map<String,Object> maAttributes;
-}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ElementContext.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ElementContext.java
index 04da341..60f2da8 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ElementContext.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ElementContext.java
@@ -1,5 +1,7 @@
 package org.apache.openoffice.ooxml.parser;
 
+import org.apache.openoffice.ooxml.parser.attribute.AttributeValues;
+
 /** Context that has the same life time (by default) as the element it represents.
  *  Gives access to the attribute values and the parent context.
  */
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Log.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Log.java
index 843b233..cefdd51 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Log.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Log.java
@@ -22,6 +22,7 @@
 package org.apache.openoffice.ooxml.parser;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -42,6 +43,14 @@ public class Log
 
 
 
+    public Log (final String sFilename)
+    {
+        this(CreateFileOutputStream(sFilename));
+    }
+
+
+
+
     public Log (final File aFile)
     {
         this(CreateFileOutputStream(aFile));
@@ -98,6 +107,24 @@ public class Log
 
 
 
+    private static OutputStream CreateFileOutputStream (final String sFilename)
+    {
+        OutputStream aOut;
+        try
+        {
+            aOut = new FileOutputStream(sFilename);
+            return aOut;
+        }
+        catch (FileNotFoundException e)
+        {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+
+
     private final OutputStream maOut;
     private String msIndentation;
 }
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NameMap.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NameMap.java
index f15d3f6..a8af8f9 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NameMap.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NameMap.java
@@ -60,6 +60,19 @@ public class NameMap
 
 
 
+    public int GetIdForOptionalName (
+        final String sName)
+    {
+        final Integer aId = maNameToIdMap.get(sName);
+        if (aId == null)
+            return -1;
+        else
+            return aId;
+    }
+
+
+
+
     public String GetNameForId (final int nId)
     {
         if (nId == -1)
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NamespaceMap.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NamespaceMap.java
index e12f1b5..d5a2af8 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NamespaceMap.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/NamespaceMap.java
@@ -27,7 +27,7 @@ import java.util.Vector;
 
 public class NamespaceMap
 {
-    class NamespaceDescriptor
+    public class NamespaceDescriptor
     {
         NamespaceDescriptor (final String sPrefix, final int nId)
         {
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/OOXMLParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/OOXMLParser.java
index e8df037..d150b1f 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/OOXMLParser.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/OOXMLParser.java
@@ -32,6 +32,10 @@ import java.util.zip.ZipFile;
 
 import javax.xml.stream.Location;
 
+import org.apache.openoffice.ooxml.parser.action.ActionManager;
+import org.apache.openoffice.ooxml.parser.action.ActionTrigger;
+import org.apache.openoffice.ooxml.parser.action.IAction;
+
 /** This OOXML parser is based on the output of the schema parser.
  *  It exists to debug the schema parser and as illustration and preparation of
  *  the C++ parse (yet to come.)
@@ -154,7 +158,7 @@ public class OOXMLParser
                     if (aContext.GetAttributes().GetAttributeCount() == 0)
                         System.out.printf("    no attributes\n");
                     else
-                        for (final Entry<String,Object> aAttribute : aContext.GetAttributes().GetAttributes())
+                        for (final Entry<String,String> aAttribute : aContext.GetAttributes().GetAttributes())
                             System.out.printf("    %s -> %s\n", aAttribute.getKey(), aAttribute.getValue());
                 }
             }
@@ -169,7 +173,7 @@ public class OOXMLParser
                     final String sText,
                     final Location aLocation)
                 {
-                    System.out.printf("%s text \"%s\"\n", aContext.GetTypeName(), sText.replace("\n", "\\n"));
+//                    System.out.printf("%s text \"%s\"\n", aContext.GetTypeName(), sText.replace("\n", "\\n"));
                 }
             }
         );
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ParseTableReader.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ParseTableReader.java
index d8426cb..a596d2b 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ParseTableReader.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ParseTableReader.java
@@ -28,16 +28,26 @@ public class ParseTableReader
                 final String sLine = aReader.readLine();
                 if (sLine == null)
                     break;
-                if (sLine.startsWith("#"))
+                else if (sLine.startsWith("#"))
+                    continue;
+                else if (sLine.isEmpty())
                     continue;
 
-                // Splitting just at whitespace may be too simple to keep quoted text
-                // (used e.g. for attribute default values) in one peace when
-                // it contains whitespace.  Should this case occur than this
-                // implementation has to be improved.
-                final String aParts[] = sLine.split("\\s+");
-
-                GetSection(aParts[0]).add(aParts);
+                final String[] aLineParts = sLine.split("\\s+");
+                for (int nIndex=0; nIndex<aLineParts.length; ++nIndex)
+                {
+                    final String sPart = aLineParts[nIndex];
+                    if (sPart.isEmpty())
+                    {
+                        throw new RuntimeException();
+                    }
+                    else if (sPart.charAt(0) == '"')
+                    {
+                        // Remove leading and trailing quotes, unquote spaces.
+                        aLineParts[nIndex] = sPart.substring(1, sPart.length()-1).replace("%20", " ").replace(""", "\"");
+                    }
+                }
+                GetSection(aLineParts[0]).add(aLineParts);
             }
 
             aReader.close();
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Parser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Parser.java
index cd0883d..538907f 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Parser.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/Parser.java
@@ -6,6 +6,9 @@ import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.openoffice.ooxml.parser.action.ActionManager;
+import org.apache.openoffice.ooxml.parser.attribute.AttributeProvider;
+
 /** This is the actual parser (where OOXMLParser is the front end that handles
  *  parameters given to the main method).
  */
@@ -23,7 +26,7 @@ public class Parser
 
 
 
-    void Parse ()
+    public void Parse ()
     {
         try
         {
@@ -67,7 +70,6 @@ public class Parser
                         break;
 
                     case XMLStreamReader.END_DOCUMENT:
-                        Log.Std.printf("--- end of document ---\n");
                         break;
 
                     default:
@@ -197,6 +199,14 @@ public class Parser
 
 
 
+    public ActionManager GetActionManager()
+    {
+        return maMachine.GetActionManager();
+    }
+
+
+
+
     private final XMLStreamReader maReader;
     private final StateMachine maMachine;
     private int mnElementCount;
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/StateMachine.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/StateMachine.java
index c851b2c..26fdb46 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/StateMachine.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/StateMachine.java
@@ -26,6 +26,14 @@ import java.util.Stack;
 
 import javax.xml.stream.Location;
 
+import org.apache.openoffice.ooxml.parser.action.ActionManager;
+import org.apache.openoffice.ooxml.parser.action.ActionTrigger;
+import org.apache.openoffice.ooxml.parser.action.IAction;
+import org.apache.openoffice.ooxml.parser.attribute.AttributeManager;
+import org.apache.openoffice.ooxml.parser.attribute.AttributeProvider;
+import org.apache.openoffice.ooxml.parser.attribute.AttributeValues;
+import org.apache.openoffice.ooxml.parser.type.SimpleTypeManager;
+
 /** The state machine is initialized at creation from the data tables
  *  created previously by a stack automaton.
  */
@@ -42,29 +50,37 @@ public class StateMachine
         maStateNameMap = new NameMap(aReader.GetSection("state-name"));
         maTransitions = new TransitionTable(aReader.GetSection("transition"));
         maSkipStates = new SkipStateTable(aReader.GetSection("skip"));
+        maAttributeValueMap = new NameMap(aReader.GetSection("attribute-value"));
         maAcceptingStates = new AcceptingStateTable(aReader.GetSection("accepting-state"));
+        maSimpleTypeManager = new SimpleTypeManager(
+            aReader.GetSection("simple-type"),
+            maAttributeValueMap);
         maAttributeManager = new AttributeManager(
             aReader.GetSection("attribute"),
             maNamespaceMap,
-            maNameMap);
+            maNameMap,
+            maStateNameMap,
+            maSimpleTypeManager);
         mnStartStateId = Integer.parseInt(aReader.GetSection("start-state").firstElement()[1]);
         mnEndStateId = Integer.parseInt(aReader.GetSection("end-state").firstElement()[1]);
+
         mnCurrentStateId = mnStartStateId;
         maStateStack = new Stack<>();
         maElementContextStack = new Stack<>();
         maActionManager = new ActionManager(maStateNameMap);
 
-        System.out.printf("read %d namespace, %d names, %d states (%d skip, %d accept), %d transitions and %d attributes\n",
-            maNamespaceMap.GetNamespaceCount(),
-            maNameMap.GetNameCount(),
-            maStateNameMap.GetNameCount(),
-            maSkipStates.GetSkipStateCount(),
-            maAcceptingStates.GetAcceptingStateCount(),
-            maTransitions.GetTransitionCount(),
-            maAttributeManager.GetAttributeCount());
-
         if (Log.Dbg != null)
+        {
+            Log.Dbg.printf("read %d namespace, %d names, %d states (%d skip, %d accept), %d transitions and %d attributes\n",
+                maNamespaceMap.GetNamespaceCount(),
+                maNameMap.GetNameCount(),
+                maStateNameMap.GetNameCount(),
+                maSkipStates.GetSkipStateCount(),
+                maAcceptingStates.GetAcceptingStateCount(),
+                maTransitions.GetTransitionCount(),
+                maAttributeManager.GetAttributeCount());
             Log.Dbg.printf("starting in state _start_ (%d)\n", mnCurrentStateId);
+        }
     }
 
 
@@ -98,11 +114,12 @@ public class StateMachine
             if (aTransition == null)
             {
                 final String sText = String.format(
-                    "can not find transition for state %s(%d) and element %s(%d:%d) at L%dC%d\n",
+                    "can not find transition for state %s(%d) and element %s:%s(%d:%d) at L%dC%d\n",
                     maStateNameMap.GetNameForId(mnCurrentStateId),
                     mnCurrentStateId,
-                    aNamespaceDescriptor.Id,
+                    aNamespaceDescriptor.Prefix,
                     maNameMap.GetNameForId(nElementNameId),
+                    aNamespaceDescriptor.Id,
                     nElementNameId,
                     aLocation.getLineNumber(),
                     aLocation.getColumnNumber());
@@ -285,7 +302,9 @@ public class StateMachine
     private final NameMap maNameMap;
     private final NameMap maStateNameMap;
     private final TransitionTable maTransitions;
+    private final SimpleTypeManager maSimpleTypeManager;
     private final AttributeManager maAttributeManager;
+    private final NameMap maAttributeValueMap;
     private int mnCurrentStateId;
     private Stack<Integer> maStateStack;
     private ElementContext maCurrentElementContext;
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionDescriptor.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionDescriptor.java
similarity index 97%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionDescriptor.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionDescriptor.java
index fe3bae7..25be5a9 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionDescriptor.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionDescriptor.java
@@ -1,4 +1,4 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.action;
 
 import java.util.Vector;
 
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionIterator.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionIterator.java
similarity index 98%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionIterator.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionIterator.java
index 0b6307f..8566dc0 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionIterator.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionIterator.java
@@ -1,4 +1,4 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.action;
 
 import java.util.Iterator;
 
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionManager.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionManager.java
similarity index 97%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionManager.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionManager.java
index 4acd8ab..e473ab6 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionManager.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionManager.java
@@ -1,13 +1,15 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.action;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.openoffice.ooxml.parser.NameMap;
+
 /** Manage actions that are bound to states and XML events.
  */
 public class ActionManager
 {
-    ActionManager (
+    public ActionManager (
         final NameMap aStateNameToIdMap)
     {
         maStateNameToIdMap = aStateNameToIdMap;
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionTrigger.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionTrigger.java
similarity index 71%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionTrigger.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionTrigger.java
index 26c9759..62735a8 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/ActionTrigger.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/ActionTrigger.java
@@ -1,4 +1,4 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.action;
 
 /** An enumeration of all supported action triggers.
  */
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/IAction.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/IAction.java
similarity index 88%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/IAction.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/IAction.java
index 61c5a04..bc14260 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/IAction.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/action/IAction.java
@@ -1,7 +1,9 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.action;
 
 import javax.xml.stream.Location;
 
+import org.apache.openoffice.ooxml.parser.ElementContext;
+
 /** Interface for actions that are bound to states and triggered by XML events.
  */
 public interface IAction
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeDescriptor.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeDescriptor.java
similarity index 81%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeDescriptor.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeDescriptor.java
index a79832a..3fc9cc3 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeDescriptor.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeDescriptor.java
@@ -1,4 +1,4 @@
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.attribute;
 
 /** Store information about a single attribute (per state) that was read
  *  from the parse table.
@@ -16,7 +16,7 @@ public class AttributeDescriptor
         final boolean bIsOptional,
         final String sDefaultValue,
         final String sAttributeName,
-        final String sAttributeType)
+        final int nAttributeTypeId)
     {
         mnNamespaceId = nPrefixId;
         mnAttributeId = nAttributeId;
@@ -24,18 +24,15 @@ public class AttributeDescriptor
         mbIsOptional = bIsOptional;
         msDefaultValue = sDefaultValue;
         msAttributeName = sAttributeName;
-        msAttributeType = sAttributeType;
+        mnAttributeTypeId = nAttributeTypeId;
     }
 
 
 
 
-    public String GetType()
+    public int GetTypeId()
     {
-        if (msAttributeType != null)
-            return msAttributeType;
-        else
-            return "<undefined>";
+        return mnAttributeTypeId;
     }
 
 
@@ -93,10 +90,10 @@ public class AttributeDescriptor
     public String toString ()
     {
         return String.format(
-            "attribute %s(%d) of type %s",
+            "attribute %s(%d) of type %d",
             msAttributeName,
             mnAttributeId,
-            msAttributeType);
+            mnAttributeTypeId);
     }
 
 
@@ -108,5 +105,5 @@ public class AttributeDescriptor
     private final boolean mbIsOptional;
     private final String msDefaultValue;
     private final String msAttributeName;
-    private final String msAttributeType;
+    private final int mnAttributeTypeId;
 }
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeManager.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeManager.java
similarity index 74%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeManager.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeManager.java
index 877ad2b..82a4052 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeManager.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeManager.java
@@ -19,7 +19,7 @@
 *
 *************************************************************/
 
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.attribute;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -27,6 +27,11 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
 
+import org.apache.openoffice.ooxml.parser.Log;
+import org.apache.openoffice.ooxml.parser.NameMap;
+import org.apache.openoffice.ooxml.parser.NamespaceMap;
+import org.apache.openoffice.ooxml.parser.type.SimpleTypeManager;
+
 
 /** Match a set of attributes from the document with the attribute
  *  specifications of a state.
@@ -40,22 +45,36 @@ public class AttributeManager
     public AttributeManager (
         final Vector<String[]> aData,
         final NamespaceMap aNamespaceMap,
-        final NameMap aNameMap)
+        final NameMap aNameMap,
+        final NameMap aStateNameMap,
+        final SimpleTypeManager aSimpleTypeManager)
     {
         maStateIdToAttributesMap = new HashMap<>();
         maNamespaceMap = aNamespaceMap;
         maNameMap = aNameMap;
+        maStateNameMap = aStateNameMap;
+        maSimpleTypeManager = aSimpleTypeManager;
+
+        ParseData(aData);
+    }
+
+
+
 
+    private void ParseData (final Vector<String[]> aData)
+    {
         for (final String[] aLine : aData)
         {
             final int nStateId = Integer.parseInt(aLine[1]);
             final int nPrefixId = Integer.parseInt(aLine[2]);
             final boolean bCanBeUnqualified = aLine[3].startsWith("u");
             final int nAttributeId = Integer.parseInt(aLine[4]);
-            final String sAttributeType = aLine[5];
+            final int nAttributeTypeId = aLine[5].equals("null") ? -1 : Integer.parseInt(aLine[5]);
             final boolean bIsOptional = aLine[6].startsWith("o");
-            final String sDefault = UnquoteString(aLine[7]);
-            final String sAttributeName = aLine[8];
+            final String sDefault = aLine[7];
+            // State name.
+            final String sAttributeName = aLine[9];
+            // Attribute type name.
 
             Map<Integer,AttributeDescriptor> aAttributesPerState = maStateIdToAttributesMap.get(nStateId);
             if (aAttributesPerState == null)
@@ -71,7 +90,7 @@ public class AttributeManager
                 bIsOptional,
                 sDefault,
                 sAttributeName,
-                sAttributeType);
+                nAttributeTypeId);
 
             aAttributesPerState.put(
                 (nPrefixId<<16)|nAttributeId,
@@ -116,13 +135,30 @@ public class AttributeManager
             // Process all attributes from the document.
             for (final String[] aEntry : aDocumentAttributes)
             {
+                final String sRawValue = aEntry[2];
                 final AttributeDescriptor aAttributeDescriptor = ProcessAttribute(
                     aEntry[0],
                     aEntry[1],
-                    aEntry[2],
+                    sRawValue,
                     aAttributesPerState);
                 aUsedAttributes.add(aAttributeDescriptor);
-                aValues.AddAttribute(aAttributeDescriptor, aEntry[2]);
+                final Object aProcessedValue = maSimpleTypeManager.PreprocessValue(
+                    sRawValue,
+                    aAttributeDescriptor);
+                if (aProcessedValue == null)
+                {
+                    maSimpleTypeManager.PreprocessValue(
+                        sRawValue,
+                        aAttributeDescriptor);
+                    throw new RuntimeException(
+                        String.format("value '%s' of attribute '%s' is not recognized",
+                            sRawValue,
+                            aAttributeDescriptor.GetName()));
+                }
+                aValues.AddAttribute(
+                    aAttributeDescriptor,
+                    sRawValue,
+                    aProcessedValue);
 
                 if (Log.Dbg != null)
                 {
@@ -131,23 +167,30 @@ public class AttributeManager
                             aEntry[0]==null ? "" : ":"+aEntry[0],
                             aEntry[1]);
                     else
-                        Log.Dbg.printf("attribute %s:%s(%d:%d) has type and value %s\n",
+                        Log.Dbg.printf("attribute %s:%s(%d:%d) has type %s(%d) and value %s('%s')\n",
                             maNamespaceMap.GetDescriptorForId(aAttributeDescriptor.GetNamespaceId()).Prefix,
                             maNameMap.GetNameForId(aAttributeDescriptor.GetNameId()),
                             aAttributeDescriptor.GetNamespaceId(),
                             aAttributeDescriptor.GetNameId(),
-                            aAttributeDescriptor.GetType(),
-                            aEntry[2]);
+                            maStateNameMap.GetNameForId(aAttributeDescriptor.GetTypeId()),
+                            aAttributeDescriptor.GetTypeId(),
+                            aProcessedValue,
+                            sRawValue);
                 }
             }
 
             // Check if all required attributes where given.
             for (final AttributeDescriptor aAttribute : aAttributesPerState.values())
             {
-                if ( ! aAttribute.IsOptional())
+                if ( ! aUsedAttributes.contains(aAttribute))
                 {
-                    if ( ! aUsedAttributes.contains(aAttribute))
+                    if ( ! aAttribute.IsOptional())
                         throw new RuntimeException("attribute '"+aAttribute.GetName()+"' is not present but also not optional");
+                    else
+                    {
+                        // Add an entry that gives access to the default value.
+                        aValues.AddAttribute(aAttribute, null, null);
+                    }
                 }
             }
         }
@@ -217,4 +260,6 @@ public class AttributeManager
     private final Map<Integer,Map<Integer,AttributeDescriptor>> maStateIdToAttributesMap;
     private final NamespaceMap maNamespaceMap;
     private final NameMap maNameMap;
+    private final NameMap maStateNameMap;
+    private final SimpleTypeManager maSimpleTypeManager;
 }
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeProvider.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeProvider.java
similarity index 97%
rename from ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeProvider.java
rename to ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeProvider.java
index fda82f4..132130a 100644
--- a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/AttributeProvider.java
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeProvider.java
@@ -19,7 +19,7 @@
 *
 *************************************************************/
 
-package org.apache.openoffice.ooxml.parser;
+package org.apache.openoffice.ooxml.parser.attribute;
 
 import java.util.Iterator;
 
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeValues.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeValues.java
new file mode 100644
index 0000000..c37641f
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/attribute/AttributeValues.java
@@ -0,0 +1,71 @@
+
+package org.apache.openoffice.ooxml.parser.attribute;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+/** Container of attribute values of an opening tag.
+ */
+public class AttributeValues
+{
+    AttributeValues ()
+    {
+        maRawAttributeValues = new TreeMap<>();
+        maProcessedAttributeValues = new TreeMap<>();
+    }
+
+
+
+
+    public void AddAttribute (
+        final AttributeDescriptor aAttributeDescriptor,
+        final String sRawValue,
+        final Object aProcessedValue)
+    {
+        maRawAttributeValues.put(
+            aAttributeDescriptor.GetName(),
+            sRawValue);
+        maProcessedAttributeValues.put(
+            aAttributeDescriptor.GetName(),
+            aProcessedValue);
+    }
+
+
+
+
+    public Iterable<Entry<String,String>> GetAttributes ()
+    {
+        return maRawAttributeValues.entrySet();
+    }
+
+
+
+
+    public String GetRawAttributeValue (final String sName)
+    {
+        return maRawAttributeValues.get(sName);
+    }
+
+
+
+
+    public Object GetProcessedAttributeValue (final String sName)
+    {
+        return maProcessedAttributeValues.get(sName);
+    }
+
+
+
+
+    public int GetAttributeCount ()
+    {
+        return maRawAttributeValues.size();
+    }
+
+
+
+
+    private Map<String,String> maRawAttributeValues;
+    private Map<String,Object> maProcessedAttributeValues;
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/BlobParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/BlobParser.java
new file mode 100644
index 0000000..9667156
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/BlobParser.java
@@ -0,0 +1,81 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+
+public class BlobParser implements ISimpleTypeParser
+{
+    public BlobParser(final String[] aLine)
+    {
+        switch(aLine[5])
+        {
+            case "B":
+                meType = Type.Base64Binary;
+                break;
+            case "H":
+                meType = Type.HexBinary;
+                break;
+            default:
+                throw new RuntimeException();
+        }
+        switch(aLine[6])
+        {
+            case "L":
+                mnLengthRestriction = Integer.parseInt(aLine[7]);
+                break;
+            case "N":
+                mnLengthRestriction = null;
+                break;
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    @Override
+    public Object Parse (
+        final String sRawValue,
+        final NameMap aAttributeValueMap)
+    {
+        if (mnLengthRestriction != null)
+            if (sRawValue.length()/2 != mnLengthRestriction)
+                return null;
+        /*
+                throw new RuntimeException(
+                    String.format(
+                        "length restriction (=%d) is violated, actual length is %d",
+                        mnLengthRestriction,
+                        sRawValue.length()));
+          */
+        switch(meType)
+        {
+            case Base64Binary:
+                throw new RuntimeException("not yet implemented");
+
+            case HexBinary:
+                try
+                {
+                    return Integer.parseInt(sRawValue, 16);
+                }
+                catch (NumberFormatException aException)
+                {
+                    return null;
+                }
+
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    enum Type
+    {
+        Base64Binary,
+        HexBinary
+    };
+    private final Type meType;
+    private final Integer mnLengthRestriction;
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/DateTimeParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/DateTimeParser.java
new file mode 100644
index 0000000..76d7624
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/DateTimeParser.java
@@ -0,0 +1,21 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+
+public class DateTimeParser implements ISimpleTypeParser
+{
+
+    public DateTimeParser(String[] aLine)
+    {
+        // TODO Auto-generated constructor stub
+    }
+
+    @Override
+    public Object Parse(
+        final String sRawValue,
+        final NameMap aAttributeValueMap)
+    {
+        throw new RuntimeException();
+    }
+
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ISimpleTypeParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ISimpleTypeParser.java
new file mode 100644
index 0000000..9ecd347
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ISimpleTypeParser.java
@@ -0,0 +1,10 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+
+public interface ISimpleTypeParser
+{
+    Object Parse (
+        final String sRawValue,
+        final NameMap aAttributeValueMap);
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ListParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ListParser.java
new file mode 100644
index 0000000..a6764c5
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/ListParser.java
@@ -0,0 +1,32 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+
+public class ListParser implements ISimpleTypeParser
+{
+
+    public ListParser (final ISimpleTypeParser aItemParser)
+    {
+        maItemParser = aItemParser;
+    }
+
+
+
+
+    @Override
+    public Object Parse(
+        final String sRawValue,
+        final NameMap aAttributeValueMap)
+    {
+        final String[] aParts = sRawValue.split("\\s+");
+        final Object[] aValues = new Object[aParts.length];
+        for (int nIndex=0; nIndex<aParts.length; ++nIndex)
+            aValues[nIndex] = maItemParser.Parse(aParts[nIndex], aAttributeValueMap);
+        return aValues;
+    }
+
+
+
+
+    private final ISimpleTypeParser maItemParser;
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/NumberParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/NumberParser.java
new file mode 100644
index 0000000..b951d6f
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/NumberParser.java
@@ -0,0 +1,250 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+import org.apache.openoffice.ooxml.parser.type.StringParser.RestrictionType;
+
+public class NumberParser implements ISimpleTypeParser
+{
+    public NumberParser (final String[] aLine)
+    {
+        switch(aLine[5])
+        {
+            case "u1":
+                meNumberType = NumberType.Boolean;
+                meJavaNumberType = JavaNumberType.Boolean;
+                break;
+            case "s8":
+                meNumberType = NumberType.Byte;
+                meJavaNumberType = JavaNumberType.Byte;
+                break;
+            case "u8":
+                meNumberType = NumberType.UnsignedByte;
+                meJavaNumberType = JavaNumberType.Short;
+                break;
+            case "s16":
+                meNumberType = NumberType.Short;
+                meJavaNumberType = JavaNumberType.Short;
+                break;
+            case "u16":
+                meNumberType = NumberType.UnsignedShort;
+                meJavaNumberType = JavaNumberType.Integer;
+                break;
+            case "s32":
+                meNumberType = NumberType.Int;
+                meJavaNumberType = JavaNumberType.Integer;
+                break;
+            case "u32":
+                meNumberType = NumberType.UnsignedInt;
+                meJavaNumberType = JavaNumberType.Long;
+                break;
+            case "s64":
+                meNumberType = NumberType.Long;
+                meJavaNumberType = JavaNumberType.Long;
+                break;
+            case "u64":
+                meNumberType = NumberType.UnsignedLong;
+                meJavaNumberType = JavaNumberType.Long;
+                break;
+            case "s*":
+                meNumberType = NumberType.Integer;
+                meJavaNumberType = JavaNumberType.Long;
+                break;
+            case "f":
+                meNumberType = NumberType.Float;
+                meJavaNumberType = JavaNumberType.Float;
+                break;
+            case "d":
+                meNumberType = NumberType.Double;
+                meJavaNumberType = JavaNumberType.Double;
+                break;
+            default:
+                throw new RuntimeException("unsupported numerical type "+aLine[5]);
+        }
+
+        switch(aLine[6])
+        {
+            case "E":
+                meRestrictionType = RestrictionType.Enumeration;
+                maEnumeration = new HashSet<>();
+                for (int nIndex=7; nIndex<aLine.length; ++nIndex)
+                    maEnumeration.add(ParseNumber(aLine[nIndex]));
+                break;
+
+            case "S":
+                meRestrictionType = RestrictionType.Size;
+                for (int nIndex=7; nIndex<=9; nIndex+=2)
+                    if (nIndex<aLine.length)
+                        switch (aLine[nIndex])
+                        {
+                            case "<=":
+                                maMaximumValue = ParseNumber(aLine[nIndex+1]);
+                                mbIsMaximumInclusive = true;
+                                break;
+                            case "<":
+                                maMaximumValue = ParseNumber(aLine[nIndex+1]);
+                                mbIsMaximumInclusive = false;
+                                break;
+                            case ">=":
+                                maMinimumValue = ParseNumber(aLine[nIndex+1]);
+                                mbIsMinimumInclusive = true;
+                                break;
+                            case ">":
+                                maMinimumValue = ParseNumber(aLine[nIndex+1]);
+                                mbIsMinimumInclusive = false;
+                                break;
+                        }
+                break;
+
+            case "N":
+                meRestrictionType = RestrictionType.None;
+                break;
+
+            default:
+                throw new RuntimeException("unsupported numerical restriction "+aLine[6]);
+        }
+    }
+
+
+
+
+    @Override
+    public Object Parse(
+        final String sRawValue,
+        final NameMap aAttributeValueMap)
+    {
+        final Object aNumber = ParseNumber(sRawValue);
+        switch(meRestrictionType)
+        {
+            case Enumeration:
+                if (maEnumeration.contains(aNumber))
+                    return aNumber;
+                else
+                    return null;
+
+            case Size:
+                if (maMinimumValue != null)
+                    if (mbIsMinimumInclusive)
+                    {
+                        if (CompareTo(aNumber, maMinimumValue, meJavaNumberType) < 0)
+                            return null;
+                    }
+                    else
+                    {
+                        if (CompareTo(aNumber, maMinimumValue, meJavaNumberType) <= 0)
+                            return null;
+                    }
+                if (maMaximumValue != null)
+                    if (mbIsMaximumInclusive)
+                    {
+                        if (CompareTo(aNumber, maMaximumValue, meJavaNumberType) > 0)
+                            return null;
+                    }
+                    else
+                    {
+                        if (CompareTo(aNumber, maMaximumValue, meJavaNumberType) >= 0)
+                            return null;
+                    }
+                return aNumber;
+
+            case None:
+                return aNumber;
+
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    Object ParseNumber (final String sNumber)
+    {
+        switch(meJavaNumberType)
+        {
+            case Boolean: return Boolean.parseBoolean(sNumber);
+            case Byte: return Byte.parseByte(sNumber);
+            case Short: return Short.parseShort(sNumber);
+            case Integer: return Integer.parseInt(sNumber);
+            case Long: return Long.parseLong(sNumber);
+            case Float: return Float.parseFloat(sNumber);
+            case Double: return Double.parseDouble(sNumber);
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    private static int CompareTo (
+        final Object aLeft,
+        final Object aRight,
+        final JavaNumberType eType)
+    {
+        switch(eType)
+        {
+            case Boolean:
+                return ((Boolean)aLeft).compareTo((Boolean)aRight);
+            case Byte:
+                return ((Byte)aLeft).compareTo((Byte)aRight);
+            case Short:
+                return ((Short)aLeft).compareTo((Short)aRight);
+            case Integer:
+                return ((Integer)aLeft).compareTo((Integer)aRight);
+            case Long:
+                return ((Long)aLeft).compareTo((Long)aRight);
+            case Float:
+                return ((Float)aLeft).compareTo((Float)aRight);
+            case Double:
+                return ((Double)aLeft).compareTo((Double)aRight);
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    enum NumberType
+    {
+        Boolean,
+        Byte,
+        UnsignedByte,
+        Short,
+        UnsignedShort,
+        Int,
+        UnsignedInt,
+        Long,
+        UnsignedLong,
+        Integer,
+        Float,
+        Double
+    }
+    enum JavaNumberType
+    {
+        Boolean,
+        Byte,
+        Short,
+        Integer,
+        Long,
+        Float,
+        Double
+    }
+    enum RestrictionType
+    {
+        Enumeration,
+        Size,
+        None
+    }
+    private final NumberType meNumberType;
+    private final JavaNumberType meJavaNumberType;
+    private final RestrictionType meRestrictionType;
+    private Set<Object> maEnumeration;
+    private Object maMinimumValue;
+    private boolean mbIsMinimumInclusive;
+    private Object maMaximumValue;
+    private boolean mbIsMaximumInclusive;
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/SimpleTypeManager.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/SimpleTypeManager.java
new file mode 100644
index 0000000..cca933c
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/SimpleTypeManager.java
@@ -0,0 +1,90 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+import org.apache.openoffice.ooxml.parser.attribute.AttributeDescriptor;
+
+public class SimpleTypeManager
+{
+    public SimpleTypeManager(
+        final Vector<String[]> aData,
+        final NameMap aAttributeValueMap)
+    {
+        maAttributeValueMap = aAttributeValueMap;
+        maSimpleTypeToParsersMap = new HashMap<>();
+        ParseData(aData);
+    }
+
+
+
+
+    private void ParseData (final Vector<String[]> aData)
+    {
+        for (final String[] aLine : aData)
+        {
+            final int nSimpleTypeId = Integer.parseInt(aLine[1]);
+//            final int nVariant = Integer.parseInt(aLine[2]);
+            final boolean bIsList = aLine[3].equals("L");
+            final ISimpleTypeParser aVariantParser;
+            switch (aLine[4])
+            {
+                case "S":
+                    aVariantParser = new StringParser(aLine);
+                    break;
+                case "N":
+                    aVariantParser = new NumberParser(aLine);
+                    break;
+                case "D":
+                    aVariantParser = new DateTimeParser(aLine);
+                    break;
+                case "B":
+                    aVariantParser = new BlobParser(aLine);
+                    break;
+                default:
+                    throw new RuntimeException("unexpected parser type: "+aLine[4]);
+            }
+
+            Vector<ISimpleTypeParser> aVariants = maSimpleTypeToParsersMap.get(nSimpleTypeId);
+            if (aVariants == null)
+            {
+                aVariants = new Vector<>();
+                maSimpleTypeToParsersMap.put(nSimpleTypeId, aVariants);
+            }
+            if (bIsList)
+                aVariants.add(new ListParser(aVariantParser));
+            else
+                aVariants.add(aVariantParser);
+        }
+    }
+
+
+
+
+    public Object PreprocessValue (
+        final String sRawValue,
+        final AttributeDescriptor aAttributeDescriptor)
+    {
+        final Vector<ISimpleTypeParser> aTypeParsers = maSimpleTypeToParsersMap.get(aAttributeDescriptor.GetTypeId());
+        if (aTypeParsers == null)
+            throw new RuntimeException("type "+aAttributeDescriptor.GetTypeId()+" is not supported");
+
+        for (final ISimpleTypeParser aParser : aTypeParsers)
+        {
+            final Object aProcessedValue = aParser.Parse(
+                sRawValue,
+                maAttributeValueMap);
+            if (aProcessedValue != null)
+                return aProcessedValue;
+        }
+        return null;
+    }
+
+
+
+
+    private final NameMap maAttributeValueMap;
+    private Map<Integer,Vector<ISimpleTypeParser>> maSimpleTypeToParsersMap;
+}
diff --git a/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/StringParser.java b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/StringParser.java
new file mode 100644
index 0000000..192c3a5
--- /dev/null
+++ b/ooxml/source/framework/JavaOOXMLParser/src/org/apache/openoffice/ooxml/parser/type/StringParser.java
@@ -0,0 +1,101 @@
+package org.apache.openoffice.ooxml.parser.type;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.openoffice.ooxml.parser.NameMap;
+
+public class StringParser
+    implements ISimpleTypeParser
+{
+
+    public StringParser (final String[] aLine)
+    {
+        switch(aLine[5])
+        {
+            case "E":
+                meRestrictionType = RestrictionType.Enumeration;
+                maEnumeration = new HashSet<>();
+                for (int nIndex=6; nIndex<aLine.length; ++nIndex)
+                    maEnumeration.add(Integer.parseInt(aLine[nIndex]));
+                break;
+
+            case "P":
+                meRestrictionType = RestrictionType.Pattern;
+                maPattern = Pattern.compile(aLine[6].replace("\\p{Is", "\\p{In"));
+                break;
+
+            case "L":
+                meRestrictionType = RestrictionType.Length;
+                mnMinimumLength = Integer.parseInt(aLine[6]);
+                mnMaximumLength = Integer.parseInt(aLine[7]);
+                break;
+
+            case "N":
+                meRestrictionType = RestrictionType.None;
+                break;
+
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    @Override
+    public Object Parse (
+        final String sRawValue,
+        final NameMap aAttributeValueMap)
+    {
+        switch(meRestrictionType)
+        {
+            case Enumeration:
+                final int nId = aAttributeValueMap.GetIdForOptionalName(sRawValue);
+                if ( ! maEnumeration.contains(nId))
+                    return null;//throw new RuntimeException("value is not part of enumeration");
+                else
+                    return nId;
+
+            case Pattern:
+                if ( ! maPattern.matcher(sRawValue).matches())
+                    return null;//throw new RuntimeException("value does not match pattern");
+                else
+                    return sRawValue;
+
+            case Length:
+                if (sRawValue.length()<mnMinimumLength || sRawValue.length()>mnMaximumLength)
+                    return null;/*throw new RuntimeException(
+                        String.format("value violates string length restriction: %s is not inside [%d,%d]",
+                            sRawValue.length(),
+                            mnMinimumLength,
+                            mnMaximumLength));
+                            */
+                else
+                    return sRawValue;
+
+            case None:
+                return sRawValue;
+
+            default:
+                throw new RuntimeException();
+        }
+    }
+
+
+
+
+    enum RestrictionType
+    {
+        Enumeration,
+        Pattern,
+        Length,
+        None
+    }
+    private final RestrictionType meRestrictionType;
+    private Set<Integer> maEnumeration;
+    private Pattern maPattern;
+    private int mnMinimumLength;
+    private int mnMaximumLength;
+}
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/SchemaReader.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/SchemaReader.java
index a1f5d3f..f4054a0 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/SchemaReader.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/SchemaReader.java
@@ -40,10 +40,10 @@ import org.apache.openoffice.ooxml.schema.automaton.NonValidatingCreator;
 import org.apache.openoffice.ooxml.schema.automaton.ValidatingCreator;
 import org.apache.openoffice.ooxml.schema.generator.LogGenerator;
 import org.apache.openoffice.ooxml.schema.generator.ParserTablesGenerator;
-import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
 import org.apache.openoffice.ooxml.schema.model.schema.Schema;
 import org.apache.openoffice.ooxml.schema.model.schema.SchemaBase;
 import org.apache.openoffice.ooxml.schema.parser.SchemaParser;
+import org.apache.openoffice.ooxml.schema.simple.SimpleTypeContainer;
 
 public class SchemaReader
 {
@@ -151,10 +151,15 @@ public class SchemaReader
                         maOutputOperations.add(new Runnable()
                         {
                             final File maAutomatonLogFile = CreateCheckedOutputFile(aParts.get(1));
-                            final File maParseTableFile = CreateCheckedOutputFile(aParts.get(2));
-                            @Override public void run() {WriteNonValidatingParseTables(
-                                maAutomatonLogFile,
-                                maParseTableFile);}
+                            final File maSimpleTypeLogFile = CreateCheckedOutputFile(aParts.get(2));
+                            final File maParseTableFile = CreateCheckedOutputFile(aParts.get(3));
+                            @Override public void run()
+                            {
+                                WriteNonValidatingParseTables(
+                                    maAutomatonLogFile,
+                                    maSimpleTypeLogFile,
+                                    maParseTableFile);
+                            }
                         });
                         break;
 
@@ -162,10 +167,15 @@ public class SchemaReader
                         maOutputOperations.add(new Runnable()
                         {
                             final File maAutomatonLogFile = CreateCheckedOutputFile(aParts.get(1));
-                            final File maParseTableFile = CreateCheckedOutputFile(aParts.get(2));
-                            @Override public void run() {WriteValidatingParseTables(
-                                maAutomatonLogFile,
-                                maParseTableFile);}
+                            final File maSimpleTypeLogFile = CreateCheckedOutputFile(aParts.get(2));
+                            final File maParseTableFile = CreateCheckedOutputFile(aParts.get(3));
+                            @Override public void run()
+                            {
+                                WriteValidatingParseTables(
+                                    maAutomatonLogFile,
+                                    maSimpleTypeLogFile,
+                                    maParseTableFile);
+                            }
                         });
                         break;
 
@@ -368,6 +378,7 @@ public class SchemaReader
 
     private void WriteNonValidatingParseTables (
         final File aAutomatonLogFile,
+        final File aSimpleTypeLogFile,
         final File aParseTableFile)
     {
         long nStartTime = System.currentTimeMillis();
@@ -381,7 +392,21 @@ public class SchemaReader
             aAutomatons.GetTransitionCount(),
             (nEndTime-nStartTime)/1000.0);
 
-        new ParserTablesGenerator(aAutomatons, maOptimizedSchemaBase.Namespaces)
+        nStartTime = System.currentTimeMillis();
+        final SimpleTypeContainer aSimpleTypes = SimpleTypeContainer.Create(
+            maOptimizedSchemaBase,
+            aSimpleTypeLogFile);
+        nEndTime = System.currentTimeMillis();
+        System.out.printf(
+            "created %d simple type descriptions in %fs\n",
+            aSimpleTypes.GetSimpleTypeCount(),
+            (nEndTime-nStartTime)/1000.0);
+
+        new ParserTablesGenerator(
+            aAutomatons,
+            maOptimizedSchemaBase.Namespaces,
+            aSimpleTypes,
+            maOptimizedSchemaBase.AttributeValueToIdMap)
             .Generate(aParseTableFile);
     }
 
@@ -390,6 +415,7 @@ public class SchemaReader
 
     private void WriteValidatingParseTables (
         final File aAutomatonLogFile,
+        final File aSimpleTypeLogFile,
         final File aParseTableFile)
     {
         long nStartTime = System.currentTimeMillis();
@@ -423,7 +449,21 @@ public class SchemaReader
             aAutomatons.GetStateCount(),
             aAutomatons.GetTransitionCount());
 
-        new ParserTablesGenerator(aAutomatons, maOptimizedSchemaBase.Namespaces)
+        nStartTime = System.currentTimeMillis();
+        final SimpleTypeContainer aSimpleTypes = SimpleTypeContainer.Create(
+            maOptimizedSchemaBase,
+            aSimpleTypeLogFile);
+        nEndTime = System.currentTimeMillis();
+        System.out.printf(
+            "created %d simple type descriptions in %fs\n",
+            aSimpleTypes.GetSimpleTypeCount(),
+            (nEndTime-nStartTime)/1000.0);
+
+        new ParserTablesGenerator(
+            aAutomatons,
+            maOptimizedSchemaBase.Namespaces,
+            aSimpleTypes,
+            maOptimizedSchemaBase.AttributeValueToIdMap)
             .Generate(aParseTableFile);
     }
 
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/Test.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/Test.java
index ea2565f..58ca325 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/Test.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/Test.java
@@ -54,6 +54,7 @@ public class Test
             new StateContainer(),
             aStates,
             null,
+            null,
             System.out);
     }
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/CreatorBase.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/CreatorBase.java
index 239dba196..c9e6779 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/CreatorBase.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/CreatorBase.java
@@ -1,13 +1,13 @@
 package org.apache.openoffice.ooxml.schema.automaton;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.Vector;
 
 import org.apache.openoffice.ooxml.schema.iterator.AttributeIterator;
 import org.apache.openoffice.ooxml.schema.iterator.DereferencingNodeIterator;
+import org.apache.openoffice.ooxml.schema.misc.Log;
 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
 import org.apache.openoffice.ooxml.schema.model.base.INode;
 import org.apache.openoffice.ooxml.schema.model.schema.SchemaBase;
@@ -22,18 +22,30 @@ public class CreatorBase
     {
         maSchemaBase = aSchemaBase;
         maStateContainer = new StateContainer();
-
-        PrintStream aLog = null;
-        try
-        {
-            aLog = new PrintStream(new FileOutputStream(aLogFile));
-        }
-        catch (FileNotFoundException e)
-        {
-            e.printStackTrace();
-        }
-        maLog = aLog;
+        maLog = new Log(aLogFile);
         msLogIndentation = "";
+        maElementSimpleTypes = new HashSet<>();
+    }
+
+
+
+
+    /** Create a very simple automaton:
+     *  a) Its start state is also the accepting state.
+     *  b) It does not allow any transitions.
+     *  c) Its text items have the given simple type.
+     */
+    protected FiniteAutomaton CreateForSimpleType (final INode aSimpleType)
+    {
+        final StateContext aStateContext = new StateContext(
+            maStateContainer,
+            aSimpleType.GetName().GetStateName());
+        aStateContext.GetStartState().SetIsAccepting();
+        aStateContext.GetStartState().SetTextType(aSimpleType);
+        return new FiniteAutomaton(
+            aStateContext,
+            new Vector<Attribute>(),
+            aSimpleType.GetLocation());
     }
 
 
@@ -82,43 +94,10 @@ public class CreatorBase
 
 
 
-    protected void AddComment (
-        final String sFormat,
-        final Object ... aArgumentList)
-    {
-        if (maLog != null)
-        {
-            maLog.print(msLogIndentation);
-            maLog.print("// ");
-            maLog.printf(sFormat, aArgumentList);
-            maLog.print("\n");
-        }
-    }
-
-
-
-
-    protected void StartBlock ()
-    {
-        if (maLog != null)
-            msLogIndentation += "    ";
-    }
-
-
-
-
-    protected void EndBlock ()
-    {
-        if (maLog != null)
-            msLogIndentation = msLogIndentation.substring(4);
-    }
-
-
-
-
     protected final SchemaBase maSchemaBase;
     protected final StateContainer maStateContainer;
-    protected final PrintStream maLog;
+    protected final Log maLog;
     protected String msLogIndentation;
     protected Vector<Attribute> maAttributes;
+    protected final Set<INode> maElementSimpleTypes;
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/DFACreator.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/DFACreator.java
index 64b2bcc..6f1334a 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/DFACreator.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/DFACreator.java
@@ -13,6 +13,7 @@ import java.util.TreeSet;
 import java.util.Vector;
 
 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 
 /** Convert an NFA into a DFA via the powerset construction (also called subset
@@ -27,13 +28,15 @@ public class DFACreator
         final StateContainer aDFAStateContainer,
         final StateContext aNFAStateContext,
         final Vector<Attribute> aAttributes,
-        final QualifiedName aTypeName)
+        final QualifiedName aTypeName,
+        final Location aLocation)
     {
         final DFACreator aCreator = new DFACreator(aDFAStateContainer, aNFAStateContext, aTypeName);
         aCreator.CreateDFAforNFA();
         return new FiniteAutomaton(
             aCreator.maDFAStateContext,
-            aAttributes);
+            aAttributes,
+            aLocation);
     }
 
 
@@ -241,13 +244,7 @@ public class DFACreator
         final State aDFAState)
     {
         for (final State aNFAState : aNFAStateSet.GetStates())
-        {
-            if (aNFAState.IsAccepting())
-                aDFAState.SetIsAccepting();
-
-            for (final SkipData aSkipData : aNFAState.GetSkipData())
-                aDFAState.AddSkipData(aSkipData.Clone(aDFAState));
-        }
+            aDFAState.CopyFrom(aNFAState);
     }
 
 
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomaton.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomaton.java
index 8c4cf6e..16bf2f7 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomaton.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomaton.java
@@ -24,6 +24,7 @@ package org.apache.openoffice.ooxml.schema.automaton;
 import java.util.Vector;
 
 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 
 
@@ -39,12 +40,14 @@ public class FiniteAutomaton
 {
     FiniteAutomaton (
         final StateContext aContext,
-        final Vector<Attribute> aAttributes)
+        final Vector<Attribute> aAttributes,
+        final Location aLocation)
     {
         maStateContext = aContext;
         maAttributes = aAttributes!=null
             ? aAttributes
             : new Vector<Attribute>();
+        maLocation = aLocation;
     }
 
 
@@ -98,7 +101,8 @@ public class FiniteAutomaton
             aDFAContainer,
             maStateContext,
             maAttributes,
-            aTypeName);
+            aTypeName,
+            maLocation);
     }
 
 
@@ -143,6 +147,14 @@ public class FiniteAutomaton
 
 
 
+    public Location GetLocation ()
+    {
+        return maLocation;
+    }
+
+
+
+
     public Vector<Attribute> GetAttributes ()
     {
         return maAttributes;
@@ -153,4 +165,5 @@ public class FiniteAutomaton
 
     private final StateContext maStateContext;
     private final Vector<Attribute> maAttributes;
+    private final Location maLocation;
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomatonContainer.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomatonContainer.java
index fbd8407..691dcaa 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomatonContainer.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/FiniteAutomatonContainer.java
@@ -124,6 +124,7 @@ public class FiniteAutomatonContainer
                     aNewStateContainer,
                     aEntry.getValue().GetStateContext(),
                     aEntry.getValue().GetAttributes(),
+                    aEntry.getValue().GetLocation(),
                     aLog));
         }
         return aDFAs;
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/HopcroftMinimizer.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/HopcroftMinimizer.java
index 195af7a..d752f21 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/HopcroftMinimizer.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/HopcroftMinimizer.java
@@ -12,6 +12,7 @@ import java.util.TreeSet;
 import java.util.Vector;
 
 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 
 /** Minimize an DFA with respect to its number of states.
@@ -27,6 +28,7 @@ public class HopcroftMinimizer
         final StateContainer aNewStateContainer,
         final StateContext aOriginalStates,
         final Vector<Attribute> aAttributes,
+        final Location aLocation,
         final PrintStream aLog)
     {
         if (aLog != null)
@@ -99,7 +101,8 @@ public class HopcroftMinimizer
         // Create and return the new minimized automaton.
         return new FiniteAutomaton(
             aMinimizedStates,
-            aAttributes);
+            aAttributes,
+            aLocation);
     }
 
 
@@ -318,10 +321,7 @@ public class HopcroftMinimizer
         for (final State aOldState : aOriginalStates.GetStates())
         {
             final State aNewState = aOldStateToNewStateMap.get(aOldState);
-            if (aOldState.IsAccepting())
-                aNewState.SetIsAccepting();
-            for (final SkipData aSkipData : aOldState.GetSkipData())
-                aNewState.AddSkipData(aSkipData.Clone(aNewState));
+            aNewState.CopyFrom(aOldState);
         }
         return aMinimizedStates;
     }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/NonValidatingCreator.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/NonValidatingCreator.java
index 2801c51..f96e323 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/NonValidatingCreator.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/NonValidatingCreator.java
@@ -56,27 +56,36 @@ public class NonValidatingCreator
     {
         final FiniteAutomatonContainer aAutomatons = new FiniteAutomatonContainer(maStateContainer);
 
+        // Create a single automaton for all top level elements.
         aAutomatons.AddAutomaton(
             null,
             CreateForTopLevelElements(aTopLevelSchemas));
 
+        // Create one automaton for each complex type.
         for (final ComplexType aComplexType : maSchemaBase.ComplexTypes.GetSorted())
             aAutomatons.AddAutomaton(
                 aComplexType.GetName(),
                 CreateForComplexType(aComplexType));
 
-        maLog.close();
+        // Create one automaton for each simple type that is referenced by an element.
+        for (final INode aSimpleType : maElementSimpleTypes)
+            aAutomatons.AddAutomaton(
+                aSimpleType.GetName(),
+                CreateForSimpleType(aSimpleType));
+
+        maLog.Close();
 
         return aAutomatons;
     }
 
 
 
+
     private FiniteAutomaton CreateForTopLevelElements (
         final Iterable<Schema> aTopLevelSchemas)
     {
-        AddComment("top level elements");
-        StartBlock();
+        maLog.AddComment("top level elements");
+        maLog.StartBlock();
         final String sTypeName = "<top-level>";
         final StateContext aStateContext = new StateContext(
             maStateContainer,
@@ -87,11 +96,11 @@ public class NonValidatingCreator
         // top level elements
         for (final Schema aSchema : aTopLevelSchemas)
         {
-            AddComment("schema %s", aSchema.GetShortName());
-            StartBlock();
+            maLog.AddComment("schema %s", aSchema.GetShortName());
+            maLog.StartBlock();
             for (final Element aElement : aSchema.TopLevelElements.GetSorted())
             {
-                AddComment("Element: on '%s' go from %s to %s via %s",
+                maLog.AddComment("Element: on '%s' go from %s to %s via %s",
                     aElement.GetElementName().GetDisplayName(),
                     aStartState.GetFullname(),
                     aEndState.GetFullname(),
@@ -104,11 +113,11 @@ public class NonValidatingCreator
                         aElement.GetElementName(),
                         aElement.GetTypeName().GetStateName()));
             }
-            EndBlock();
+            maLog.EndBlock();
         }
-        EndBlock();
+        maLog.EndBlock();
 
-        return new FiniteAutomaton(aStateContext, null);
+        return new FiniteAutomaton(aStateContext, null, null);
     }
 
 
@@ -117,10 +126,10 @@ public class NonValidatingCreator
     private FiniteAutomaton CreateForComplexType (final ComplexType aComplexType)
     {
         maLog.printf("\n");
-        AddComment ("Complex Type %s defined in %s.",
+        maLog.AddComment ("Complex Type %s defined in %s.",
             aComplexType.GetName().GetDisplayName(),
             aComplexType.GetLocation());
-        StartBlock();
+        maLog.StartBlock();
 
         final StateContext aStateContext = new StateContext(
             maStateContainer,
@@ -128,7 +137,7 @@ public class NonValidatingCreator
 
         for (final Element aElement : CollectElements(aComplexType))
         {
-            AddComment("Element: on '%s' go from %s to %s via %s",
+            maLog.AddComment("Element: on '%s' go from %s to %s via %s",
                 aElement.GetElementName().GetDisplayName(),
                 aStateContext.GetStartState().GetFullname(),
                 aStateContext.GetStartState().GetFullname(),
@@ -140,6 +149,13 @@ public class NonValidatingCreator
                     aStateContext.GetStartState(),
                     aElement.GetElementName(),
                     aElement.GetTypeName().GetStateName()));
+
+            // For elements whose type is a simple type we have to remember that
+            // simple type for later (and then create an NFA for it.)
+            final INode aSimpleType = maSchemaBase.GetSimpleTypeForName(
+                aElement.GetTypeName());
+            if (aSimpleType != null)
+                maElementSimpleTypes.add(aSimpleType);
         }
 
         for (final Any aAny : CollectAnys(aComplexType))
@@ -158,9 +174,9 @@ public class NonValidatingCreator
 
         aStateContext.GetStartState().SetIsAccepting();
 
-        EndBlock();
+        maLog.EndBlock();
 
-        return new FiniteAutomaton(aStateContext, maAttributes);
+        return new FiniteAutomaton(aStateContext, maAttributes, aComplexType.GetLocation());
     }
 
 
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/State.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/State.java
index d5f297e..7d9982c 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/State.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/State.java
@@ -23,6 +23,7 @@ package org.apache.openoffice.ooxml.schema.automaton;
 
 import java.util.Vector;
 
+import org.apache.openoffice.ooxml.schema.model.base.INode;
 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 
 /** Each complex type is represented by a State object (primary state).
@@ -49,6 +50,7 @@ public class State
         maEpsilonTransitions = new Vector<>();
         maSkipData = new Vector<>();
         mbIsAccepting = false;
+        maTextType = null;
     }
 
 
@@ -82,6 +84,7 @@ public class State
 
 
 
+
     public QualifiedName GetBasename ()
     {
         return maBasename;
@@ -90,6 +93,22 @@ public class State
 
 
 
+    /** Return a qualified name that contains the suffix.
+     *  This is typically only used for sorting type names.
+     */
+    public QualifiedName GetQualifiedName ()
+    {
+        return new QualifiedName(
+            maBasename.GetNamespacePrefix(),
+            maBasename.GetNamespaceURI(),
+            msSuffix != null
+                ? maBasename.GetLocalPart() + "_" + msSuffix
+                : maBasename.GetLocalPart());
+    }
+
+
+
+
     public String GetSuffix ()
     {
         return msSuffix;
@@ -195,6 +214,35 @@ public class State
 
 
 
+    public void SetTextType (final INode aTextType)
+    {
+        assert(maTextType==null);
+        maTextType = aTextType;
+    }
+
+
+
+
+    public INode GetTextType ()
+    {
+        return maTextType;
+    }
+
+
+
+
+    public void CopyFrom (final State aOther)
+    {
+        if (aOther.IsAccepting())
+            SetIsAccepting();
+        for (final SkipData aSkipData : aOther.GetSkipData())
+            AddSkipData(aSkipData.Clone(this));
+        SetTextType(aOther.GetTextType());
+    }
+
+
+
+
     @Override
     public String toString ()
     {
@@ -211,4 +259,5 @@ public class State
     private final Vector<EpsilonTransition> maEpsilonTransitions;
     private final Vector<SkipData> maSkipData;
     private boolean mbIsAccepting;
+    private INode maTextType;
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateContext.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateContext.java
index ba33d09..f2d877f 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateContext.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateContext.java
@@ -21,7 +21,9 @@
 
 package org.apache.openoffice.ooxml.schema.automaton;
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.Vector;
@@ -44,6 +46,7 @@ public class StateContext
         maStateContainer = aStateContainer;
         maStates = new HashSet<>();
         maStartState = GetOrCreateState(new QualifiedName(null, null, sBaseStateName), null);
+        maDisambiguateCounters = new HashMap<>();
     }
 
 
@@ -133,6 +136,31 @@ public class StateContext
 
 
 
+    /** Some algorithms can not easily produce unique suffixes.
+     *  Append an integer to the given suffix so that it becomes unique.
+     */
+    public String GetUnambiguousSuffix (final QualifiedName aBasename, final String sSuffix)
+    {
+        String sStateName = State.GetStateName(aBasename, sSuffix);
+        if ( ! HasState(sStateName))
+        {
+            // The given suffix can be used without modification.
+            return sSuffix;
+        }
+        else
+        {
+            int nIndex = 2;
+            final Integer nDisambiguateCounter = maDisambiguateCounters.get(sStateName);
+            if (nDisambiguateCounter != null)
+                nIndex = nDisambiguateCounter+1;
+            maDisambiguateCounters.put(sStateName, nIndex);
+
+            return sSuffix + "_" + nIndex;
+        }
+    }
+
+
+
 
     public boolean HasState (
         final QualifiedName aBasename,
@@ -237,4 +265,5 @@ public class StateContext
     private final StateContainer maStateContainer;
     private final Set<State> maStates;
     private final State maStartState;
+    private final Map<String,Integer> maDisambiguateCounters;
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateSet.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateSet.java
index d094027..1f20d16 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateSet.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/StateSet.java
@@ -4,6 +4,7 @@ import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.apache.openoffice.ooxml.schema.model.base.INode;
 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 
 /** Used in the transformation of NFA to DFA and in the minimization of DFAs.
@@ -149,26 +150,26 @@ public class StateSet
             throw new RuntimeException("can not create state for "+toString());
 
         // Disambiguate new state name.
-        State aNewState = null;
-        for (int nIndex=1; true; ++nIndex)
-        {
-            final String sSuffix = nIndex==1 ? sShortestSuffix : sShortestSuffix+"_"+nIndex;
-            if ( ! aContext.HasState(aBaseName, sSuffix))
-            {
-                aNewState = aContext.CreateState(aBaseName, sSuffix);
-                break;
-            }
-        }
+        State aNewState = aContext.CreateState(
+            aBaseName,
+            aContext.GetUnambiguousSuffix(aBaseName, sShortestSuffix));
         assert(aNewState!=null);
 
         // Mark the new state as accepting if at least one of its original states
         // is accepting.
         for (final State aState : maStates)
+        {
             if (aState.IsAccepting())
             {
                 aNewState.SetIsAccepting();
                 break;
             }
+            for (final SkipData aData : aState.GetSkipData())
+                aNewState.AddSkipData(aData.Clone(aNewState));
+            final INode aTextType = aState.GetTextType();
+            if (aTextType != null)
+                aNewState.SetTextType(aTextType);
+        }
 
         return aNewState;
     }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/ValidatingCreator.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/ValidatingCreator.java
index 8489299..c0dd5ac 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/ValidatingCreator.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/automaton/ValidatingCreator.java
@@ -85,16 +85,24 @@ public class ValidatingCreator
     {
         final FiniteAutomatonContainer aAutomatons = new FiniteAutomatonContainer(maStateContainer);
 
+        // Create the automaton for the top-level elements.
         aAutomatons.AddAutomaton(
             null,
             CreateForTopLevelElements());
 
+        // Create one automation for each complex type.
         for (final ComplexType aComplexType : maSchemaBase.ComplexTypes.GetSorted())
             aAutomatons.AddAutomaton(
                 aComplexType.GetName(),
                 CreateForComplexType(aComplexType));
 
-        maLog.close();
+        // Create one automaton for each simple type that is referenced by an element.
+        for (final INode aSimpleType : maElementSimpleTypes)
+            aAutomatons.AddAutomaton(
+                aSimpleType.GetName(),
+                CreateForSimpleType(aSimpleType));
+
+        maLog.Close();
 
         return aAutomatons;
     }
@@ -120,7 +128,7 @@ public class ValidatingCreator
                 maStateContext.GetStartState(),
                 aEndState);
 
-        return new FiniteAutomaton(maStateContext, null);
+        return new FiniteAutomaton(maStateContext, null, null);
     }
 
 
@@ -140,7 +148,8 @@ public class ValidatingCreator
             aEndState);
         return new FiniteAutomaton(
             maStateContext,
-            maAttributes);
+            maAttributes,
+            aComplexType.GetLocation());
     }
 
 
@@ -149,7 +158,7 @@ public class ValidatingCreator
     @Override
     public void Visit (final All aAll)
     {
-        AddComment("All");
+        maLog.AddComment("All");
         ProcessAttributes(aAll);
 
         // Make a transformation of the children into a choice of sequences that
@@ -164,15 +173,18 @@ public class ValidatingCreator
             maCurrentContext.BaseState,
             "Ae");
 
-        StartBlock();
+        maLog.StartBlock();
         AddEpsilonTransition(maCurrentContext.StartState, aLocalStartState);
+        final long nStartTime = System.currentTimeMillis();
         ProcessType(
             aReplacement,
             maStateContext.CreateState(maCurrentContext.BaseState, "A"),
             aLocalStartState,
             aLocalEndState);
+        final long nEndTime = System.currentTimeMillis();
+        System.out.printf("processed 'all' children in %fs\n", (nEndTime-nStartTime)/1000.0);
         AddEpsilonTransition(aLocalEndState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -183,7 +195,7 @@ public class ValidatingCreator
     {
         assert(aAny.GetChildCount() == 0);
 
-        AddComment("Any");
+        maLog.AddComment("Any");
         ProcessAttributes(aAny);
 
         AddSkipTransition(
@@ -202,16 +214,16 @@ public class ValidatingCreator
     {
         assert(aComplexContent.GetChildCount() == 1);
 
-        AddComment ("Complex Content.");
+        maLog.AddComment ("Complex Content.");
         ProcessAttributes(aComplexContent);
 
-        StartBlock();
+        maLog.StartBlock();
         ProcessType(
             aComplexContent.GetChildren().iterator().next(),
             maCurrentContext.BaseState,
             maCurrentContext.StartState,
             maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -222,14 +234,14 @@ public class ValidatingCreator
     {
         if (maLog != null)
         {
-            maLog.print("\n");
-            AddComment ("Complex Type %s defined in %s.",
+            maLog.printf("\n");
+            maLog.AddComment ("Complex Type %s defined in %s.",
                 aComplexType.GetName().GetDisplayName(),
                 aComplexType.GetLocation());
         }
         ProcessAttributes(aComplexType);
 
-        StartBlock();
+        maLog.StartBlock();
         maLog.printf("%sstarting at state %s\n", msLogIndentation, maCurrentContext.StartState.GetFullname());
 
         if (GetElementCount(aComplexType) == 0)
@@ -243,7 +255,7 @@ public class ValidatingCreator
         for (final INode aChild : aComplexType.GetChildren())
             ProcessType(aChild, maCurrentContext.BaseState, maCurrentContext.StartState, maCurrentContext.EndState);
 
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -261,12 +273,12 @@ public class ValidatingCreator
     @Override
     public void Visit (final Choice aChoice)
     {
-        AddComment("Choice");
+        maLog.AddComment("Choice");
         ProcessAttributes(aChoice);
 
         final State aLocalStartState = maStateContext.CreateState(maCurrentContext.BaseState, "Cs");
         final State aLocalEndState = maStateContext.CreateState(maCurrentContext.BaseState, "Ce");
-        StartBlock();
+        maLog.StartBlock();
         AddEpsilonTransition(maCurrentContext.StartState, aLocalStartState);
 
         int nStateIndex = 0;
@@ -279,7 +291,7 @@ public class ValidatingCreator
                 aLocalEndState);
         }
         AddEpsilonTransition(aLocalEndState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -290,7 +302,7 @@ public class ValidatingCreator
     {
         assert(aElement.GetChildCount()==0);
 
-        AddComment("Element: on '%s' go from %s to %s via %s",
+        maLog.AddComment("Element: on '%s' go from %s to %s via %s",
             aElement.GetElementName().GetDisplayName(),
             maCurrentContext.StartState.GetFullname(),
             maCurrentContext.EndState.GetFullname(),
@@ -303,6 +315,13 @@ public class ValidatingCreator
             aElement.GetElementName(),
             aElement.GetTypeName().GetStateName());
         maCurrentContext.StartState.AddTransition(aTransition);
+
+        // For elements whose type is a simple type we have to remember that
+        // simple type for later (and then create an NFA for it.)
+        final INode aSimpleType = maSchemaBase.GetSimpleTypeForName(
+            aElement.GetTypeName());
+        if (aSimpleType != null)
+            maElementSimpleTypes.add(aSimpleType);
     }
 
 
@@ -313,15 +332,15 @@ public class ValidatingCreator
     {
         assert(aReference.GetChildCount() == 0);
 
-        AddComment("Element reference to %s", aReference.GetReferencedElementName());
+        maLog.AddComment("Element reference to %s", aReference.GetReferencedElementName());
         ProcessAttributes(aReference);
 
         final Element aElement = aReference.GetReferencedElement(maSchemaBase);
         if (aElement == null)
             throw new RuntimeException("can't find referenced element "+aReference.GetReferencedElementName());
-        StartBlock();
+        maLog.StartBlock();
         ProcessType(aElement, maCurrentContext.BaseState, maCurrentContext.StartState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -334,12 +353,12 @@ public class ValidatingCreator
     {
         assert(aExtension.GetChildCount() <= 1);
 
-        AddComment("Extension of base type %s", aExtension.GetBaseTypeName());
+        maLog.AddComment("Extension of base type %s", aExtension.GetBaseTypeName());
         ProcessAttributes(aExtension);
 
         final Vector<INode> aNodes = aExtension.GetTypeNodes(maSchemaBase);
 
-        StartBlock();
+        maLog.StartBlock();
         int nStateIndex = 0;
         State aCurrentState = maStateContext.CreateState(maCurrentContext.BaseState, "E"+nStateIndex++);
         AddEpsilonTransition(maCurrentContext.StartState, aCurrentState);
@@ -355,7 +374,7 @@ public class ValidatingCreator
             aCurrentState = aNextState;
         }
         AddEpsilonTransition(aCurrentState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -366,17 +385,17 @@ public class ValidatingCreator
     {
         assert(aGroup.GetChildCount() == 1);
 
-        AddComment("Group %s", aGroup.GetName());
+        maLog.AddComment("Group %s", aGroup.GetName());
         ProcessAttributes(aGroup);
 
-        StartBlock();
+        maLog.StartBlock();
         final State aGroupBaseState = maStateContext.CreateState(maCurrentContext.BaseState, "G");
         ProcessType(
             aGroup.GetOnlyChild(),
             aGroupBaseState,
             maCurrentContext.StartState,
             maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -385,16 +404,16 @@ public class ValidatingCreator
     @Override
     public void Visit (final GroupReference aReference)
     {
-        AddComment("Group reference to %s", aReference.GetReferencedGroupName());
+        maLog.AddComment("Group reference to %s", aReference.GetReferencedGroupName());
         ProcessAttributes(aReference);
 
         final Group aGroup = aReference.GetReferencedGroup(maSchemaBase);
         if (aGroup == null)
             throw new RuntimeException("can't find referenced group "+aReference.GetReferencedGroupName());
 
-        StartBlock();
+        maLog.StartBlock();
         ProcessType(aGroup, maCurrentContext.BaseState, maCurrentContext.StartState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -409,12 +428,12 @@ public class ValidatingCreator
     {
         assert(aOccurrence.GetChildCount() == 1);
 
-        AddComment("OccurrenceIndicator %s->%s",
+        maLog.AddComment("OccurrenceIndicator %s->%s",
             aOccurrence.GetDisplayMinimum(),
             aOccurrence.GetDisplayMaximum());
         ProcessAttributes(aOccurrence);
 
-        StartBlock();
+        maLog.StartBlock();
 
         final INode aChild = aOccurrence.GetChildren().iterator().next();
 
@@ -426,7 +445,7 @@ public class ValidatingCreator
         {
             // A zero minimum means that all occurrences are optional.
             // Add a short circuit from start to end.
-            AddComment("Occurrence: make whole element optional (min==0)");
+            maLog.AddComment("Occurrence: make whole element optional (min==0)");
             AddEpsilonTransition(maCurrentContext.StartState, maCurrentContext.EndState);
         }
         else
@@ -436,14 +455,14 @@ public class ValidatingCreator
             {
                 // Add transition i-1 -> i (i == nIndex).
                 final State aNextState = maStateContext.CreateState(maCurrentContext.BaseState, "O"+nIndex);
-                AddComment("Occurrence: move from %d -> %d (%s -> %s) (minimum)",
+                maLog.AddComment("Occurrence: move from %d -> %d (%s -> %s) (minimum)",
                     nIndex-1,
                     nIndex,
                     aCurrentState,
                     aNextState);
-                StartBlock();
+                maLog.StartBlock();
                 ProcessType(aChild, aCurrentState, aCurrentState, aNextState);
-                EndBlock();
+                maLog.EndBlock();
                 aCurrentState = aNextState;
             }
         }
@@ -454,17 +473,17 @@ public class ValidatingCreator
 
             // last -> loop
             final State aLoopState = maStateContext.CreateState(maCurrentContext.BaseState, "OL");
-            AddComment("Occurrence: forward to loop (maximum)");
+            maLog.AddComment("Occurrence: forward to loop (maximum)");
             AddEpsilonTransition(aCurrentState, aLoopState);
 
             // loop -> loop
-            AddComment("Occurrence: loop");
-            StartBlock();
+            maLog.AddComment("Occurrence: loop");
+            maLog.StartBlock();
             ProcessType(aChild, aLoopState, aLoopState, aLoopState);
-            EndBlock();
+            maLog.EndBlock();
 
             // -> end
-            AddComment("Occurrence: forward to local end");
+            maLog.AddComment("Occurrence: forward to local end");
             AddEpsilonTransition(aLoopState, maCurrentContext.EndState);
         }
         else
@@ -475,29 +494,29 @@ public class ValidatingCreator
                 if (nIndex > 0)
                 {
                     // i-1 -> end
-                    AddComment("Occurrence: make %d optional (maximum)", nIndex-1);
+                    maLog.AddComment("Occurrence: make %d optional (maximum)", nIndex-1);
                     AddEpsilonTransition(aCurrentState, maCurrentContext.EndState);
                 }
 
                 // i-1 -> i
                 final State aNextState = maStateContext.CreateState(maCurrentContext.BaseState, "O"+nIndex);
-                AddComment("Occurrence: %d -> %d (%s -> %s) (maximum)",
+                maLog.AddComment("Occurrence: %d -> %d (%s -> %s) (maximum)",
                     nIndex-1,
                     nIndex,
                     aCurrentState,
                     aNextState);
-                StartBlock();
+                maLog.StartBlock();
                 ProcessType(aChild, aCurrentState, aCurrentState, aNextState);
-                EndBlock();
+                maLog.EndBlock();
 
                 aCurrentState = aNextState;
             }
 
             // max -> end
-            AddComment("Occurrence: forward to local end");
+            maLog.AddComment("Occurrence: forward to local end");
             AddEpsilonTransition(aCurrentState, maCurrentContext.EndState);
         }
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -510,10 +529,10 @@ public class ValidatingCreator
     @Override
     public void Visit (final Sequence aSequence)
     {
-        AddComment("Sequence.");
+        maLog.AddComment("Sequence.");
         ProcessAttributes(aSequence);
 
-        StartBlock();
+        maLog.StartBlock();
         int nStateIndex = 0;
         State aCurrentState = maStateContext.CreateState(maCurrentContext.BaseState, "S"+nStateIndex++);
         AddEpsilonTransition(maCurrentContext.StartState, aCurrentState);
@@ -524,7 +543,7 @@ public class ValidatingCreator
             aCurrentState = aNextState;
         }
         AddEpsilonTransition(aCurrentState, maCurrentContext.EndState);
-        EndBlock();
+        maLog.EndBlock();
     }
 
 
@@ -533,7 +552,8 @@ public class ValidatingCreator
     @Override
     public void Visit (final BuiltIn aNode)
     {
-        throw new RuntimeException("can not handle "+aNode.toString());
+        // Ignored.
+        //throw new RuntimeException("can not handle "+aNode.toString());
     }
 
 
@@ -559,7 +579,7 @@ public class ValidatingCreator
     @Override
     public void Visit (final SimpleContent aNode)
     {
-        AddComment("SimpleContent.");
+        maLog.AddComment("SimpleContent.");
         ProcessAttributes(aNode);
 
         for (final INode aChild : aNode.GetChildren())
@@ -572,9 +592,9 @@ public class ValidatingCreator
     @Override
     public void Visit (final SimpleType aNode)
     {
-        AddComment("SimpleContent.");
-        for (final INode aChild : aNode.GetChildren())
-            ProcessType(aChild, maCurrentContext.BaseState, maCurrentContext.StartState, maCurrentContext.EndState);
+        maLog.AddComment("SimpleType.");
+        //for (final INode aChild : aNode.GetChildren())
+            //ProcessType(aChild, maCurrentContext.BaseState, maCurrentContext.StartState, maCurrentContext.EndState);
     }
 
 
@@ -706,6 +726,8 @@ public class ValidatingCreator
 
     private INode GetAllReplacement (final All aAll)
     {
+        final long nStartTime = System.currentTimeMillis();
+
         // By default each child of this node can appear exactly once, however
         // the order is undefined.  This corresponds to an enumeration of all
         // permutations of the children.
@@ -735,7 +757,10 @@ public class ValidatingCreator
 
             ++nCount;
         }
-        System.out.printf("there are %d permutations\n", nCount);
+        final long nEndTime = System.currentTimeMillis();
+        System.out.printf("created %d permutations in %fs\n",
+            nCount,
+            (nEndTime-nStartTime)/1000.0);
 
         return aChoice;
     }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/LogGenerator.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/LogGenerator.java
index 8eeaf87..36deab2 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/LogGenerator.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/LogGenerator.java
@@ -216,12 +216,6 @@ public class LogGenerator
                         WriteAttribute(sIndentation+"    ", aAttribute);
                     break;
 
-                case SimpleType:
-                    final Restriction aRestriction = ((SimpleType)aType).GetRestriction();
-                    if (aRestriction != null)
-                        WriteRestriction(sIndentation+"    ", aRestriction);
-                    break;
-
                 case SimpleTypeReference:
                     WriteType(
                             sIndentation+"    ",
@@ -303,9 +297,6 @@ public class LogGenerator
             case ComplexType:
                 return ((ComplexType)aType).GetAttributes().iterator().hasNext();
 
-            case SimpleType:
-                return ((SimpleType)aType).GetRestriction() != null;
-
             case SimpleTypeReference:
                 return true;
 
@@ -317,16 +308,6 @@ public class LogGenerator
 
 
 
-    private void WriteRestriction (
-        final String sIndentation,
-        final Restriction aRestriction)
-    {
-        maOut.printf("%s%s\n", sIndentation, aRestriction.toString());
-    }
-
-
-
-
     private final SchemaBase maSchemaBase;
     private final PrintStream maOut;
 }
diff --git a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/ParserTablesGenerator.java b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/ParserTablesGenerator.java
index fe18e99..99cfbe1 100644
--- a/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/ParserTablesGenerator.java
+++ b/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/generator/ParserTablesGenerator.java
@@ -39,20 +39,35 @@ import org.apache.openoffice.ooxml.schema.automaton.State;
 import org.apache.openoffice.ooxml.schema.automaton.Transition;
 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
 import org.apache.openoffice.ooxml.schema.model.attribute.AttributeBase.Use;
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
 import org.apache.openoffice.ooxml.schema.model.schema.NamespaceMap;
 import org.apache.openoffice.ooxml.schema.parser.FormDefault;
+import org.apache.openoffice.ooxml.schema.simple.BlobNode;
+import org.apache.openoffice.ooxml.schema.simple.DateTimeNode;
+import org.apache.openoffice.ooxml.schema.simple.ISimpleTypeNode;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list