Exporting Code Templates

Having trouble installing Oxygen? Got a bug to report? Post it all here.
stefanhinz
Posts: 8
Joined: Thu Jun 11, 2009 1:47 pm

Exporting Code Templates

Post by stefanhinz »

Oxygen XML Editor (on 18.1 here) comes with a bunch of preconfigured code templates. I created a couple of my own, and would like to export just those, not all of them. In the Code Templates dialog, though, the Export button seems to export them all. Even if I could change that by unselecting all the templates I don't want to export, that would take a long time, because there doesn't seem to be a Select All / Unselect All functionality.
Any pointers how to do this right are appreciated! Thanks in advance!
Stefan
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Exporting Code Templates

Post by adrian »

Hi,

I'm afraid you can only export all of them at once (including the defaults).
But you can open the XML file afterwards and remove all unwanted code templates (element "codeTemplateItem"). The first from the list should be your custom ones, the rest are the defaults.
You can use the XPath toolbar at the top to highlight individual templates:
//codeTemplateItem

When importing code templates, they are merged with your existing ones.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
stefanhinz
Posts: 8
Joined: Thu Jun 11, 2009 1:47 pm

Re: Exporting Code Templates

Post by stefanhinz »

As always, super quick and competent reply, thanks much, Adrian!
I noted the following in a README file:
Exporting code templates (or document templates) from Oxygen can be a cumbersome process, because you can only export all code templates (or document templates), and you'd have to remove from the export file the ones you don't want in it, manually. This is not a big issue, though, because, on import, any new templates are merged with the existing ones, and the existing ones will remain as they are (that is, no duplicates will be created). However:
* Note: If templates in the import file conflict with existing (modified) templates,
* the existing templates will be overwritten with the imported ones.
So, not a big issue. One nitpick, though: In the export file, I found my custom code templates somewhere in the middle of the XML, not at the top of the file. Since I don't intend to edit the export/import file, though (see above), this is not an issue for me.
Stefan
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Exporting Code Templates

Post by adrian »

Hi,

I would agree that the UI needs some work with regard to exporting/importing code templates. I've logged an improvement request to handle code templates individually.
One nitpick, though: In the export file, I found my custom code templates somewhere in the middle of the XML, not at the top of the file. Since I don't intend to edit the export/import file, though (see above), this is not an issue for me.
I believe you are correct. If you've used a specific Editor for "Associate with" (as opposed to "All editors" like I did in my tests) you may find them somewhere in the middle.

Easier way to find a specific code template via XPath:

Code: Select all

//codeTemplateItem[contains(field[@name="renderString"]/String/text(), "my code template name")]
Replace "my code template name" with a part of (or the entire) name of the searched code template.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
stefanhinz
Posts: 8
Joined: Thu Jun 11, 2009 1:47 pm

Re: Exporting Code Templates

Post by stefanhinz »

Thanks again, Adrian! Case solved, at least for me. And thanks for filing the feature request!
Post Reply