Re: [xml] RelaxNG Question



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/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]