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

<!-- Authors: Chris Taylor, Ceki Gulcu. -->
<!-- Version: 1.2 -->
<!-- PHP Port Modifications Author: VxR -->
<!-- PHP dtd Version: $Revision: 1.3 $ -->

<!--
  
-->

<grammar
	xmlns:log4php="http://logging.apache.org/log4php/"
	xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
	xmlns:xhtml="http://www.w3.org/1999/xhtml"
	xmlns:sch="http://www.ascc.net/xml/schematron"
	xmlns="http://relaxng.org/ns/structure/1.0"
	datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

	<start>
		<element name="log4php:configuration">
			<ref name="log4php.configuration"/>
		</element>
	</start>
	
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	
	<xhtml:h2>Configuretion (root) Element</xhtml:h2>
	
	<xhtml:p>A configuration element consists of optional renderer
		elements, appender elements, categories and an optional root
		element.</xhtml:p>
	
	<define name="log4php.configuration">
		<ref name="attlist.configuration"/>
		<interleave>
			<zeroOrMore>
				<ref name="log4php.renderer"/>
			</zeroOrMore>
			<zeroOrMore>
				<ref name="log4php.appender"/>
			</zeroOrMore>
			<zeroOrMore>
				<choice>
					<ref name="category"/>
					<ref name="logger"/>
				</choice>
			</zeroOrMore>
			<optional>
				<ref name="root"/>
			</optional>
			<optional>
				<ref name="categoryFactory"/>
			</optional>
		</interleave>
	</define>
	
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	
	<xhtml:p>The "threshold" attribute takes a level value such that all
		logging statements with a level equal or below this value are
		disabled.</xhtml:p>
	<xhtml:p>Setting the "debug" enable the printing of internal log4j logging statements.
		By default, debug attribute is "null", meaning that we not do touch
		internal log4j logging settings. The "null" value for the threshold
		attribute can be misleading. The threshold field of a repository
		cannot be set to null. The "null" value for the threshold attribute
		simply means don't touch the threshold field, the threshold field
		keeps its old value.</xhtml:p>
	<xhtml:p>The "null" value in debug means "turn off debugging"</xhtml:p>
 
	<define name="attlist.configuration" combine="interleave">
    <optional>
      <attribute name="threshold" a:defaultValue="null">
        <choice>
          <value>all</value>
          <value>debug</value>
          <value>info</value>
          <value>warn</value>
          <value>error</value>
          <value>fatal</value>
          <value>off</value>
          <value>null</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="debug" a:defaultValue="null">
        <choice>
          <value>true</value>
          <value>false</value>
          <value>null</value>
        </choice>
      </attribute>
    </optional>
  </define>

	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	
	<xhtml:h2>Renderers</xhtml:h2>
	
	<xhtml:p>renderer elements allow the user to customize the conversion of message objects to String.</xhtml:p>
	
	<define name="log4php.renderer">
		<element name="log4php:renderer">
			<ref name="attlist.renderer"/>
			<empty/>
		</element>
	</define>
	
	<define name="attlist.renderer" combine="interleave">
		<attribute name="renderedClass"/>
		<attribute name="renderingClass"/>
	</define>
	
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
	
	<xhtml:h2>Appenders</xhtml:h2>
	
	<xhtml:p>Appenders must have a name and a class. Appenders may contain an error handler,
		a layout, optional parameters and filters. They may also reference (or include) other
		appenders. error handler tag has no effects since log4php does not handle errors.</xhtml:p>

	<define name="log4php.appender">
		<element name="log4php:appender">
			<ref name="attlist.appender"/>
			<optional>
				<ref name="errorHandler"/>
			</optional>
			<zeroOrMore>
				<ref name="param"/>
			</zeroOrMore>
			<optional>
				<ref name="layout"/>
			</optional>
			<zeroOrMore>
				<ref name="filter"/>
			</zeroOrMore>
			<zeroOrMore>
				<ref name="appender-ref"/>
			</zeroOrMore>
		</element>
	</define>
	
	<define name="attlist.appender" combine="interleave">
		<attribute name="name">
			<data type="ID"/>
		</attribute>
		<attribute name="class"/>
	</define>
	
	<define name="layout">
		<element name="log4php:layout">
			<ref name="attlist.layout"/>
			<zeroOrMore>
				<ref name="param"/>
			</zeroOrMore>
		</element>
	</define>
	
	<define name="attlist.layout" combine="interleave">
    <attribute name="class"/>
  </define>

	<define name="filter">
  	<element name="log4php:filter">
      <ref name="attlist.filter"/>
      <zeroOrMore>
        <ref name="param"/>
      </zeroOrMore>
    </element>
  </define>

	<define name="attlist.filter" combine="interleave">
    <attribute name="class"/>
  </define>
  
	<define name="param">
  	<element name="log4php:param">
      <ref name="attlist.param"/>
      <empty/>
    </element>
  </define>
  
	<define name="attlist.param" combine="interleave">
    <attribute name="name"/>
    <attribute name="value"/>
  </define>
  
	<define name="priority">
  	<element name="log4php:priority">
      <ref name="attlist.priority"/>
      <empty/>
    </element>
  </define>
  
	<define name="attlist.priority" combine="interleave">
    <attribute name="value"/>
  </define>
  <define name="level">
  	<element name="log4php:level">
      <ref name="attlist.level"/>
      <empty/>
    </element>
  </define>
  <define name="attlist.level" combine="interleave">
    <attribute name="value"/>
  </define>
  <!-- If no level element is specified, then the configurator MUST not -->
  <!-- touch the level of the named logger. -->
  <define name="logger">
  	<element name="log4php:logger">
      <ref name="attlist.logger"/>
      <optional>
        <ref name="level"/>
      </optional>
      <zeroOrMore>
        <ref name="appender-ref"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.logger" combine="interleave">
    <attribute name="name">
      <data type="ID"/>
    </attribute>
    <optional>
      <attribute name="additivity" a:defaultValue="true">
        <choice>
          <value>true</value>
          <value>false</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="appender-ref">
  	<element name="log4php:appender-ref">
      <ref name="attlist.appender-ref"/>
      <empty/>
    </element>
  </define>
  <define name="attlist.appender-ref" combine="interleave">
    <attribute name="ref">
      <data type="IDREF"/>
    </attribute>
  </define>
  <!-- If no priority element is specified, then the configurator MUST not -->
  <!-- touch the priority of root. -->
  <!-- The root category always exists and cannot be subclassed. -->
  <define name="root">
  	<element name="log4php:root">
      <ref name="attlist.root"/>
      <zeroOrMore>
        <ref name="param"/>
      </zeroOrMore>
      <optional>
        <choice>
          <ref name="priority"/>
          <ref name="level"/>
        </choice>
      </optional>
      <zeroOrMore>
        <ref name="appender-ref"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.root" combine="interleave">
    <empty/>
  </define>
  <!-- ==================================================================== -->
  <!-- A logging event -->
  <!-- ==================================================================== -->
  <define name="log4php.eventSet">
    <element name="log4php:eventSet">
      <ref name="attlist.log4php.eventSet"/>
      <zeroOrMore>
        <ref name="log4php.event"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.log4php.eventSet" combine="interleave">
    <optional>
      <attribute name="version" a:defaultValue="0.3">
        <choice>
          <value>0.2</value>
          <value>0.3</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="includesLocationInfo" a:defaultValue="true">
        <choice>
          <value>true</value>
          <value>false</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="log4php.event">
    <element name="log4php:event">
      <ref name="attlist.log4php.event"/>
      <ref name="log4php.message"/>
      <optional>
        <ref name="log4php.locationInfo"/>
      </optional>
    </element>
  </define>
  <!-- The timestamp format is application dependent. -->
  <define name="attlist.log4php.event" combine="interleave">
    <attribute name="logger"/>
    <attribute name="level"/>
    <attribute name="thread"/>
    <attribute name="timestamp"/>
  </define>
  <define name="log4php.message">
    <element name="log4php:message">
      <ref name="attlist.log4php.message"/>
      <text/>
    </element>
  </define>
  <define name="attlist.log4php.message" combine="interleave">
    <empty/>
  </define>
  <define name="log4php.NDC">
    <element name="log4php:NDC">
      <ref name="attlist.log4php.NDC"/>
      <text/>
    </element>
  </define>
  <define name="attlist.log4php.NDC" combine="interleave">
    <empty/>
  </define>
  <define name="log4php.locationInfo">
    <element name="log4php:locationInfo">
      <ref name="attlist.log4php.locationInfo"/>
      <empty/>
    </element>
  </define>
	
	<define name="attlist.log4php.locationInfo" combine="interleave">
		<attribute name="class"/>
		<attribute name="method"/>
		<attribute name="file"/>
		<attribute name="line"/>
	</define>
	
	<define name="category" combine="choice">
		<notAllowed/>
	</define>
	
	<define name="categoryFactory" combine="choice">
		<notAllowed/>
	</define>
	
	<define name="errorHandler" combine="choice">
		<notAllowed/>
	</define>
	
</grammar>
