Search this blog

Saturday, 8 March 2014

The Write Special Format operator

Here is a complicated process that does quite a lot...
Deep breath, here we go...
  1. Loop through all the process files in a repository (make sure you point it to your location) and read each one in as a document.
  2. Convert the documents to normal examples within a single example set.
  3. Create an attribute called `description` that contains the text within the top-level comment for each process. This uses Ninja XPath (actually it doesn't but I wanted to use the word Ninja).
  4. Do gymnastics to reformat the contents of the attribute. This uses Ninja regular expressions (actually it doesn't but the usual rule is all regular expressions require Ninja like skills). Newlines and linefeeds are included - this is perhaps the interesting part.
  5. Rename to make the name of the attribute easier to understand.
  6. Select only the attributes of interest.
  7. Filter out all where there is no description.
  8. Write the example set to a file (make sure you set this to somewhere you want to write files). This uses the `Write Special Format` operator which was the only way I could find to get this to work.

The comment view can contain html. This allows basic formatting and structure to be defined so that when a process is opened, the text in the comment view is displayed with this formatting and structure applied. The process above allows the html tags to be extracted so they can be re-used if you want to use the formatting and structure somewhere else like a document or index. Time is precious, anything that allows re-use and avoids typing is good.

The `Write Special Format` operator is especially nice because it allows precise control to be exerted over what is to be written. Dare I say Ninja like control?

No comments:

Post a Comment