Name

cx:plantuml — Convert an ASCII “PlantUML” diagram into an image.

Synopsis

<p:declare-step type="cx:plantuml" xmlns:cx="http://xmlcalabash.com/ns/extensions">
     <p:input port="source" sequence="true"/>
     <p:output port="result" sequence="true"/>
     <p:option name="format" select="'png'"/>                      <!-- "png" | "svg" -->
     <p:option name="html" select="false()"/>                      <!-- boolean -->
</p:declare-step>

Description

This step converts PlantUML diagrams into PNG or SVG images. For PNG, the step returns a base64 encoded data: URI; for SVG it returns the SVG.

If the html option is true, an HTML img is returned, otherwise a c:data element that contains the URI is returned. At the moment, the HTML option has no effect in the SVG case; in the future it might do something with namespaces or something.

Here's an example from the PlantUML site:


@startuml

class BaseClass

namespace net.dummy #DDDDDD {
    .BaseClass <|-- Person
    Meeting o-- Person

    .BaseClass <|- Meeting
}

namespace net.foo {
  net.dummy.Person  <|- Person
  .BaseClass <|-- Person

  net.dummy.Meeting o-- Person
}

BaseClass <|-- net.unused.Person

@enduml

Run through the cx:plantuml step, you get:

Here's another example:


@startuml
title Servlet Container

(*) --> "ClickServlet.handleRequest()"
--> "new Page"

if "Page.onSecurityCheck" then
  ->[true] "Page.onInit()"

  if "isForward?" then
   ->[no] "Process controls"

   if "continue processing?" then
     -->[yes] ===RENDERING===
   else
     -->[no] ===REDIRECT_CHECK===
   endif

  else
   -->[yes] ===RENDERING===
  endif

  if "is Post?" then
    -->[yes] "Page.onPost()"
    --> "Page.onRender()" as render
    --> ===REDIRECT_CHECK===
  else
    -->[no] "Page.onGet()"
    --> render
  endif

else
  -->[false] ===REDIRECT_CHECK===
endif

if "Do redirect?" then
 ->[yes] "redirect request"
 --> ==BEFORE_DESTROY===
else
 if "Do Forward?" then
  -left->[yes] "Forward request"
  --> ==BEFORE_DESTROY===
 else
  -right->[no] "Render page template"
  --> ==BEFORE_DESTROY===
 endif
endif

--> "Page.onDestroy()"
-->(*)

@enduml

And what it produces:

PlantUML can make lots of different quites of diagrams of quite considerable complexity.

Implementation

This step is implemented by the xmlcalabash1-plantuml module. The jar file from that project must be in the class path in order to use this step.