I was not able to reproduce any problem using XXE v4.5.1. Here's what I did:

[1] I've re-read Eric van der Vlist's RELAX NG  book --
http://books.xmlschemata.org/relaxng/page2.html -- as a refresher
(highly recommended! As it is often the case, the spec of the standard
is unreadable).

More specifically this chapter: "10.2.2. Merging and Replacing
Definitions"
http://books.xmlschemata.org/relaxng/relax-CHP-10-SECT-2.html#relax-CHP-10-SECT-2.2

[2] I've created my_db5.rng in XXE_install_dir/addon/config/docbook5/:

---
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0";
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes";>
  <include href="rng/V5.0/docbook.rng">
    <define name="db.phrase.role.attribute" >
      <attribute name="role">
        <choice>
          <value type="string">tech</value>
          <value type="string">nontechy</value>
        </choice>
      </attribute>
    </define>
  </include>
</grammar>
---

[3] I've validated this grammar using:

---
$ XXE_install_dir/bin/xmltool validate -s my_db5.rng
---

[4] I've generated a documentation for this grammar using:

---
$ XXE_install_dir/bin/xmltool schemadoc -xxe my_db5.rng /tmp/my_db5
---

This allows to check the possible values of phrase/@role without even
starting XXE. See attached phrase_1i.html (page generated by xmltool
schemadoc)

[5] I've modified XXE_install_dir/addon/config/docbook5/docbook5.xxe to
instruct XXE to use my_db5.rng rather than rng/V5.0/docbook.rng.

Replaced:
---
<relaxng location="rng/V5.0/docbook.rng" />
---
by
---
<relaxng location="my_db5.rng" />
---

[6] Started XXE and converted a piece of text to a phrase element. Added
attribute role to the newly created phrase element. The attribute tool
only allows "tech" and "notechy".

See attached screenshot.



--> I have not the slightest idea of what could have caused your
problems, because:

[a] The combine attribute is not needed, provided the define element is
contained in an include element.

[b] The behavior of XXE is correct when the definition of a phrase is
something like:

element phrase {
   (attribute role { token } |
    attribute role { "tech" | "nontechy" }) &
   ...
}

This indeed gives 2 possible role attributes, each having a different
content model: one is *labeled* "role" and the other is labeled "role-2".




Mike Maxwell wrote:
> 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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20100124/ff0aa8d7/attachment-0001.html
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: db5_role.png
Type: image/png
Size: 105311 bytes
Desc: not available
Url : 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20100124/ff0aa8d7/attachment-0001.png
 

Reply via email to