December 2003
Intermediate to advanced
506 pages
12h 26m
English
As mentioned earlier, named patterns are the only way to represent
recursive
models. We don’t yet have all the building blocks
needed to define a recursive XHTML div element,
for example, but let’s start with a simpler example.
If our library is divided into categories, each having a
title, zero or more embedded
category elements, and zero or more
books, you can write (assuming that named patterns
have been defined for the book element):
<define name="category"> <element name="category"> <element name="title"> <text/> </element> <zeroOrMore> <ref name="category"/> </zeroOrMore> <zeroOrMore> <ref name="book"/> </zeroOrMore> </element> </define>
or:
category = element category{
element title{text},
category *,
book*
}Note that in this case, the recursive reference to the
category named pattern must be optional. Otherwise
the document is required to have an infinite depth!
Read now
Unlock full access