List Info

Thread: RelaxNG Question




RelaxNG Question
user name
2006-12-19 22:37:20
Because I haven't found a more appropriate venue for this
question.

In RelaxNG, let's say that you have 2 attributes. And you
would like to 
make a named pattern for them, such that it matches the
attributes if 
one of them or both of them are found. Is it possible to
specify this 
without saying:

<choice>
    <group>
       <ref name="attrib1"/>
       <ref name="attrib2"/>
    </group>
    <ref name="attrib1"/>
    <ref name="attrib2"/>
</choice>


Because I have a schema now where I would want to have 3
(and in some 
cases, possibly more) of these defined. That would require a
lot of 
extraneous manipulation.

So, does RelaxNG have something for this?
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
RelaxNG Question
user name
2006-12-20 11:20:19
On Tue, Dec 19, 2006 at 02:37:20PM -0800, Jason McKesson
wrote:
> Because I haven't found a more appropriate venue for
this question.
> 
> In RelaxNG, let's say that you have 2 attributes. And
you would like to 
> make a named pattern for them, such that it matches the
attributes if 
> one of them or both of them are found. Is it possible
to specify this 
> without saying:
> 
> <choice>
>     <group>
>        <ref name="attrib1"/>
>        <ref name="attrib2"/>
>     </group>
>     <ref name="attrib1"/>
>     <ref name="attrib2"/>
> </choice>
> 
> 
> Because I have a schema now where I would want to have
3 (and in some 
> cases, possibly more) of these defined. That would
require a lot of 
> extraneous manipulation.
> 
> So, does RelaxNG have something for this?

  Hum, using the property that you can have a given
attribute only once per node
inverting the group and using optional may work

  <group>
    <choice>
      attrib1
      attrib2
      ...
      attribn
    <choice>
    <optional>attrib1</optional>
    <optional>attrib2</optional>
    ...
    <optional>attribn</optional>
  </group>

should work and stay linear in expression complexity

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )