HTML / XML Markup Generation Functions

Overview

This plugin provides Appian functions that generate HTML and XML content with properly-escaped characters. It can be used to produce HTML email content, XML to be fed into plugins or services, etc.

By escaping characters by default and automatically opening and closing tags and attributes, it provides a better abstraction and mechanism for less error-prone content generation.

Here's an example of this plug-in in use, which helps us create valid HTML content with escaping that happens by default:

MarkupGen_html_toText(
  MarkupGen_html_newElem("p",  {class: "info"}, 
  {
    MarkupGen_html_newElem("b", null, "Message for " & ri!name),
    ri!message,
    MarkupGen_html_newElem( "a",  { href: ri!url },
    "Click here to " & ri!action
    )    
  }
  )
)

Notice how the language syntax helps us create valid HTML content. Furthermore, the HTML escaping happens by default; we don't need to remember to call a specific function to escape text.

Key Features & Functionality

For HTML Generation:

  • MarkupGen_html_newElem: Creates a new HTML element, such as <p> or <a href="x">.
  • MarkupGen_html_toText: Converts an element or list of elements to text.
  • MarkupGen_html_newTextPart (Less common): Creates a new element for text. It's necessary only when you need to use a uniform list of the MarkupGen_HtmlPart data type.
  • MarkupGen_html_newRawPart (Less common): Creates a new element with raw HTML. When using these functions ensure that the raw content is trusted and in line with security policies for your organization.

For XML Generation:

  • MarkupGen_xml_newElem: Creates a new XML element, such as <item> or <person>.
  • MarkupGen_xml_toText: Converts an XML element to text.
  • MarkupGen_xml_newTextPart (Less common): Creates a new element for text.
  • MarkupGen_xml_newRawPart (Less common): Creates a new element with raw XML. When using these functions ensure that the raw content is trusted and in line with security policies for your organization.

Github repository for source code and more details:
https://github.com/innodev-au/innodev-appianfunctions-markupgen

Anonymous