[relaxng-user] E "oneOrMore" contains "group" contains "attribute"
again...
Bob Foster
bob at objfac.com
Mon May 3 22:17:50 ICT 2004
Hutchison, Ben wrote:
> I have some further questions related to the issues I had last week in a
> thread "Jing & Trang errors when processing RNC grammar".
>
> I have read 7.1.2 of the spec and now appreciate the above pattern is
> forbidden. However, what I have not found is any examples showing
> alternatives approaches where you do need to specify that attributes be
> present on members of a repeated subgroup.
Attributes aren't present on members of a repeated subgroup, attributes
are present in an element.
> Bob Foster's suggested fix to my original schema is shown below. Note
> that the NamedElementAttributes are specified for ConfigGroups. I also
> require a name attribute to be present for all elements in the
> ConfigValue group as well, but when I include this it becomes an illegal
> grammar. At the same time, I don't want a top-level blanket requirement
> of a name attribute for every element in the grammar, because eg array
> elements are not named.
You mean that you want NamedElementAttributes present in the
StringValue, IntValue, FloatValue, BooleanValue, Map and Array elements?
Add it to the definitions of these elements.
> Does anyone have a reliable approach or "algorithm" for specifying
> attributes in these sorts of situations?
Write out what you mean. Then factor, if possible.
Bob Foster
> Regards
> Ben
>
> namespace rng = "http://relaxng.org/ns/structure/1.0"
> datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
>
> start = element ConfigRoot { ConfigGroup* }
>
> NamedElementAttributes =
> attribute name { text },
> attribute platform { text }?
>
> StringValue = element StringValue { xsd:string }
> IntValue = element IntValue { xsd:integer }
> FloatValue = element FloatValue { xsd:float }
> BooleanValue = element BooleanValue { xsd:boolean } PrimitiveValue =
> (StringValue | IntValue | FloatValue | BooleanValue)
>
> Map = element Map { (MapEntry)* }
> MapEntry = element MapEntry { PrimitiveValue }
> Array = element Array { (PrimitiveValue)* }
>
> ConfigValue = ( PrimitiveValue | Map | Array )
>
> ConfigGroupEntry = (ConfigGroup | ConfigValue)
>
> ConfigGroup = element ConfigGroup {
> ConfigGroupEntry*,
> NamedElementAttributes
> }
More information about the relaxng-user
mailing list