<?xml version="1.0" encoding="UTF-8"?>
<!--
  for SGML validation, use this first line instead:
  <!DOCTYPE grammar PUBLIC "-//thaiopensource//DTD RNG 20010705//EN" "">
 -->

<grammar
  xmlns="http://relaxng.org/ns/structure/1.0"
  xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes" 
  xmlns:rdt="http://relaxng.org/ns/compatibility/datatypes/1.0" 
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

  <a:documentation>
    EPNML 1.1 with subnets - RELAX NG implementation
    version: $Id: structured.rng 1474 2007-10-18 19:07:36Z rp $
    (c) 2003-2004, Technische Universiteit Eindhoven
        by JMEM van der Werf, jmw@petriweb.org
        some editing by Reinier Post, rp@petriweb.org
    human-readable documentation:
        EPNML 1.1 - an XML format for Petri nets
        http://www.petriweb.org/specs/epnml-1.1/pnmldef.pdf
  </a:documentation>
  
  
  <a:documentation>
      We use basic EPNML, with some extensions. So we include this document:
  </a:documentation>
  <!-- PNML extended to EPNML -->
  <include href="basic.rng"/>
  <define name="net.content" combine="choice">
    <a:documentation>
        Unlike in general structured PNML, we do not support
        reference transitions, and allow referencePlaces only within pages.
        See [1], section 4 and 8
    </a:documentation>
    <zeroOrMore>
      <element name="page">
        <ref name="page.content"/>
      </element>
    </zeroOrMore>

<!--    <a:documentation>
      Because of translations that petriweb makes, (page -> net), also
      referenceplaces and types must be allowed in nets.
    </a:documentation>
    <optional>
      <ref name="transition.type"/>
    </optional>
    <zeroOrMore>
      <ref name="refplace.element"/>
    </zeroOrMore>-->
  </define>
  
  
  <define name="page.content">
    <a:documentation>
      An EPNML 1.1 page is a "refined transition".
      It is like a net, except that it is within a net or page,
      can have reference places, and a transition type.
      See [1], section 8
    </a:documentation>
    <interleave>
      <ref name="common.labels"/>
      <zeroOrMore>
        <ref name="net.content"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="refplace.element"/>
      </zeroOrMore>
      <ref name="node.content"/>
      <optional>
        <ref name="transition.type"/>
      </optional>
    </interleave>
  </define>
  
  <define name="refplace.element">
    <element name="referencePlace">
      <ref name="refplace.content"/>
    </element>
  </define>

  
  <define name="refplace.content">
    <a:documentation>
        A reference place is a placeholder to a place.
        See [1], section 8.2
    </a:documentation>
    <attribute name="ref">
      <data type="IDREF"/>
    </attribute>
    <interleave>
      <ref name="node.content"/>
      <ref name="common.labels"/>
    </interleave>
  </define>

</grammar>
