cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alfred Nathaniel <>
Subject Re: [RT] Improved matching & selecting
Date Sun, 10 Dec 2006 23:29:31 GMT
On Fri, 2006-12-08 at 20:14 -0800, Mark Lundquist wrote:
> On Dec 8, 2006, at 2:39 PM, Alfred Nathaniel wrote:
> > Could you try to write a Relax NG schema sniplet (preferable in compact
> > notation) for validating your proposed syntax?
> OK, I think this is it.  Just a first swipe at it, I haven't tried 
> validating anything against it, I've just run it through trang and 
> that's all so far.  Not much to it, huh? :-)
> Cheers,
> —ml—
> sitemap-matcher-engine.rnc
> ===================

I also had a go at it to validate this mini-example:


  <match value="{request:URI}" path="foobar/**/*">
    <read src="..."/>

  <match value="{request:URI}">
    <when regexp="foo(bar|baz)">
      <read src="..."/>
    <when path="*/**">
      <read src="..."/>
      <read src="..."/>

  <match type="wildcard" pattern="**">
    <read src="..."/>


grammar {

     start = Pipeline

     Pipeline = element pipeline { PipelineComponent* }

     PipelineComponent = Match | Read

     Match = LegacyMatch | SimpleMatch | ComplexMatch

     LegacyMatch = element match { attribute type{text}?, attribute
pattern{text}, PipelineComponent* }

     SimpleMatch = element match { attribute value{text}, MatchFunction,
PipelineComponent* }

     ComplexMatch = element match { attribute value{text}, When+,
Otherwise? }

     When = element when { MatchFunction, PipelineComponent* }

     Otherwise = element otherwise { PipelineComponent* }

     MatchFunction = attribute path{text} | attribute regexp{text}

     Read = element read { attribute src { text } }

Simple enough, but only in Relax NG.  This grammar cannot be transformed
into a DTD.  There are two problems which hinder that.  First the same
element name for different productions (major), and second the mutual
exclusion of match functions (minor).

I am a big fan of Relax NG but I also learned that support for
schema-driven editing with DTDs is still much more wide-spread.
Therefore I think that we should give up light-heartly the possibility
to have a sitemap DTD.

NB I would only forsee wildcard and regexp functions.  Equals and
contains can be trivially expressed as wildcards.  Otherwise one should
also forsee starts-with and ends-with.

Cheers, Alfred.

View raw message