openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1599430 [3/5] - in /openoffice/trunk/main/ooxml: ./ source/ source/framework/ source/framework/JavaOOXMLParser/ source/framework/JavaOOXMLParser/.settings/ source/framework/JavaOOXMLParser/src/ source/framework/JavaOOXMLParser/src/org/ sou...
Date Tue, 03 Jun 2014 06:57:15 GMT
Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeGroupReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeGroupReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeGroupReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeGroupReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,112 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.attribute;
+
+import java.util.Vector;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+public class AttributeGroupReference
+    extends Node
+    implements INodeReference
+{
+    public AttributeGroupReference (
+        final QualifiedName aReferencedElementName,
+        final Location aLocation)
+    {
+        super(null, null, aLocation);
+        maReferencedElement = aReferencedElementName;
+    }
+    
+    
+    
+    
+    @Override
+    public INode GetOnlyChild ()
+    {
+        throw new RuntimeException("AttributeGroupReference has no children");
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    public QualifiedName GetReferencedName ()
+    {
+        return maReferencedElement;
+    }
+
+
+
+
+    public AttributeGroup GetReferencedAttributeGroup (final Schema aSchema)
+    {
+        return aSchema.AttributeGroups.Get(maReferencedElement);
+    }
+    
+    
+    
+    
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetReferencedAttributeGroup(aSchema);
+    }
+
+        
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.AttributeGroupReference;
+    }
+
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "reference to attribute group "+maReferencedElement.GetDisplayName();
+    }
+    
+    
+    
+    
+    private final QualifiedName maReferencedElement;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/attribute/AttributeReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,102 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.attribute;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+public class AttributeReference
+    extends AttributeBase
+    implements INodeReference
+{
+    public AttributeReference (
+        final QualifiedName aReferencedName,
+        final String sUse,
+        final String sDefault,
+        final String sFixed,
+        final Location aLocation)
+    {
+        super(aReferencedName, sUse, sDefault, sFixed, aLocation);
+        
+        maReferencedName = aReferencedName;
+    }
+
+
+
+
+    public Attribute GetReferencedAttribute (final Schema aSchema)
+    {
+        final Attribute aAttribute = aSchema.Attributes.Get(maReferencedName);
+        if (aAttribute == null)
+            throw new RuntimeException(
+                String.format(
+                    "can not find attribute %s, referenced at %s",
+                    maReferencedName.GetDisplayName(),
+                    GetLocation()));
+        return aAttribute;
+    }
+    
+    
+    
+    
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetReferencedAttribute(aSchema);
+    }
+
+        
+    
+    
+    public QualifiedName GetReferencedName ()
+    {
+        return maReferencedName;
+    }
+
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.AttributeReference;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor(INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    private final QualifiedName maReferencedName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INode.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INode.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INode.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INode.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,38 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+
+/** Interface of all nodes in a tree of XML schema nodes.
+ *  It is implemented by complex types, simple types, and attributes.
+ */
+public interface INode
+{
+    NodeType GetNodeType ();
+    QualifiedName GetName ();
+    int GetChildCount();
+    Iterable<INode> GetChildren();
+    INode GetOnlyChild();
+    Iterable<INode> GetAttributes ();
+    void AcceptVisitor (final INodeVisitor aVisitor);
+    Location GetLocation ();
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,32 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+/** Interface implemented by all references to INodes.
+ */
+public interface INodeReference
+    extends INode
+{
+    INode GetReferencedNode (final Schema aSchema);
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeVisitor.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeVisitor.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeVisitor.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/INodeVisitor.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,85 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroup;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroupReference;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeReference;
+import org.apache.openoffice.ooxml.schema.model.complex.All;
+import org.apache.openoffice.ooxml.schema.model.complex.Any;
+import org.apache.openoffice.ooxml.schema.model.complex.Choice;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexContent;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexType;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexTypeReference;
+import org.apache.openoffice.ooxml.schema.model.complex.Element;
+import org.apache.openoffice.ooxml.schema.model.complex.ElementReference;
+import org.apache.openoffice.ooxml.schema.model.complex.Extension;
+import org.apache.openoffice.ooxml.schema.model.complex.Group;
+import org.apache.openoffice.ooxml.schema.model.complex.GroupReference;
+import org.apache.openoffice.ooxml.schema.model.complex.OccurrenceIndicator;
+import org.apache.openoffice.ooxml.schema.model.complex.Sequence;
+import org.apache.openoffice.ooxml.schema.model.simple.BuiltIn;
+import org.apache.openoffice.ooxml.schema.model.simple.List;
+import org.apache.openoffice.ooxml.schema.model.simple.Restriction;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleContent;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleType;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleTypeReference;
+import org.apache.openoffice.ooxml.schema.model.simple.Union;
+
+/** Interface for the visitor pattern.
+ *  Use a node visitor instead of INode/NodeType and casting INode to a derived
+ *  class.
+ *  See also the default implementation NodeVisitorAdapter. 
+ */
+public interface INodeVisitor
+{
+    // Complex nodes.
+    void Visit (final All aAll);
+    void Visit (final Any aAny);
+    void Visit (final ComplexContent aComplexContent);
+    void Visit (final ComplexType aNode);
+    void Visit (final ComplexTypeReference aTypeReference);
+    void Visit (final Choice aChoice);
+    void Visit (final Element aElement);
+    void Visit (final ElementReference aElementReference);
+    void Visit (final Extension aNode);
+    void Visit (final Group aGroup);
+    void Visit (final GroupReference aGroupReference);
+    void Visit (final OccurrenceIndicator aOccurrenceIndicator);
+    void Visit (final Sequence aNode);
+    
+    // Simple nodes.
+    void Visit (final BuiltIn aType);
+    void Visit (final List aList);
+    void Visit (final Restriction aRestriction);
+    void Visit (final SimpleContent aSimpleContent);
+    void Visit (final SimpleType aSimpleType);
+    void Visit (final SimpleTypeReference aSimpleTypeReference);
+    void Visit (final Union aUnion);
+    
+    // Attributes.
+    void Visit (final AttributeGroup attributeGroup);
+    void Visit (final AttributeReference attributeReference);
+    void Visit (final Attribute attribute);
+    void Visit (final AttributeGroupReference attributeGroupReference);
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Location.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Location.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Location.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Location.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,61 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+/** The location in a file consisting of file name, line number, column number
+ *  and byte index in the file.
+ */
+public class Location
+{
+    public Location (
+        final String sFilename,
+        final int nLineNumber,
+        final int nColumnNumber,
+        final int nOffset)
+    {
+        msFilename = sFilename;
+        mnLineNumber = nLineNumber;
+        mnColumnNumber = nColumnNumber;
+        mnOffset = nOffset;
+    }
+
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return String.format("%s:%d,%d/%d",
+            msFilename,
+            mnLineNumber,
+            mnColumnNumber,
+            mnOffset);
+    }
+    
+    
+    
+    
+    private final String msFilename;
+    private final int mnLineNumber;
+    private final int mnColumnNumber;
+    private final int mnOffset;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Node.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Node.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Node.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/Node.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,156 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+import java.util.Vector;
+
+/** Base class for the nodes in the type hierarchies that represent complex
+ *  types, simple types, and attributes.
+ */
+public abstract class Node
+    implements INode, Comparable<Node>
+{
+    abstract public NodeType GetNodeType ();
+    
+    
+    
+    protected Node (
+        final Node aParent,
+        final QualifiedName aName,
+        final Location aLocation)
+    {
+        maParent = aParent;
+        maName = aName;
+
+        maLocation = aLocation;
+        maAttributes = new Vector<>();
+        maChildren = new Vector<>();
+    }
+    
+    
+    
+    
+    @Override
+    public QualifiedName GetName ()
+    {
+        return maName;
+    }
+    
+    
+    
+    
+    public Node GetParent ()
+    {
+        return maParent;
+    }
+    
+
+    
+    
+    /** Store the location in the schema files.  This is used for debugging or the creation of documentation.
+     */
+    public void SetLocation (
+        final Location aLocation)
+    {
+        maLocation = aLocation;
+    }
+    
+    
+    
+    
+    public Location GetLocation ()
+    {
+        return maLocation;
+    }
+    
+
+    
+    
+    public void AddAttribute (final INode aAttribute)
+    {
+        maAttributes.add(aAttribute);        
+    }
+    
+    
+    
+    
+    public Iterable<INode> GetAttributes ()
+    {
+        return maAttributes;
+    }
+    
+    
+    
+    
+    public void AddChild (final Node aChild)
+    {
+        maChildren.add(aChild);
+    }
+    
+    
+    
+
+    public Iterable<INode> GetChildren ()
+    {
+        return maChildren;
+    }
+
+
+    
+    
+    public INode GetOnlyChild ()
+    {
+        assert(maChildren.size() == 1);
+        return maChildren.get(0);
+    }
+    
+    
+    
+    
+    public int GetChildCount ()
+    {
+        return maChildren.size();
+    }
+
+    
+    
+    
+    @Override
+    public int compareTo (final Node aOther)
+    {
+        if (maName==null || aOther.maName==null)
+        {
+            throw new RuntimeException("can not compare nodes that don't have a name");
+        }
+        else
+            return maName.compareTo(aOther.maName);
+    }
+
+    
+    
+    
+    private final Node maParent;
+    private final QualifiedName maName;
+    private Location maLocation;
+    private final Vector<INode> maAttributes;
+    private final Vector<INode> maChildren;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeType.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeType.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeType.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeType.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,53 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+/** Type of a node in the XML schema tree.
+ *  It basically corresponds to the class of a node.
+ */
+public enum NodeType
+{
+    All,
+    Any,
+    Attribute,
+    AttributeReference,
+    AttributeGroup,
+    AttributeGroupReference,
+    BuiltIn,
+    Choice,
+    ComplexContent,
+    ComplexType,
+    ComplexTypeReference,
+    Element,
+    ElementReference,
+    Extension,
+    Group,
+    GroupReference,
+    List,
+    OccurrenceIndicator,
+    Restriction,
+    Sequence,
+    SimpleContent,
+    SimpleType,
+    SimpleTypeReference,
+    Union
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeVisitorAdapter.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeVisitorAdapter.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeVisitorAdapter.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/NodeVisitorAdapter.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,203 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroup;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroupReference;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeReference;
+import org.apache.openoffice.ooxml.schema.model.complex.All;
+import org.apache.openoffice.ooxml.schema.model.complex.Any;
+import org.apache.openoffice.ooxml.schema.model.complex.Choice;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexContent;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexType;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexTypeReference;
+import org.apache.openoffice.ooxml.schema.model.complex.Element;
+import org.apache.openoffice.ooxml.schema.model.complex.ElementReference;
+import org.apache.openoffice.ooxml.schema.model.complex.Extension;
+import org.apache.openoffice.ooxml.schema.model.complex.Group;
+import org.apache.openoffice.ooxml.schema.model.complex.GroupReference;
+import org.apache.openoffice.ooxml.schema.model.complex.OccurrenceIndicator;
+import org.apache.openoffice.ooxml.schema.model.complex.Sequence;
+import org.apache.openoffice.ooxml.schema.model.simple.BuiltIn;
+import org.apache.openoffice.ooxml.schema.model.simple.List;
+import org.apache.openoffice.ooxml.schema.model.simple.Restriction;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleContent;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleType;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleTypeReference;
+import org.apache.openoffice.ooxml.schema.model.simple.Union;
+
+/** Implementation of the INodeVisitor interface.
+ *  All methods that are not overridden are redirected to the Default(INode)
+ *  method.  
+ */
+public class NodeVisitorAdapter
+    implements INodeVisitor
+{
+    @Override
+    public void Visit (final All aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final Any aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final Choice aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final ComplexContent aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final ComplexType aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final ComplexTypeReference aTypeReference)
+    {
+        Default(aTypeReference);
+    }
+
+    @Override
+    public void Visit (final Element aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final ElementReference aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final Extension aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final Group aNode)
+    {
+        Default(aNode);
+    }
+    
+    @Override
+    public void Visit (final GroupReference aNode)
+    {
+        Default(aNode);
+    }
+
+    @Override
+    public void Visit (final OccurrenceIndicator aIndicator)
+    {
+        Default(aIndicator);
+    }
+
+    @Override
+    public void Visit(Sequence aNode)
+    {
+        Default(aNode);
+    }
+    
+    @Override
+    public void Visit (final BuiltIn aType)
+    {
+        Default(aType);
+    }
+
+    @Override
+    public void Visit (final List aList)
+    {
+        Default(aList);
+    }
+
+    @Override
+    public void Visit (final SimpleContent aSimpleContent)
+    {
+        Default(aSimpleContent);
+    }
+
+    @Override
+    public void Visit (final SimpleType aSimpleType)
+    {
+        Default(aSimpleType);
+    }
+
+    @Override
+    public void Visit (final SimpleTypeReference aSimpleTypeReference)
+    {
+        Default(aSimpleTypeReference);
+    }
+    
+    @Override
+    public void Visit (final Union aUnion)
+    {
+        Default(aUnion);
+    }
+
+    @Override
+    public void Visit (final Restriction aRestriction)
+    {
+        Default(aRestriction);
+    }
+
+    @Override
+    public void Visit (final AttributeGroup aAttributeGroup)
+    {
+        Default(aAttributeGroup);
+    }
+
+    @Override
+    public void Visit (final AttributeGroupReference aAttributeGroupReference)
+    {
+        Default(aAttributeGroupReference);
+    }
+
+    @Override
+    public void Visit (final AttributeReference aAttributeReference)
+    {
+        Default(aAttributeReference);
+    }
+
+    @Override
+    public void Visit (final Attribute aAttribute)
+    {
+        Default(aAttribute);
+    }
+    
+    public void Default (final INode aNode)
+    {
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/QualifiedName.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/QualifiedName.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/QualifiedName.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/base/QualifiedName.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,141 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.base;
+
+import javax.xml.namespace.QName;
+
+/** Similar to the QName class.  A qualified name that consists of the local
+ *  part and a namespace. 
+ *  The namespace is stored both as URI and short form (prefix).
+ */
+public class QualifiedName
+    implements Comparable<QualifiedName>
+{
+    public QualifiedName (final QName aName)
+    {
+        msLocalPart = aName.getLocalPart();
+        msNamespacePrefix = aName.getPrefix();
+        msNamespaceURI = aName.getNamespaceURI();
+    }
+    
+    
+    
+    
+    public QualifiedName (
+        final String sNamespaceURI,
+        final String sNamespacePrefix,
+        final String sLocalPart)
+    {
+        msLocalPart = sLocalPart;
+        msNamespacePrefix = sNamespacePrefix;
+        msNamespaceURI = sNamespaceURI;
+    }
+    
+
+
+
+    /** Return a textual representation for informal (and informative) display.
+     */
+    public String GetDisplayName ()
+    {
+        if (msNamespacePrefix == null)
+            return msLocalPart;
+        else
+            return msNamespacePrefix + ":" + msLocalPart;
+    }
+    
+    
+    
+
+    public String GetStateName()
+    {
+        if (msNamespacePrefix == null)
+            return msLocalPart;
+        else
+            return msNamespacePrefix + "_" + msLocalPart;
+    }
+
+    
+    
+    
+    public String GetNamespaceURI ()
+    {
+        return msNamespaceURI;
+    }
+    
+    
+    
+    
+    public String GetNamespacePrefix ()
+    {
+        return msNamespacePrefix;
+    }
+    
+    
+    
+    
+    public String GetLocalPart ()
+    {
+        return msLocalPart;
+    }
+
+    
+    
+    
+    /** Compare QualifiedName objects (e.g. for sorting them).
+     *  Primary sort key is the local part.
+     *  Secondary key is the namespace prefix.
+     *  Missing prefixes come before existing prefixes.
+     */
+    @Override
+    public int compareTo (final QualifiedName aOther)
+    {
+        final int nComparisonResult = msLocalPart.compareTo(aOther.msLocalPart);
+        if (nComparisonResult != 0)
+            return nComparisonResult;
+        else
+            if (msNamespacePrefix==null && aOther.msNamespacePrefix==null)
+                return 0;
+            else if (msNamespacePrefix!=null && aOther.msNamespacePrefix!=null)
+                return msNamespacePrefix.compareTo(aOther.msNamespacePrefix);
+            else if (msNamespacePrefix==null)
+                return -1;
+            else
+                return +1;
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return GetDisplayName(); 
+    }
+    
+    
+    
+    
+    private final String msLocalPart;
+    private final String msNamespacePrefix;
+    private final String msNamespaceURI;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/All.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/All.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/All.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/All.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,87 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+
+/** Representation of the 'all' XML schema element.  All its children are
+ *  expected to occur in any order.  By default each child is optional but with
+ *  a min=1 attribute the children can be made mandatory.
+ */
+public class All
+    extends Node
+{
+    public All (
+        final Node aParent,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        
+        assert(CheckParent(aParent));
+    }
+
+
+    
+    
+    /** Occurrence values of an 'all' node must be 
+     *  min=(0,1)
+     *  max=1.
+     */
+    private static boolean CheckParent (final Node aParent)
+    {
+        if (aParent == null)
+            return false;
+        if (aParent.GetNodeType() != NodeType.OccurrenceIndicator)
+            // Missing occurrence parent means that min and max have the default
+            // values of 0 and 1, which is valid.
+            return true;
+        
+        final OccurrenceIndicator aIndicator = (OccurrenceIndicator)aParent;
+        if (aIndicator.GetMinimum() > 1)
+            return false;
+        else if (aIndicator.GetMaximum() != 1)
+            return false;
+        else
+            return true;
+    }
+    
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+    
+    
+
+    @Override
+    public NodeType GetNodeType()
+    {
+        return NodeType.All;
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Any.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Any.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Any.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Any.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,75 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+
+/** Representation of the 'any' XML schema element.  It specifies that its 
+ *  children conform to a non-standard schema.  If it is unknown than the
+ *  children are to be ignored.
+ */
+public class Any
+    extends Node
+{
+    public Any (
+        final Node aParent,
+        final String sProcessContents,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        msProcessContents = sProcessContents;
+    }
+
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.Any;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return String.format("any processContents=%s", msProcessContents);
+    }
+    
+    
+    
+    
+    private final String msProcessContents;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Choice.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Choice.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Choice.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Choice.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,68 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+
+/** Representation of the 'choice' XML schema element.
+ *  With the default max value (1) only one of its children may occur.
+ */
+public class Choice
+    extends Node
+{
+    public Choice (
+        final Node aParent,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+    }
+    
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.Choice;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "choice";
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexContent.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexContent.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexContent.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexContent.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,56 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+
+public class ComplexContent
+    extends Node
+{
+    public ComplexContent (
+        final Node aParent,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    @Override
+    public NodeType GetNodeType()
+    {
+        return NodeType.ComplexContent;
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexType.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexType.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexType.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexType.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,72 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+
+/** Representation of the 'complexType' XML schema element.  It specifies the
+ *  structure of its children. 
+ */
+public class ComplexType
+    extends Node
+{
+    public ComplexType (
+        final Node aParent,
+        final QualifiedName aName,
+        final Location aLocation)
+    {
+        super(aParent, aName, aLocation);
+        
+        assert(aName!=null);
+    }
+    
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.ComplexType;
+    }
+
+
+    
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "complex type "+GetName().GetDisplayName();
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexTypeReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexTypeReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexTypeReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ComplexTypeReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,91 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+public class ComplexTypeReference
+    extends Node
+    implements INodeReference
+{
+    ComplexTypeReference (
+        final Node aParent,
+        final QualifiedName aReferencedTypeName,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        maReferencedTypeName = aReferencedTypeName;        
+    }
+    
+    
+    
+    
+    public ComplexType GetReferencedComplexType (final Schema aSchema)
+    {
+        final Node aType = aSchema.GetTypeForName(maReferencedTypeName);
+        if (aType == null)
+            throw new RuntimeException();
+        else if (aType.GetNodeType() != NodeType.ComplexType)
+            throw new RuntimeException();
+        else
+            return (ComplexType)aType;
+    }
+    
+    
+    
+    
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetReferencedComplexType(aSchema);
+    }
+
+        
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.SimpleTypeReference;
+    }
+    
+    
+    
+    
+    private final QualifiedName maReferencedTypeName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Element.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Element.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Element.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Element.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,108 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+
+/** Representation of the 'element' XML schema element.
+ */
+public class Element
+    extends Node
+{
+    /** Create a new element that represents a transition to aTypeName when a
+     *  start tag of aElementName is processed.
+     */
+    public Element (
+        final Node aParent,
+        final QualifiedName aElementName,
+        final QualifiedName aTypeName,
+        final Location aLocation)
+    {
+        super(aParent, aElementName, aLocation);
+        maElementName = aElementName;
+        maTypeName = aTypeName;
+    }
+    
+    
+    
+    
+    public QualifiedName GetElementName ()
+    {
+        return maElementName;
+    }
+    
+    
+    
+    
+    public QualifiedName GetTypeName ()
+    {
+        return maTypeName;
+    }
+    
+    
+    
+    
+    @Override
+    public int compareTo (final Node aOther)
+    {
+        if (aOther.GetNodeType() != NodeType.Element)
+            throw new RuntimeException("can not compare Element object to non-Element object");
+        else
+            return maElementName.compareTo(((Element)aOther).maElementName);
+    }
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.Element;
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "element " + maElementName.GetDisplayName() +" -> " + maTypeName.GetDisplayName();
+    }
+    
+    
+    
+    
+    private final QualifiedName maElementName;
+    private final QualifiedName maTypeName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ElementReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ElementReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ElementReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/ElementReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,103 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+public class ElementReference
+    extends Element
+    implements INodeReference
+{
+    public ElementReference (
+        final Node aParent,
+        final QualifiedName aReferencedElementName,
+        final Location aLocation)
+    {
+        super(aParent, null, null, aLocation);
+        
+        maReferencedElementName = aReferencedElementName;
+    }
+    
+    
+    
+    
+    public QualifiedName GetReferencedElementName ()
+    {
+        return maReferencedElementName;
+    }
+    
+    
+
+
+    public Element GetReferencedElement (final Schema aSchema)
+    {
+        return aSchema.TopLevelElements.Get(maReferencedElementName);
+    }
+
+    
+    
+    
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetReferencedElement(aSchema);
+    }
+
+        
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.ElementReference;
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "element reference to "+maReferencedElementName.GetDisplayName();
+    }
+    
+    
+    
+    
+    private final QualifiedName maReferencedElementName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Extension.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Extension.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Extension.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Extension.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,152 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import java.util.Vector;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+/** Representation of the 'extension' XML schema element.
+ *  It extends a complex base type.
+ */
+public class Extension
+    extends Node
+    implements INodeReference
+{
+    public Extension (
+        final Node aParent,
+        final QualifiedName aBaseTypeName,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        maBaseTypeName = aBaseTypeName;
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+
+    
+    
+    
+    @Override
+    public NodeType GetNodeType()
+    {
+        return NodeType.Extension;
+    }
+
+
+
+
+    public QualifiedName GetBaseTypeName()
+    {
+        return maBaseTypeName;
+    }
+
+
+
+
+    public INode GetBaseType (final Schema aSchema)
+    {
+        return aSchema.GetTypeForName(maBaseTypeName);
+    }
+
+    
+    
+
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetBaseType(aSchema);
+    }
+
+    
+    
+
+    public Vector<INode> GetTypeNodes (final Schema aSchema)
+    {
+        final Vector<INode> aNodes = new Vector<>();
+        
+        AddNodes(aSchema.GetTypeForName(maBaseTypeName), aNodes, aSchema);
+        for (final INode aChild : GetChildren())
+            AddNodes(aChild, aNodes, aSchema);
+        
+        return aNodes;
+    }
+    
+    
+    
+    
+    private void AddNodes (
+        final INode aParent,
+        final Vector<INode> aNodes,
+        final Schema aSchema)
+    {
+        INode aNode = aParent;
+        while (true)
+        {
+            switch (aNode.GetNodeType())
+            {
+                case Extension:
+                    aNode = ((Extension)aNode).GetBaseType(aSchema);
+                    break;
+
+                case OccurrenceIndicator:
+                case ComplexContent:
+                case SimpleContent:
+                case ComplexType:
+                    switch(aNode.GetChildCount())
+                    {
+                        case 0:
+                            return;
+                        case 1:
+                            aNode = aNode.GetOnlyChild();
+                            break;
+                        default:
+                            throw new RuntimeException();
+                    }
+                    break;
+                    
+                default:
+                    aNodes.add(aNode);
+                    return;
+            }
+        }
+    }
+    
+    
+    
+    
+    public QualifiedName maBaseTypeName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Group.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Group.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Group.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Group.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,70 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+
+/** Represents the 'group' XML schema element.
+ *  The concepts of groups are similar to macros.
+ */
+public class Group
+    extends Node
+{
+    public Group (
+        final Node aParent,
+        final QualifiedName aName,
+        final Location aLocation)
+    {
+        super(aParent, aName, aLocation);
+    }
+    
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.Group;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);        
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "group "+GetName().GetDisplayName();
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/GroupReference.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/GroupReference.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/GroupReference.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/GroupReference.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,109 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.INodeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+
+public class GroupReference
+    extends Node
+    implements INodeReference
+{
+    public GroupReference (
+        final Node aParent,
+        final QualifiedName aReferencedGroupName,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        
+        maReferencedGroupName = aReferencedGroupName;
+    }
+    
+    
+    
+    
+    public QualifiedName GetReferencedGroupName ()
+    {
+        return maReferencedGroupName;
+    }
+    
+    
+
+
+    public Group GetReferencedGroup (final Schema aSchema)
+    {
+        final Node aType = aSchema.GetTypeForName(maReferencedGroupName);
+        if (aType == null)
+            throw new RuntimeException("there is no type named '"+maReferencedGroupName+"' in the schema");
+        else if (aType.GetNodeType()!=NodeType.Group)
+            throw new RuntimeException("name '"+maReferencedGroupName+"' references a "+aType.GetNodeType()+" not a group");
+        else
+            return (Group)aType;
+    }
+
+    
+    
+    
+    @Override
+    public INode GetReferencedNode (final Schema aSchema)
+    {
+        return GetReferencedGroup(aSchema);
+    }
+
+        
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.GroupReference;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return "group reference to "+maReferencedGroupName.GetDisplayName();
+    }
+    
+    
+    
+    
+    private final QualifiedName maReferencedGroupName;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/OccurrenceIndicator.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/OccurrenceIndicator.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/OccurrenceIndicator.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/OccurrenceIndicator.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,152 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+
+/** An occurrence indicator is based on a minimum and a maximum value.
+ *  The minimum value is 0 or larger.  If it is 0 then the child node is optional.
+ *  The maximum value is at least as large as the minimum value.
+ *  It can be 'unbounded' in which case the child node can appear any number of times.
+ *  'Unbounded' is internally stored as -1.
+ *  
+ *  An OccurrenceIndicator represents the minOccur and maxOccur attributes of
+ *  XML schema elements.
+ *   
+ *  There is usually exactly one child.
+ */
+public class OccurrenceIndicator
+    extends Node
+{
+    public static int unbounded = -1;
+
+    public OccurrenceIndicator (
+        final Node aParent,
+        final String sMinimum,
+        final String sMaximum,
+        final Location aLocation)
+    {
+        super(aParent, null, aLocation);
+        
+        mnMinimum = ParseValue(sMinimum);
+        mnMaximum = ParseValue(sMaximum);
+        
+        assert(mnMinimum>=0);
+        assert(mnMaximum==unbounded || mnMaximum>=mnMinimum);
+    }
+    
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.OccurrenceIndicator;
+    }
+    
+    
+    
+    
+    /** Return a string version of the minimum value for textual display.
+     */
+    public String GetDisplayMinimum ()
+    {
+        return Integer.toString(mnMinimum);
+    }
+    
+
+    
+    
+    /** Return a string version of the maximum value for textual display.
+     */
+    public String GetDisplayMaximum ()
+    {
+        if (mnMaximum == unbounded)
+            return "unbounded";
+        else
+            return Integer.toString(mnMaximum);
+    }
+    
+    
+    
+    
+    public int GetMinimum ()
+    {
+        return mnMinimum;
+    }
+    
+    
+    
+    
+    public int GetMaximum ()
+    {
+        return mnMaximum;
+    }
+
+    
+    
+    
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    } 
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        return String.format("occurrence %s to %s",
+            GetDisplayMinimum(),
+            GetDisplayMaximum());
+    }
+    
+    
+    
+    
+    private static int ParseValue (final String sValue)
+    {
+        if (sValue == null)
+        {
+            // Missing values default to 1.
+            return 1;
+        }
+        else
+            switch (sValue)
+            {
+                case "0" : return 0;
+                case "1" : return 1;
+                case "unbounded" : return unbounded;
+                default: return Integer.parseInt(sValue);
+            }
+    }
+    
+    
+    
+    private final int mnMinimum;
+    private final int mnMaximum;
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Sequence.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Sequence.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Sequence.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/complex/Sequence.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,73 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.complex;
+
+import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor;
+import org.apache.openoffice.ooxml.schema.model.base.Location;
+import org.apache.openoffice.ooxml.schema.model.base.Node;
+import org.apache.openoffice.ooxml.schema.model.base.NodeType;
+import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
+
+/** Representation of a 'sequence' XML schema element.
+ *  It defines an order on its children.
+ */
+ public class Sequence
+    extends Node
+{
+    public Sequence (
+        final Node aParent,
+        final QualifiedName aName,
+        final Location aLocation)
+    {
+        super(aParent, aName, aLocation);
+    }
+    
+    
+    
+    
+    @Override
+    public NodeType GetNodeType ()
+    {
+        return NodeType.Sequence;
+    }
+
+
+
+
+    @Override
+    public void AcceptVisitor (final INodeVisitor aVisitor)
+    {
+        aVisitor.Visit(this);
+    }
+    
+    
+    
+    
+    @Override
+    public String toString ()
+    {
+        if (GetName() != null)
+            return "sequence "+GetName().GetDisplayName();
+        else
+            return "sequence";
+    }
+}

Added: openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/ProcessTypeVisitor.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/ProcessTypeVisitor.java?rev=1599430&view=auto
==============================================================================
--- openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/ProcessTypeVisitor.java (added)
+++ openoffice/trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/model/optimize/ProcessTypeVisitor.java Tue Jun  3 06:57:13 2014
@@ -0,0 +1,110 @@
+/**************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*************************************************************/
+
+package org.apache.openoffice.ooxml.schema.model.optimize;
+
+import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroup;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeGroupReference;
+import org.apache.openoffice.ooxml.schema.model.attribute.AttributeReference;
+import org.apache.openoffice.ooxml.schema.model.base.INode;
+import org.apache.openoffice.ooxml.schema.model.base.NodeVisitorAdapter;
+import org.apache.openoffice.ooxml.schema.model.complex.ComplexType;
+import org.apache.openoffice.ooxml.schema.model.complex.Group;
+import org.apache.openoffice.ooxml.schema.model.schema.Schema;
+import org.apache.openoffice.ooxml.schema.model.simple.SimpleType;
+
+/** This visitor is called to process individual type nodes.
+ *  Actions can be adding top-level elements, complex types, simple types and
+ *  groups and attribute groups to the optimized schema.
+ */
+public class ProcessTypeVisitor
+    extends NodeVisitorAdapter
+{
+    ProcessTypeVisitor (
+        final Schema aSourceSchema,
+        final Schema aTargetSchema,
+        final SchemaOptimizer aSchemaOptimizer)
+    {
+        maSourceSchema = aSourceSchema;
+        maTargetSchema = aTargetSchema;
+        maSchemaOptimizer = aSchemaOptimizer;
+    }
+    
+    
+    
+    
+    @Override public void Visit (final ComplexType aComplexType)
+    {
+        maTargetSchema.ComplexTypes.Add(aComplexType);
+
+        // Add requests for types referenced by child nodes (sequences, elements, etc.)
+        maSchemaOptimizer.RequestReferencedTypes(aComplexType);
+    }
+
+    @Override public void Visit (final Group aGroup)
+    {
+        maTargetSchema.Groups.Add(aGroup);
+        maSchemaOptimizer.RequestReferencedTypes(aGroup);
+    }
+    @Override public void Visit (final SimpleType aSimpleType)
+    {
+        maTargetSchema.SimpleTypes.Add(aSimpleType);
+        maSchemaOptimizer.RequestReferencedTypes(aSimpleType);
+    }
+    
+    @Override public void Visit (final Attribute aAttribute)
+    {
+        maSchemaOptimizer.RequestType(aAttribute.GetTypeName());
+    }
+    @Override public void Visit (final AttributeGroup aAttributeGroup)
+    {
+        maTargetSchema.AttributeGroups.Add(aAttributeGroup);
+    }
+    @Override public void Visit (final AttributeReference aAttributeReference)
+    {
+        maTargetSchema.Attributes.Add(
+            aAttributeReference.GetReferencedAttribute(maSourceSchema));
+    }
+    @Override public void Visit (final AttributeGroupReference aAttributeGroupReference)
+    {
+        maTargetSchema.AttributeGroups.Add(
+            aAttributeGroupReference.GetReferencedAttributeGroup(maSourceSchema));
+    }
+    @Override public void Default (final INode aNode)
+    {
+        switch(aNode.GetNodeType())
+        {
+            case BuiltIn:
+                break;
+                
+            default:
+                throw new RuntimeException("don't know how to process "+aNode.toString());
+        }
+    }
+    
+    
+    
+    
+    private final Schema maSourceSchema;
+    private final Schema maTargetSchema;
+    private final SchemaOptimizer maSchemaOptimizer;
+}



Mime
View raw message