XSL Extensions for Simple Form Support

Serna allows you to represent the content of elements and even attributes with edit-boxes or combo-boxes with special extensions. This is convenient for creating form-like documents, or editing elements in Serna that have enumerated values or ones conforming to a simple type (e.g. date).

To represent the elements (attributes) in combo-box and line-edit the following XSL FO extensions are available:

<se:combo-box 

    value="VALUE"

    is-editable="true|false"

    is-enabled="true|false"

    width="widthValue">

      <se:value>...</se:value>

      ...

</se:combo-box>
<se:line-edit 

    value="VALUE"

    is-enabled="true|false"

    width="widthValue"/>
Important:

For performance reasons Serna treats namespace prefix se conforming to xmlns:se="http://syntext.com/XSL/Format-1.0". Make sure you use se namespace prefix for the extension FOs.

Note:

If you want to use the same stylesheet for 3rd-party XSL processors, see Serna XSL Extensions about how to ignore the extensions in a stylesheet.

These FOs are inline areas (inheriting the properties of inline areas) and have the following parameters/content:

The se:combo-box are filled with values in the following manner:

  1. If the values are provided via se:value elements, then these values are shown in the combo-box.

  2. If the values are not provided, but validation is ON or STRICT and schema enforces enumerated values for the element or attribute, then these values are shown.

Examples:

See example Representing an element with enumerated values from schema. See example Representing an element with non-enumerated value. See example Representing an element with values from the stylesheet. See example Editing Element Attributes Inline.

Representing an element with enumerated values from schema

  <xsl:template match="my-boolean-element">

    <fo:block>

      <se:combo-box

        value="{string()}"

        width="2cm"/>

    </fo:block>

  </xsl:template>

Representing an element with non-enumerated value

In this example schema may or may not check the value entered into the line-edit.

  <xsl:template match="time">

    <fo:block>

      <se:line-edit 

        value="{string()}"

        width="1.5cm"/>

    </fo:block>

  </xsl:template>

Representing an element with values from the stylesheet

In this example the value list of the combo is filled with the vales returned by the function foo called with the argument bar. In this example, function foo should return a node-set with multiple <se:value> elements.

<se:combo-box width="5cm">

  <xsl:copy-of select="foo('bar')"/>

</se:combo-box>

Editing Element Attributes Inline

In this example we demonstrate the Docbook ulink element, that has an attribute url that keeps the URL, while the content of the ulink shows the description. The approach below allows to edit the attribute inline within a line-edit.

  <xsl:template match="ulink">

    <!-- Keep all the content within one area -->

    <fo:inline text-decoration="underline">



      <!-- Separate inline area will draw empty tag if content is empty -->

      <fo:inline>

        <xsl:apply-templates/>

      </fo:inline>



      <!-- Use the extensions if processed in Serna -->

      <xsl:choose>

        <xsl:when test="$use-serna-extensions">

          <xsl:apply-templates select="@url" mode="ulink"/>

        </xsl:when>

        <xsl:otherwise>

          <xsl:text> [</xsl:text>

          <xsl:value-of select="@url"/>

          <xsl:text>]</xsl:text>

        </xsl:otherwise>

      </xsl:choose>

    </fo:inline>

  </xsl:template>



  <!-- Call separate template for @url to make @url the context node -->

  <xsl:template match="@url" mode="ulink">

    <fo:inline>

      <xsl:text> [</xsl:text>

      <se:line-edit value="{string(.)}" />

      <xsl:text>]</xsl:text>

    </fo:inline>

  </xsl:template>