OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: Difference for attribute values


Jeni Tennison wrote:
 
> Excluding attribute values:
> 
> I'd like to be able to restrict the contents of the xs:restriction
> element based on its base attribute, but only for certain values. So
> if its base attribute is "xs:decimal" then it could contain
> xs:totalDigits but if it's "xs:string" then it can't, and so on.
> However, if it's not a name in the 'xs' namespace, then I want to
> allow any content.
> 
> Best would be to exclude all QName values with a particular namespace,
> but XMLSchema-datatypes doesn't offer that as a facet (and therefore
> RELAX NG doesn't have it as a parameter). I don't want to use the
> 'pattern' parameter to test the names because that would undermine the
> namespace awareness of the schema. I thought I could create a pattern
> that didn't match particular enumerated values, but I can't find a way
> to do so.  What I'm looking for is something like:
> 
> <choice>
>    <group>
>       <attribute name="foo">
>          <value>bar</value>
>       </attribute>
>       <element name="bar"><empty /></element>
>    </group>
>    <group>
>       <attribute name="foo">
>          <!-- not current RELAX NG -->
>          <not>
>             <value>bar</value>
>          </not>
>          <!-- /not current RELAX NG -->
>       </attribute>
>       <element name="baz"><empty /></element>
>    </group>
> </choice>
> 
> This use case would imply that the difference element would be useful
> outside name classes as well.

The TC has discussed this issue in the past and decided not to add
<difference> to 1.0 mainly for implementation reasons.  Supporting
<difference> in full generality for patterns makes it hard to build an
automaton.

However, I have encountered similar use cases to the one you
encountered, and I'm beginning to feel that needing to use <difference>
for attribute values is going to be a very common requirement.  Any time
that you use an attribute value as qualifying the element name, you have
as much need to use <difference> for attribute values as you do for name
classes.

I am wondering whether we could allow <difference> in a very limited
fashion that would be sufficient to support this use case.  For example,
allowing <difference> where each operand matches exactly one string. 
This would be easy to implement.  Wouldn't it also have the benefit of
making the language as a whole closed under difference?

James




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC