<?xml version="1.0" encoding="utf-8"?>

<!--
	description: "Eiffel Xace RelaxNG specification"
	system: "Gobo Eiffel Xace"
	copyright: "Copyright (c) 2003, Berend de Boer and others"
	license: "Eiffel Forum License v2 (see forum.txt)"
	date: "$Date: 2005/03/06 19:47:55 $"
	revision: "$Revision: 1.7 $"
-->

<grammar
	xmlns="http://relaxng.org/ns/structure/1.0"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

	<!-- An Xace file defines either a library or a system -->
	<start>

		<choice>
			<ref name="library"/>
			<ref name="system"/>
		</choice>

	</start>


	<!-- Definition for <library/> follows -->
	<define name="library">
		<element name="library">
			<attribute name="name"/>
			<optional>
				<attribute name="prefix"/>
			</optional>
			<ref name="description"/>
			<oneOrMore>
				<choice>
					<ref name="option"/>
					<ref name="cluster"/>
					<ref name="mount"/>
				</choice>
			</oneOrMore>
		</element>
	</define>


	<!-- Definition for <system/> follows -->
	<define name="system">
		<element name="system">
			<attribute name="name"/>
			<ref name="description"/>
			<oneOrMore> <!-- use if/unless flags to enable/disable just one -->
				<element name="root">
					<attribute name="class"/>
					<attribute name="creation"/>
				</element>
			</oneOrMore>
			<oneOrMore>
				<choice>
					<ref name="option"/>
					<ref name="cluster"/>
					<ref name="mount"/>
				</choice>
			</oneOrMore>
		</element>
	</define>


	<!-- Elements used in both libraries and systems -->
	<define name="description">
		<element name="description">
			<text/>
		</element>
	</define>

	<define name="cluster">
		<element name="cluster">
			<attribute name="name"/>
			<optional>
				<attribute name="prefix"/>
			</optional>
			<optional>
				<attribute name="relative"><data type="boolean"/></attribute>
			</optional>
			<optional>
				<attribute name="location"/>
			</optional>
			<ref name="ifUnless"/>
			<zeroOrMore>
				<choice>
					<ref name="option"/>
					<ref name="cluster"/>
					<ref name="class"/>
				</choice>
			</zeroOrMore>
		</element>
	</define>

	<define name="class">
		<element name="class">
			<attribute name="name"/>
			<ref name="ifUnless"/>
			<zeroOrMore>
				<choice>
					<ref name="option"/>
					<ref name="feature"/>
				</choice>
			</zeroOrMore>
		</element>
	</define>

	<define name="feature">
		<element name="feature">
			<attribute name="name"/>
			<ref name="ifUnless"/>
			<zeroOrMore>
				<ref name="option"/>
			</zeroOrMore>
		</element>
	</define>

	<define name="mount">
		<element name="mount">
			<attribute name="location"/>
			<ref name="ifUnless"/>
		</element>
	</define>

	<define name="option">
		<element name="option">
			<optional>
				<attribute name="name"/>
				<attribute name="value"/>
			</optional>
			<ref name="ifUnless"/>
			<zeroOrMore>
				<ref name="option"/>
			</zeroOrMore>
		</element>
	</define>

	<!-- if and unless attributes can be used on most elements -->
	<define name="ifUnless">
		<optional>
			<choice>
				<attribute name="if"/>
				<attribute name="unless"/>
			</choice>
		</optional>
	</define>

</grammar>
