[relaxng-user] prep.xsl
James Clark
jjc at jclark.com
Tue Sep 30 08:56:59 ICT 2003
Cheng-Chang Wu wrote:
> My program can still not handle all of the relaxng
> constructs, but it can already read the relaxng file I
> am using in my project.
>
> I've had problems to determine the nullability of ref
> element. In section 4.19 of the specification it says
> one can replace the expandable ref element with its
> definition. THIS MUST NOT RESULT IN A LOOP. I can't
> grasp this well.
Typically, an implementation represents each type of pattern by an
object. The schema is thus initially a tree of objects. At a convenient
point, the implementation typically resolves references: it checks that
there's a define for each ref and makes each ref pattern point directly
to that define, and each grammar becomes just a reference to its start
pattern. At this stage, you have a directed graph of objects. This
graph may have cycles (where every cycle passes through a ref pattern).
What your implementation has to do is check that every cycle passes
through an element pattern. You can do this by having a recursive
function with a single depth parameter that walks the graph, recording
at each ref node the depth at which it last visited the node, and
incrementing the depth when it passes through an element node.
See com.thaiopensource.relaxng.impl.RefPattern.checkRecursion() in Jing.
James
More information about the relaxng-user
mailing list