Question
· Jul 19

How to make a custom studio document work correctly with $System.OBJ.Load() ?

Hi all,

I have some .vm (Velocity Templating Language) files that I'd like to be able to load into IRIS with the $System.OBJ.Load(filename) command, but it seems that only accepts XML files.

I've tried adding import/export logic in my custom studio document that will wrap the velocity content inside an XML document and vice versa, I've changed the existing Velocity files to have the extension .xml and be wrapped in XML, and I've included a .dtd file for them to reference. However, this doesn't seem to work.

Does anyone have suggestions for how can I make my custom studio document work correctly with $System.OBJ.Load()?

Discussion (4)2
Log in or sign up to continue

from class documentation:

You can import files exported in

  • XML format,
  • %RO format,
  • CDL format,
  • UDL format,
  • %GOF,
  • and CSR/CSP files.

You should do an export of one of this types and then see
how this may match your .vm  thing.

Your screenshot is definitely some XML
But it doesn't match any formatting structures or rules required  in IRIS or Caché.

We are using this to implement a reusable comprehensive email templating module to prevent our having to hand-craft HTML emails out of many different IRIS applications.  So far the approach looks very promising!  (and members of the community will eventually be able to directly see the results as we're first using this to implement a Welcome Email framework which can be used by any of our externally facing applications which use InterSystems Login accounts - https://community.intersystems.com/post/leveraging-your-intersystems-log...

SOLVED - 

1) We wrapped the .vm in XML like so:

The actual velocity code is wrapped in a CDATA tag, so it is not parsed as XML.

2) Our custom studio document class looks like this:

We originally thought we'd need custom import/export logic to strip the CData, but turns out the default behavior of %Studio.AbstractDocument is to CData escape the stream, so this is automatically taken care of: