<!--
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.
-->

<xs:schema
        targetNamespace="http://graphml.graphdrawing.org/xmlns"

        xmlns="http://graphml.graphdrawing.org/xmlns"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"

        elementFormDefault="qualified"
        attributeFormDefault="unqualified"
        >

    <xs:annotation>
        <xs:documentation
                source="http://graphml.graphdrawing.org/"
                xml:lang="en">
            This document defines the GraphML language including GraphML attributes and GraphML parseinfo.
        </xs:documentation>
    </xs:annotation>


    <xs:redefine schemaLocation="http://graphml.graphdrawing.org/xmlns/1.1/graphml-structure.xsd">

        <!--redefinition as in graphml-attributes.xsd -->

        <xs:attributeGroup name="key.extra.attrib">
            <xs:attributeGroup ref="key.extra.attrib"/>
            <xs:attributeGroup ref="key.attributes.attrib"/>
        </xs:attributeGroup>

        <!--redefinition as in graphml-parseinfo.xsd -->

        <xs:attributeGroup name="graph.extra.attrib">
            <xs:attributeGroup ref="graph.extra.attrib"/>
            <xs:attributeGroup ref="graph.parseinfo.attrib"/>
        </xs:attributeGroup>

        <xs:attributeGroup name="node.extra.attrib">
            <xs:attributeGroup ref="node.extra.attrib"/>
            <xs:attributeGroup ref="node.parseinfo.attrib"/>
        </xs:attributeGroup>

    </xs:redefine>


    <!--types as in graphml-attributes.xsd -->

    <xs:simpleType name="key.name.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/(Dokumentation der Attributes Erweiterung; entsprechende Stelle.html)"
                    xml:lang="en">
                Simple type for the attr.name attribute of &lt;key>.
                key.name.type is final, that is, it may not be extended
                or restricted.
                key.name.type is a restriction of xs:NMTOKEN
                Allowed values: (no restriction)
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:NMTOKEN"/>

    </xs:simpleType>


    <xs:simpleType name="key.type.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/(Dokumentation der Attributes Erweiterung; entsprechende Stelle.html)"
                    xml:lang="en">
                Simple type for the attr.type attribute of &lt;key>.
                key.type.type is final, that is, it may not be extended
                or restricted.
                key.type.type is a restriction of xs:NMTOKEN
                Allowed values: boolean, int, long, float, double, string.
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="boolean"/>
            <xs:enumeration value="int"/>
            <xs:enumeration value="long"/>
            <xs:enumeration value="float"/>
            <xs:enumeration value="double"/>
            <xs:enumeration value="string"/>
        </xs:restriction>

    </xs:simpleType>


    <xs:attributeGroup name="key.attributes.attrib">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Definition of the attribute group key.attributes.attrib.
                This group consists of the two optional attributes
                - attr.name (gives the name for the data function)
                - attr.type ((declares the range of values for the data function)
            </xs:documentation>
        </xs:annotation>

        <xs:attribute name="attr.name" type="key.name.type" use="optional"/>
        <xs:attribute name="attr.type" type="key.type.type" use="optional"/>
    </xs:attributeGroup>

    <!--types as in graphml-parseinfo.xsd -->

    <xs:annotation>
        <xs:documentation
                source="http://graphml.graphdrawing.org/"
                xml:lang="en">
            Simple type definitions for the new graph attributes.
        </xs:documentation>
    </xs:annotation>

    <xs:simpleType name="graph.order.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.order attribute of &lt;graph>.
                graph.order.type is final, that is, it may not be extended
                or restricted.
                graph.order.type is a restriction of xs:NMTOKEN
                Allowed values: free, nodesfirst, adjacencylist.
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="free"/>
            <xs:enumeration value="nodesfirst"/>
            <xs:enumeration value="adjacencylist"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="graph.nodes.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.nodes attribute of &lt;graph>.
                graph.nodes.type is final, that is, it may not be extended
                or restricted.
                graph.nodes.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:simpleType name="graph.edges.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.edges attribute of &lt;graph>.
                graph.edges.type is final, that is, it may not be extended
                or restricted.
                graph.edges.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:simpleType name="graph.maxindegree.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.maxindegree attribute of &lt;graph>.
                graph.maxindegree.type is final, that is, it may not be extended
                or restricted.
                graph.maxindegree.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:simpleType name="graph.maxoutdegree.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.maxoutdegree attribute of &lt;graph>.
                graph.maxoutdegree.type is final, that is, it may not be extended
                or restricted.
                graph.maxoutdegree.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:simpleType name="graph.nodeids.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.nodeids attribute of &lt;graph>.
                graph.nodeids.type is final, that is, it may not be extended
                or restricted.
                graph.nodeids.type is a restriction of xs:string
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="canonical"/>
            <xs:enumeration value="free"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="graph.edgeids.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.edgeids attribute of &lt;graph>.
                graph.edgeids.type is final, that is, it may not be extended
                or restricted.
                graph.edgeids.type is a restriction of xs:string
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="canonical"/>
            <xs:enumeration value="free"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:attributeGroup name="graph.parseinfo.attrib">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Definition of the attribute group graph.parseinfo.attrib.
                This group consists of the seven attributes
                - parse.nodeids (fixed to 'canonical' meaning that the id attribute
                of &lt;node> follows the pattern 'n[number]),
                - parse.edgeids (fixed to 'canonical' meaning that the id attribute
                of &lt;edge> follows the pattern 'e[number]),
                - parse.order (required; one of the values 'nodesfirst',
                'adjacencylist' or 'free'),
                - parse.nodes (required; number of nodes in this graph),
                - parse.edges (required; number of edges in this graph),
                - parse.maxindegree (optional; maximal indegree of a node in this graph),
                - parse.maxoutdegree (optional; maximal outdegree of a node in this graph)
            </xs:documentation>
        </xs:annotation>

        <xs:attribute name="parse.nodeids" type="graph.nodeids.type"/>
        <xs:attribute name="parse.edgeids" type="graph.edgeids.type"/>
        <xs:attribute name="parse.order" type="graph.order.type"/>
        <xs:attribute name="parse.nodes" type="graph.nodes.type"/>
        <xs:attribute name="parse.edges" type="graph.edges.type"/>
        <xs:attribute name="parse.maxindegree" type="graph.maxindegree.type" use="optional"/>
        <xs:attribute name="parse.maxoutdegree" type="graph.maxoutdegree.type" use="optional"/>
    </xs:attributeGroup>


    <xs:annotation>
        <xs:documentation
                source="http://graphml.graphdrawing.org/"
                xml:lang="en">
            Simple type definitions for the new node attributes.
        </xs:documentation>
    </xs:annotation>

    <xs:simpleType name="node.indegree.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.indegree attribute of &lt;node>.
                node.indegree.type is final, that is, it may not be extended
                or restricted.
                node.indegree.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:simpleType name="node.outdegree.type" final="#all">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Simple type for the parse.outdegree attribute of &lt;node>.
                node.outdegree.type is final, that is, it may not be extended
                or restricted.
                node.outdegree.type is a restriction of xs:nonNegativeInteger
                Allowed values: (no restriction).
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:nonNegativeInteger"/>
    </xs:simpleType>

    <xs:attributeGroup name="node.parseinfo.attrib">

        <xs:annotation>
            <xs:documentation
                    source="http://graphml.graphdrawing.org/"
                    xml:lang="en">
                Definition of the attribute group node.parseinfo.attrib.
                This group consists of two attributes
                - parse.indegree (optional; indegree of this node),
                - parse.outdegree (optional; outdegree of this node).
            </xs:documentation>
        </xs:annotation>

        <xs:attribute name="parse.indegree" type="node.indegree.type" use="optional"/>
        <xs:attribute name="parse.outdegree" type="node.outdegree.type" use="optional"/>
    </xs:attributeGroup>

</xs:schema>