[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: [relax-ng-comment] Duplicate Attributes
If you have say a
<name ns="">foo</name>
and
<anyName><except><nsName ns=""/></except></anyName>
then there is no conflict because there is no name that is a member of both
name classes: the name class <name ns="">foo</name> contains a single name,
which has local name "foo" and namespace URI ""; since this name belongs to
<nsName ns=""/>, it does not belong to <anyName><except><nsName
ns=""/></except></anyName>.
In order to implement the rule on duplicate attributes you have to be able
to figure out whether the intersection of two arbitrary name classes is
empty. Here's some pseudo-code for one way to do it:
boolean overlaps(NameClass nc1, NameClass nc2) {
for x in walk(nc1) union walk(nc2)
if (contains(nc1, x) and contains(nc2, x))
return true;
return false
}
String MAGIC = "\0" // any string that is not a legal URI nor a legal name
Set(Name) walk(NameClass nc) {
switch (NameClass nc) {
case <name ns="x">y</name>: return { name(x, y) };
case <nsName ns="x"/> : return { name(x, MAGIC) };
case <nsName ns="x"><except>e</except></nsName>:
return { name(x, MAGIC) } union walk(e);
case <anyName/> : return { name(MAGIC, MAGIC) };
case <anyName><except>e</except></anyName>:
return { name(MAGIC, MAGIC) } union walk(e);
}
}
--On 02 November 2001 18:38 +1100 Gary Stephenson <garys@ihug.com.au> wrote:
> Hi all,
>
> I am currently implementing a Relax NG processor in the Xbase++ language
> (using the pytrex.py module by James Tauber as an initial guide).
>
> I am having trouble with the restriction in section 7.3 regarding
> Duplicate Attributes.
>
> I find that when attempting to validate the rngSchema.rng file, I get a
> duplicate attribute error, wherby by a "name" attribute in one branch of a
> group is clashing with an "anyname" (with exceptions) attribute in the
> other. The group in question is the child of the element child of the
> "define-element" define. That is, after transforming to the simplified
> syntax, I get:
>
> ( DEFINE - define-element :
> ( ELEMENT
>
> ( EXPANDED-NAME : {,define} )
> ( T_Group :
> ( ATTRIBUTE :
> ( EXPANDED-NAME : {,name} )
> ( DATA : NCName )
> )
> ( T_Group :
> ( T_Group :
> ( T_Choice :
> ( T_Empty )
> ( ATTRIBUTE :
> ( EXPANDED-NAME : {,combine} )
> ( T_Choice :
> ( VALUE : choice )
> ( VALUE : interleave )
> )
> )
> )
> ( T_Group :
> ( T_Choice :
> ( T_Empty )
> ( ATTRIBUTE :
> ( EXPANDED-NAME : {,ns} )
> ( DATA : anyURI )
> )
> )
> ( T_Group :
> ( T_Choice :
> ( T_Empty )
> ( ATTRIBUTE :
> ( EXPANDED-NAME :
> {,datatypeLibrary} ) ( DATA :
> anyURI )
> )
> )
> ( T_Choice :
> ( T_Empty )
> ( T_OneOrMore :
> ( ATTRIBUTE :
> ( ANY-NAME - except :
> ( T_NameClass_Except :
> ( T_NSName )
> ( T_NSName )
> )
> )
> ( T_Text )
>
> etc..
>
> What is wrong here. Should the "anyName-with-exceptions" attribute match
> the attribute "name"? If not, why not? If so, then what else might I be
> doing wrong?
>
> many tias,
>
> gary
>
>
> ----------------------------------------------------------------
> To subscribe or unsubscribe from this elist use the subscription
> manager: <http://lists.oasis-open.org/ob/adm.pl>
>
>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC