XML Form document (XForm) can not change instanceData name

I’m doing some tests with LibreOffice Writer’s XForm capabilities. In the XML column the root element for the XML is called “instanceData” and I think you are supposed to be able to edit it and change its name. But the change do not take effect. Is this a bug ?

I believe I am seeing the same issue as Igor. I was following along in the online tutorial by David Eisenberg here and he clearly shows in Illustration 6 that he’s renamed the root, which gets the name “instanceData” by default, to “club.” When I right-click on the instanceData in the instance tree control I can select “Edit Element” which brings up a dialog showing the Element’s Name as an editable string. If I change the name to something simple like “thisNode” there is no error but neither does the name of the root node as displayed in the tree change. Just to make sure it’s not some kind of refresh issue I saved the document, closed, reopened the document, and the tree’s root node is still named “instanceData.” This sure looks like a bug to me and I want to file it as such but am worried I may just been too new to LibreOffice to know that I’m doing something silly and the behavior is expected and normal.

After loading the LibreOffice code in the Kdevelop debugger it looks like the problem lies in the renameElement function–this function is called every time you edit an item in the XML tree but it fails when you are interacting with the root node. I’ve not studied the code enough to understand exactly why but I think it’s because the parent of the root node is different from the parent of all other nodes in the tree.

But, probably the best approach is to simply work around this problem completely. I recommend the following approach:

  1. Create your base XML document, i.e. the XML that you want to bind form controls to in your XForm, and save it as a .xml file. Obviously in this XML document you’ll have your root node named as you wish.
  2. Create your XForm document in Writer like normal but ignore the default instance, Instance 1, that is created for you. Instead, use the Instance button in the lower right corner of the XML pane to Add a new instance. When doing so type in the name of your new instance, browse to the XML document created in step 1, and be sure to check Link Instance. When you press OK you should see your XML document’s structure reflected in the XML tree complete with a root node that has the name you designated.
  3. At this point I’d delete the original default “Instance 1” that was created for you since you don’t need it.
  4. Since you specified Link Instance when you imported your XML document into your XForm document, any change to a node name, including the root node, you make in the XML document will be reflected in the XML tree. You will have to close/open the XForm document to refresh the XML tree (or maybe there’s an easier way to refresh?) but the tree will track changes to the XML document.

All in all renaming the root node would be nice but won’t you usually have already built your XML before you start working in Writer anyway?