Philippe Nobili wrote:
>  On 10/05/2010 07:22 PM, Hussein Shafie wrote:
>> On 10/05/2010 06:52 PM, Philippe Nobili wrote:
>>>   Dear M. Shafie,
>>>
>>> In our XMLMind configuration, we use<elementTemplate>  element to change
>>> some of the templates for elements in our XML schema. When we add
>>> insert-after(),... buttons, we see the following:
>>>
>>> + When we do not use the @selectable attribute, the new template item is
>>> displayed in the menu in addition to the standard element,  for instance
>>> for our element, which is<menu>: menu(menu). This is in line with what
>>> is in the documentation... but we do not want to see the duplicate
>>> items: menu and menu(menu)
>>>
>>> + When we set @selectable to "override", we expected to see only one
>>> menu item in the generated pulldown; it is effectively what happens, but
>>> then our template is not executed and the default element is generated
>>> instead.
>> -->  This probably happens because inserting the content of your
>> elementTemplate would cause the document to become invalid.
> Dear M. Shafie,
> 
> Yes, this is exactly what happens.
> 
> But in this case this is unfortunate since the invalidity is due to
> mandatory attributes (which then receive the  default value '???' when
> the elements are created).
> 
> So the result is as invalid as if the default template were used, no
> more. The same would happen if you create an <xref> in DocBook document:
> the document becomes invalid until you specify the @linkend attribute...
> 
> Is there a workaround ? 

Yes, see below.


> (needless to say, we cannot suggest  default
> values for the mandatory attributes or we would have done this...).
> 

No, but you nevertheless need to specify placeholder values for all the
required attributes.

DocBook 4 example: "xref" has a "linkend" required attribute.

What follows [A] works as expected:

---
  <elementTemplate name="simple" selectable="override">
    <xref xmlns="" linkend="???" role="TEST" />
  </elementTemplate>
---

While this [B] may be used to reproduce the behavior you describe:

---
  <elementTemplate name="simple" selectable="override">
    <xref xmlns="" role="TEST" />
  </elementTemplate>
---

[B] is *structurally*-invalid and hence ignored.

[A] is structurally-valid but data-type-invalid, which is still OK.

We'll document all these subtleties in next release.
 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to