Alexander Johannesen wrote:
> Hi again,
>
> I'm getting nervously close to my deadline, and need help with a
> specific problem I'm having. Basically, I've got a DTD in which I've
> got (amongst other things) ;
>
> <!ELEMENT section (title|picture|item|point|link)* >
>
> My CSS has got this (for testing purposes) ;
>
> section:after {
> display:inline;
> content: insert-before-button() " " insert-button() " "
> insert-after-button() " " ;
> }
>
> If my XML template looks like this;
>
> <section> </section>
>
> I can click the middle icon-button and all elements of the DTD comes
> up as options. However, if I do;
>
> <section>
> <point> ... text ... </point>
> </section>
>
> then the middle icon-button yields nothing; I can't add more than one
> element! (See below for the "empty element OR caret position" problem)
> It does not matter which element it is; unless <section> is empty, I
> can't add anything. (The before- and after- buttons work fine,
> correctly stating I can add a section before and after this section.
>
> I did one experiment where I also add #PCDATA to the <section> ;
>
> <!ELEMENT section (#PCDATA|title|picture|item|point|link)* >
>
> and if I put the caret at the beginning, then I can add stuff. So, I
> can write a macro as such ;
>
> <macro><sequence>
> <command name="selectNode" parameter="self[implicitElement]" />
> <command name="insert" parameter="into link" />
> </sequence></macro>
>
> Now, the manual states that an 'insert into' must be either an empty
> selected element OR at caret position. Why must an element be empty?
> Is there no way to insert into a given position, such as "into/last()
> element"? I already have the context node selected, so adding to the
> beginning, position() or end should be trivial. This basically means
> that what I'm trying to do is impossible, no? I'm trying to add
> several elements to a <section> in a controlled way without having
> #PCDATA in that element.
The insert after last child or insert at nth position can be implemented
in terms of insert before/after which are the primitive commands of XXE.
Insert at caret position or insert into an empty element cannot be
implemented in terms of insert before/after. That why we have added
another primitive command.
OK, this was the rationale of insert into/before/after.
Let's say you want to add elements after the last child of a section if
any, here's how I would write this:
---
<!ELEMENT doc (section+)>
<!ELEMENT section (para1|para2|para3)*>
<!ELEMENT para1 (#PCDATA)>
<!ELEMENT para2 (#PCDATA)>
<!ELEMENT para3 (#PCDATA)>
---
---
doc,
section,
para1,
para2,
para3 {
display: block;
}
para1,
para2,
para3 {
margin: 1ex 0;
}
section {
margin-left: 4ex;
}
section:before {
display: marker;
content: command-button(command, "MyInsertInto",
icon, icon(pop-down));
}
---
---
<command name="MyInsertInto">
<macro trace="true">
<choice>
<command name="insert" parameter="into" />
<sequence>
<command name="selectNode" parameter="lastChild" />
<command name="insert" parameter="after" />
</sequence>
</choice>
</macro>
</command>
---
Note that the above macro simply uses the native dialogs of XXE. I have
written this just to explain why you don't need *generic*, *primitive*
insert other than into/before/after.
Please find attached to this document, a working configuration.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example1.zip
Type: application/octet-stream
Size: 2587 bytes
Desc: not available
Url :
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20041021/06d85eed/attachment.dll