I'm trying to constrain the 'role' attr to be one of two values. 
Initially, I'm doing this on the <phrase> element, but eventually I want 
to do this on all elements.

This is in DocBook 5, and I'm using the non-compact RNG syntax for our 
customization.  There's an example in Walsh and Muellner's "DocBook 5.0" 
document in section 5.10, but it's in the compact syntax:
    namespace db = "http://docbook.org/ns/docbook";

    include "docbook.rnc" {
       db.procedure.role.attribute = attribute role
              { "required" | "optional" }
    }

OK, I thought, can't be too hard...

Several hours later, and a good deal of searching on the web, I still 
can't get it to work.  My non-compact syntax schema fragment looks like 
this (omitting the 'include docbook.rng' part):
    <define name="db.phrase.role.attribute" >
      <attribute name="role">
        <choice>
          <value type="string">tech</value>
          <value type="string">nontechy</value>
        </choice>
      </attribute>
    </define>
(The funny spelling of "nontechy" here is intentional: the value in the 
document is actually "nontech", so what I'm trying to do is to ensure 
that this customization signals a warning for any 'role' attrs in the 
text whose values don't match the above schema fragment.)

Using the above code, XMLmind signals an error about the customization:
     multiple definitions of "db.phrase.role.attribute"
     without "combine" attribute
I'm not sure how the "combine" attr is supposed to be represented in the 
compact syntax, but clearly it's required in the non-compact syntax. 
However, I have tried both possible values of this attr, without success.

Specifically, if I add 'combine="interleave"', to the <define...> tag, 
then I get the error
     duplicate attribute "role"

If I instead add 'combine="choice"' I don't get an error, but I do get 
some odd behavior.  For existing <phrase role="nontech"> tags, there is 
no warning, despite the fact that this spelling does not conform to the 
above schema.  If I create a *new* <phrase> tag, the attributes pane in 
XXE shows me two role attributes: one is just 'role', and appears to be 
text-valued (that is, it simply allows typing in a value); the other is 
labeled 'role-2', and has a drop-down with the above two values ('tech' 
and 'nontechy').  (Sometimes 'role' and 'role-2' are reversed, I'm not 
sure when this happens.)  Neither behavior is what I want: I want it to 
flag existing 'nontech' roles as warnings (because they're misspelled 
according to the above schema fragment); and for new <phrase> tags, I 
want just a 'role' attr (with two choices), not a 'role' attr and a 
'role-2' attr.

Do you have some sample schema code in which an attr which is defined in 
DocBook 5 as text-valued (like 'role') is customized to allow only one 
of an enumerated set of values?
-- 
    Mike Maxwell
    What good is a universe without somebody around to look at it?
    --Robert Dicke, Princeton physicist

Reply via email to