Attached is a RELAX NG schema that does the same.

Why? Just for the hell of it ;) And because RNG is very cool.. simple,
powerful, readable.

http://www.oasis-open.org/committees/relax-ng/tutorial.html

There's also an Ant script to run it


--Jeff

On Wed, Mar 27, 2002 at 06:57:12PM -0800, Daniel Rall wrote:
> A DTD for the Maven project descriptor would answer a lot of these
> questions.  What do you think?
#
# RELAX NG schema for Maven's project descriptor (project.xml) format. Written
# in RNG's non-XML syntax. To validate an XML, you'll need:
#  Non-XML to XML syntax converter:
#   http://www.thaiopensource.com/relaxng/nonxml/
#  A RNG validator, like jing:
#   http://www.thaiopensource.com/relaxng/jing.html
#
# Assuming the above, the commands to validate project.xml would be:
#   export CLASSPATH=$CLASSPATH:rngnx.jar:jing.jar
#   java com.thaiopensource.relaxng.nonxml.Driver project.rnx > project.rng
#   java com.thaiopensource.relaxng.util.Driver project.rng project.xml
#
# Jeff Turner <[EMAIL PROTECTED]>
#

datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes";

start =                         project
project =                       element project {
                                                element name {text},
                                                element id {text},
                                                element currentVersion {text},
                                                element organization {text}?,
                                                element inceptionYear {
                                                        xsd:gYear { pattern="[0-9]{4}" 
}
                                                },
                                                element package {
                                                        xsd:string { pattern="[\S\.]+" 
}
                                                },
                                                element shortDescription {text},
                                                element gumpRepositoryId {text}?,
                                                element description {text}?,
                                                element url {xsd:anyURI},
                                                element cvsWebUrl {xsd:anyURI}?,
                                                element issueTrackingUrl {xsd:anyURI},
                                                element siteAddress {text}?,
                                                element siteDirectory {text}?,
                                                element distributionDirectory {text}?,
                                                distributions?,
                                                branches?,
                                                mailingLists,
                                                developers,
                                                dependencies,
                                                build
                                        }
distributions =         element distributions {
                                                element distribution {
                                                        element version {text},
                                                        element tag {text}
                                                }*
                                        }

branches =                      element branches {
                                                element branch {
                                                        element tag {text}
                                                }*
                                        }
mailingLists =          element mailingLists {
                                                element mailingList {
                                                        element name {text},
                                                        element subscribe {text},
                                                        element unsubscribe {text},
                                                        element archive {text}
                                                }*
                                        }
developers =            element developers {
                                                element developer {
                                                        element name {text},
                                                        element id {text},
                                                        element email {text},
                                                        element organization {text}?
                                                }*
                                        }
dependencies =          element dependencies {
                                                element dependency {
                                                        element name {text},
                                                        element type 
{"required"|"documentation"},
                                                        element version {text},
                                                        element jar {text},
                                                        element url {xsd:anyURI}?

                                                }*
                                        }
build =                         element build {
                                                sourceDirectories,
                                                testSourceDirectories?,
                                                aspectSourceDirectories?,
                                                unitTestClassEntries?,
                                                runtimeTestClassEntries?,
                                                integrationUnitTestClassEntries?,
                                                jarResources?,
                                                jars?
                                        }

sourceDirectories =                     element sourceDirectories {
                                                                element 
sourceDirectory {text}*
                                                        }
testSourceDirectories =         element testSourceDirectories {
                                                                element 
testSourceDirectory {text}*
                                                        }
aspectSourceDirectories =       element aspectSourceDirectories {
                                                                element 
aspectSourceDirectory {text}*
                                                        }
unitTestClassEntries =          element unitTestClassEntries {
                                                                element 
unitTestClassEntry {text}*
                                                        }
runtimeTestClassEntries =       element runtimeTestClassEntries {
                                                                element 
runtimeTestClassEntry {text}*
                                                        }
integrationUnitTestClassEntries = element integrationUnitTestClassEntries {
                                                                        element 
integrationUnitTestClassEntry {text}*
                                                                }
jarResources =          element jarResources {
                                                element jarResource {text}*
                                        }
jars =                          element jars {
                                                element jar {text}*
                                        }
<?xml version="1.0"?>

<project name="validate" default="validate" basedir=".">
    <property name="rnx" value="project.rnx"/>
    <property name="rng" value="project.rng"/>
    <property file="${user.home}/build.properties"/>
    <property name="parser.jar" value="${lib.repo}/xerces.jar"/>
    <property name="jing.jar" value="${lib.repo}/jing.jar"/>
    <property name="rngnx.jar" value="${lib.repo}/rngnx.jar"/>

    <target name="rnx2rng">
        <java 
            classname="com.thaiopensource.relaxng.nonxml.Driver" 
            fork="yes" 
            failonerror="yes"
            output="${rng}">
            <arg line="${rnx}"/>
            <classpath>
                <pathelement location="${rngnx.jar}"/>
                <pathelement location="${parser.jar}"/>
            </classpath>
        </java>
    </target>

    <target name="validate" depends="rnx2rng">

        <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
            <classpath>
                <pathelement location="${jing.jar}"/>
                <pathelement location="${parser.jar}"/>
            </classpath>
        </taskdef>
        <jing rngfile="${rng}">
            <fileset dir="." includes="project.xml"/>
        </jing>
    </target>
</project>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to