Classic CONREF

From W3C Wiki

Classic `CONREF` (a co-constraint use case)

If a particular pair of attributes) have values, then the element must be empty. If they have no values, then the element must have content (obeying a normal content model), and certain other attributes must be present.

source: Marcos Mayorga [1]


Other use cases: Co-constraint Use Cases

Description

Consider the following XML:


    <mycontainer>
            <myelement name="n1" a="0" b="1">
                    <mynestedelement c="2"/>
            </myelement>
            <myelement name="n2" a="0" b="1">
                    <mynestedelement c="2"/>
            </myelement>
            <myelement href="doc2.xml" path="mycontainer/myelement#n3"/>
    </mycontainer>


   where attributes name, a and b 
   are required and mynestedelement is also
   required. At the other side, attributes href and path 
   are required, and have simple content.

Analysis

(Add your analysis here; see your name in pixels!)

MSM

The title given to this use case is mildly misleading; this is a more elaborate constraint than the `#CONREF` keyword for attributes provided in SGML.

The SGML `CONREF` keyword could be applied to a single attribute; it had the effect that if a value was specified for that attribute, the element in the document instance would be / could be / was required to be empty. As Charles Goldfarb describes it in the SGML Handbook (p. 159):

 A "content reference attribute" ... is an attribute with the 
 property that, if it is specified explicitly in a start-tag
 (rather than defaulted), then the content of that instance
 of the element is empty.  Instead, the attribute value is 
 used by the application (in some unspecified way) to produce
 content data.
 ... 
 A typical use of a content reference attribute is to allow the user
 to decide for any instance of an element, such as a figure, whether
 it will have normal SGML text content, or whether data in an
 external entity (such as a scanned image) will be used.

The use case outlined by the original poster is more complex, since it involves not one but two attributes (path and href) which must be supplied when the element is empty, and since it affects not just the content but also the other attributes.

Possible solutions

Relax NG

Schematron

Check clause

SchemaPath

Conditional Type