On Fri, Jan 9, 2009 at 9:06 PM, nico_debeissat <[email protected]> wrote:
> hello,
>
> I have the following issue :
> I want to specify that XML :
>
> <markup value="A B C">
>
> I want the values inside the list to be one of A, B, C or D. That can
> be empty, or any number of values.
>
> If I follow that tutorial
> http://relaxng.org/tutorial-20011203.html#IDAK0YR, I would specify
> that like that :
>
> <rng:element name="markup">
>   <rng:attribute name="value">
>      <rng:list>
>         <rng:zeroOrMore>
>            <rng:choice>
>               <rng:value>A</rng:value>
>               <rng:value>B</rng:value>
>               <rng:value>C</rng:value>
>               <rng:value>D</rng:value>
>            </rng:choice>
>         </rng:zeroOrMore>
>      </rng:list>
>   </rng:attribute>
> </rng:element>

That's correct.

> but, looking there :
> http://www.thaiopensource.com/relaxng/derivative.html :
> listDeriv :: Context -> Pattern -> [String] -> Pattern
> listDeriv _ p [] = p
> listDeriv cx p (h:t) = listDeriv cx (textDeriv cx p h) t
>
> I have the impression the <rng:zeroOrMore> is useless.

No, you need it.  Remember you have:

textDeriv cx (List p) s =
  if nullable (listDeriv cx p (words s)) then Empty else NotAllowed


In other words, to match a string against a list pattern, split the
string into a sequence of tokens, and match the sequence of tokens
against the content of <list/>.

James

Reply via email to