On 11/22/2014 04:48 AM, Mike Maxwell wrote:
We have munged the DocBook rng (and css) files for some extra elements
we need.  One of these new elements, which we call <inlineExample>
(there's actually a namespace, but I assume that's irrelevant), has an
attribute which allows a choice among three values, expressed as follows
in the .rng schema:

   <element name="inlineExample">
     ...
     <optional>
       <attribute name="align">
         <choice>
           <value type="string">horizontal</value>
           <value type="string">vertical</value>
           <value type="string">tabbed</value>
         </choice>
       </attribute>
     </optional>
     <oneOrMore>
       <ref name="langData">
       ...

In XXE, this attribute always appears in the Attributes pane for
elements of this type.  However, the attribute sometimes has a dropdown
in the Value column allowing the user to select one of these three
values, as I would expect--but sometimes the Value column contains only
a fill-in-the-blank text box, with no dropdown.

I looked at the underlying XML file to see what would explain why some
of these elements display the drop-down for the attribute and some
don't.  It appears that the difference is whitespace between XML
elements: if there's no whitespace between the <inlineExample> tag and
its first daughter element's tag, the dropdown appears; otherwise not.
(No, I don't understand why that would cause a problem, but it's the
only difference I can find.)

The schema does not allow for any text element between the
<inlineExample> element and its first daughter (the <langData> in the
schema above); but I would not have expected whitespace to count as a
text element.

Non-ignoreable whitespace indeed counts as a text element. However, once a document has been loaded, there must be no ignoreable whitespace text nodes whatsoever left in the document. Otherwise this clearly creates problems, which could explain the issues you have.

Ignoreable whitespace is automatically stripped by XXE at document load time. If the document being loaded is structurally invalid (or, in the case of RELAX NG, has complex content models; e.g. text allowed after some child elements but disallowed before other child elements; see below), then XXE may fail to do this.




And indeed the schema validation that XXE performs does
not report this as an error.  Also, XXE sometimes inserts whitespace in
there in the form of a newline and some space characters.

I experimented with adding a space character between an <inlineExample>
tag and the following <langData> tag in a text editor, and that indeed
prevented the dropdown from appearing.  I wish I could say that removing
whitespace would cause the dropdown to appear, but that only seems to
work in some cases (from what I can tell, in the cases where I inserted
the space character in the first place).

Could this possibly be the reason for the non-appearance of the dropdown
allowing the choice of values?  If not, what should we be looking for?

We're using XXE 6.1.0, under Windows 7.

Just a guess. Cannot do much without having a working sample document using your DocBook RELAX NG customization.

May be XXE simply cannot cope with the content model of your inlineExample (which does not mean that your inlineExample elements are invalid according to the RELAX NG schema). When this is the case XXE locally puts itself in "lenient mode". Hence, no dropdown.

How to check whether XXE can cope with the content model of your elements?

1) May be you can see inlineExample or its parent element underlined in orange or red in the node path bar. When this is the case, this means that you have lost XXE.

2) Pressing Shift-F1 (Help|Show Content model) with inlineExample or its parent selected may also give you useful information. For example, inlineExample or its parent could be marked as "Using these attributes or child elements may cause the content model of this element to become ambiguous."



--> My suggestion: change the content model of inlineExample and make it simpler, especially in terms of where text is allowed.

RELAX NG has not been designed with "element typing" in mind. RELAX NG has been designed with expressivity, simplicity and streaming validation in mind.

Quickly determining the type of an element simply by looking at its contents and at its ancestors is critical to implement an schema-directed editor like XXE.

This is a quite difficult task in the case of RELAX NG.

We think that our implementation is sufficient for the vast majority of cases. We do not plan to improve this implementation in the near future (unless the newest additions to DocBook 5.1 forces us to do it).



Reference
---------

The support of RELAX NG schemas in XXE, its specificities and its limitations are documented in this document:

http://www.xmlmind.com/xmleditor/_distrib/doc/rngsupport/index.html





--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to