Hi!
I'm answering my own question here, but asking another:
I fixed (and improved) my workaround, so it now won't let you enter an ID
that already exists, and also allows you to optionally add a prefix (%1) to
the ID entered by the user, making it possible to maintain separate groups
of IDs used for different purposes. However, I would like to be able to
delete the inserted element if the user exits from the ID prompt dialog by
pressing Cancel. How would I do this?
<cfg:command name="my.insert">
<cfg:macro trace="true">
<cfg:sequence>
<cfg:command name="insert" parameter="%0" />
<cfg:choice>
<cfg:sequence>
<cfg:match context="$selectedElement" pattern="*...@id]"/>
<cfg:command name="my.insertId" parameter="'Enter element ID:'
'%1'" />
</cfg:sequence>
</cfg:choice>
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:command name="my.insertId">
<cfg:macro trace="true">
<cfg:sequence>
<cfg:command name="prompt" parameter="'Insert Element' '%0'" />
<cfg:choice>
<cfg:sequence>
<cfg:test context="$selectedElement" expression="id('%1%_')"/>
<cfg:command name="my.insertId" parameter="'%_ already exists,
please try again:' '%1'"/>
</cfg:sequence>
<cfg:sequence>
<cfg:command name="putAttribute" parameter="[implicitElement] id
'%1%_'" />
</cfg:sequence>
</cfg:choice>
</cfg:sequence>
</cfg:macro>
</cfg:command>
_____
From: Kevin Flynn [mailto:[email protected]]
Sent: 20. februar 2006 09:51
To: 'xmleditor-support at xmlmind.com'
Subject: putAttribute question
Is the behavior of XmlMind's putAttribute function sensible for attributes
of type ID? If no value is specified, then a select box dialog is displayed
that allows you to select from a list of existing ID values. This is
obviously the correct behavior for IDREF attributes, but surely the point
when inserting an ID attribute is to insert a unique value that has not yet
been used?
I am currently using version 3.0 of XmlMind.
Do you have a workaround that lets me display a standard "prompt" dialog for
a newly inserted element only if it has an attribute called "id"? I tried
this, but it doesn't seem to work, for reasons I don't understand:
<cfg:command name="my.insert">
<cfg:macro trace="true">
<cfg:sequence>
<cfg:command name="insert" parameter="%0" />
<cfg:choice>
<cfg:sequence>
<cfg:match context="$selectedElement" pattern="@id"/>
<cfg:command name="prompt" parameter="'Insert Element' 'Enter
element ID:'" />
<cfg:command name="putAttribute" parameter="[implicitElement] id
'%_'" />
</cfg:sequence>
</cfg:choice>
</cfg:sequence>
</cfg:macro>
</cfg:command>
Kevin Flynn
Birdstep Technology ASA
Oslo, Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20060220/0298af8f/attachment.htm