/t5/indesign-discussions/cs3-js-add-xml-element-to-insertion-points/td-p/1159064Jun 10, 2008
Jun 10, 2008
Copy link to clipboard
Copied
hi list,
i'll do some text parsing in indesign cs3 intended to add some xml elements to my document.
i just wonder why i can't markup an insertion point. is the following approach correct? The code works fine, only the return value (stored in the _xml variable) is not the new element but the parent element. The same code works without using the insertion point (marking up the text object [xmlElements.add(_dokument.xmlTags.item("index") , erg[0]))] ).
Any ideas or thoughts?
var _dokument = app.activeDocument;
main ();
// ** main ()
function main() {
//Set the find options.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences= NothingEnum.nothing;
//find any string encloased by @
app.findGrepPreferences.findWhat = "@.*?@";
/t5/indesign-discussions/cs3-js-add-xml-element-to-insertion-points/m-p/1159065#M338416Jun 10, 2008
Jun 10, 2008
Copy link to clipboard
Copied
If you try it in the UI, you'll see that when only an insertion point is selected and you try to tag it, the whole story is tagged.
I don't think that what you're trying can be done. You have to tag content, not the lack of it. However, what you could do is insert some temporary text at the insertion point, tag that and then delete the text. That will have the effect you're trying to achieve.
/t5/indesign-discussions/cs3-js-add-xml-element-to-insertion-points/m-p/1159066#M338417Jun 10, 2008
Jun 10, 2008
Copy link to clipboard
Copied
...but you can enter a character in the contents of the insertion point, tag it, and then delete the character. This creates an empty element at the insertion point. Not elegant, but it works.:-)
/t5/indesign-discussions/cs3-js-add-xml-element-to-insertion-points/m-p/1159067#M338418Jun 11, 2008
Jun 11, 2008
Copy link to clipboard
Copied
hi dave,
gui testing is always a good idea 🙂 but in this case the behaviour is different:
your observation is correct (anyway at least a strange behaviour compared to any xml editing tool i know == how adobe intended to insert an empty element?), tagging in the gui a tagged insertion point tags the whole story.
in the script a new element is added but the return value is the parent element (the xmlElement of the whole story).
this causes a problem when i add an attribute (the intention of the above script is to add references) which is added to the parent element.