Anyhow, in order to at least have context-sensitive tag completion, I decided to quickly roll a RelaxNG based grammar for it. That way, I can stick it into Emac's nxml-mode, and get some support for editing the files. I did it by hand, so some errors might have sneaked in, but I will update it once I find them.
This is the RelaxNG grammar:
<!--
Copyright (c) 2009, Wilfred Springer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="http://jakarta.apache.org/log4j/">
<start>
<choice>
<ref name="configuration"/>
<ref name="eventSet"/>
</choice>
</start>
<define name="configuration">
<element name="configuration">
<optional>
<attribute name="threshold">
<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">
<choice>
<value>true</value>
<value>false</value>
<value>null</value>
</choice>
</attribute>
</optional>
<zeroOrMore><ref name="renderer"/></zeroOrMore>
<zeroOrMore><ref name="appender"/></zeroOrMore>
<zeroOrMore>
<choice>
<ref name="category"/>
<ref name="logger"/>
</choice>
</zeroOrMore>
<optional><ref name="root"/></optional>
<optional><ref name="categoryFactory"/></optional>
</element>
</define>
<define name="appender">
<attribute name="name">
<data type="ID"/>
</attribute>
<attribute name="class">
<text/>
</attribute>
<element name="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="renderer">
<element name="renderer">
<attribute name="renderedClass"><text/></attribute>
<attribute name="renderingClass"><text/></attribute>
</element>
</define>
<define name="layout">
<element name="layout">
<attribute name="class"><text/></attribute>
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
</element>
</define>
<define name="filter">
<element name="filter">
<attribute name="class"><text/></attribute>
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
</element>
</define>
<define name="errorHandler">
<attribute name="class"><text/></attribute>
<element name="errorHandler">
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
<optional>
<ref name="root-ref"/>
</optional>
<zeroOrMore>
<ref name="logger-ref"/>
</zeroOrMore>
<zeroOrMore>
<ref name="appender-ref"/>
</zeroOrMore>
</element>
</define>
<define name="root-ref">
<element name="root-ref">
<empty/>
</element>
</define>
<define name="logger-ref">
<element name="logger-ref">
<attribute name="ref"><data type="IDREF"/></attribute>
<empty/>
</element>
</define>
<define name="param">
<element name="param">
<attribute name="name"><text/></attribute>
<attribute name="value"><text/></attribute>
<empty/>
</element>
</define>
<define name="priority">
<element name="priority">
<optional>
<attribute name="class"><text/></attribute>
</optional>
<attribute name="value"><text/></attribute>
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
</element>
</define>
<define name="level">
<element name="level">
<optional>
<attribute name="class"><text/></attribute>
</optional>
<attribute name="value"><text/></attribute>
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
</element>
</define>
<define name="category">
<element name="category">
<optional>
<attribute name="class"><text/></attribute>
</optional>
<attribute name="name"><text/></attribute>
<optional>
<attribute name="additivity">
<choice>
<value>true</value>
<value>false</value>
</choice>
</attribute>
</optional>
<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="logger">
<element name="logger">
<attribute name="name"><data type="ID"/></attribute>
<attribute name="additivity">
<optional>
<choice>
<value>true</value>
<value>false</value>
</choice>
</optional>
</attribute>
<optional>
<ref name="level"/>
</optional>
<zeroOrMore>
<ref name="appender-ref"/>
</zeroOrMore>
</element>
</define>
<define name="categoryFactory">
<element name="categoryFactory">
<attribute name="class"><text/></attribute>
<zeroOrMore>
<ref name="param"/>
</zeroOrMore>
</element>
</define>
<define name="appender-ref">
<element name="appender-ref">
<attribute name="ref"><data type="IDREF"/></attribute>
<empty/>
</element>
</define>
<define name="root">
<element name="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="eventSet">
<element name="eventSet">
<zeroOrMore>
<ref name="event"/>
</zeroOrMore>
</element>
</define>
<define name="event">
<element name="event">
<ref name="message"/>
<optional>
<ref name="NDC"/>
</optional>
<optional>
<ref name="throwable"/>
</optional>
<optional>
<ref name="locationInfo"/>
</optional>
</element>
</define>
<define name="message">
<element name="message">
<choice>
<text/>
<empty/>
</choice>
</element>
</define>
<define name="NDC">
<element name="NDC">
<choice>
<text/>
<empty/>
</choice>
</element>
</define>
<define name="throwable">
<element name="throwable">
<choice>
<text/>
<empty/>
</choice>
</element>
</define>
<define name="locationInfo">
<attribute name="class"><text/></attribute>
<attribute name="method"><text/></attribute>
<attribute name="file"><text/></attribute>
<attribute name="line"><text/></attribute>
</define>
</grammar>
This is the compact syntax grammar:
# Copyright (c) 2009, Wilfred Springer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
default namespace = "http://jakarta.apache.org/log4j/"
start = configuration | eventSet
configuration =
element configuration {
attribute threshold {
"all"
| "debug"
| "info"
| "warn"
| "error"
| "fatal"
| "off"
| "null"
}?,
attribute debug { "true" | "false" | "null" }?,
renderer*,
appender*,
(category | logger)*,
root?,
categoryFactory?
}
appender =
attribute name { xsd:ID },
attribute class { text },
element appender {
errorHandler?, param*, layout?, filter*, appender-ref*
}
renderer =
element renderer {
attribute renderedClass { text },
attribute renderingClass { text }
}
layout =
element layout {
attribute class { text },
param*
}
filter =
element filter {
attribute class { text },
param*
}
errorHandler =
attribute class { text },
element errorHandler { param*, root-ref?, logger-ref*, appender-ref* }
root-ref = element root-ref { empty }
logger-ref =
element logger-ref {
attribute ref { xsd:IDREF },
empty
}
param =
element param {
attribute name { text },
attribute value { text },
empty
}
priority =
element priority {
attribute class { text }?,
attribute value { text },
param*
}
level =
element level {
attribute class { text }?,
attribute value { text },
param*
}
category =
element category {
attribute class { text }?,
attribute name { text },
attribute additivity { "true" | "false" }?,
param*,
(priority | level)?,
appender-ref*
}
logger =
element logger {
attribute name { xsd:ID },
attribute additivity { ("true" | "false")? },
level?,
appender-ref*
}
categoryFactory =
element categoryFactory {
attribute class { text },
param*
}
appender-ref =
element appender-ref {
attribute ref { xsd:IDREF },
empty
}
root = element root { param*, (priority | level)?, appender-ref* }
eventSet = element eventSet { event* }
event = element event { message, NDC?, throwable?, locationInfo? }
message = element message { text | empty }
NDC = element NDC { text | empty }
throwable = element throwable { text | empty }
locationInfo =
attribute class { text },
attribute method { text },
attribute file { text },
attribute line { text }
0 comments:
Post a Comment