Library for advanced binding
For the sake of simplicity, this documentation uses the term "extended bindings" for this document function.
Extended bindings make it possible to influence the document structure via XSLT. Compared to the document function "Scripts", extended bindings are able to change not only the text content but also other attributes such as text color, size of applied style, etc. They offer many possibilities, however, they are challenging to implement and maintain and have a higher loading time than documents without extended bindings. Therefore, extended bindings should be used sparingly and if possible not at all.
Tags
General Tags:
Tag | Function |
---|---|
<w:sdtContent></w:sdtContent> |
These tags enclose the entire extended binding in the Word document. |
<xsl:stylesheet></xsl:stylesheet> |
These tags enclose all templates. |
<xsl:template></xsl:template> |
These tags enclose a template. |
<xsl:param></xsl:param> |
These tags enclose a parameter. |
<xsl:variable></xsl:variable> |
These tags enclose a variable. |
<xsl:value-of></xsl:value-of> |
These tags enclose a variable which will be output. |
<xsl:call-template></xsl:call-template> |
These tags enclose a template call. |
<xsl:with-param></xsl:with-param> |
These tags enclose a parameter which is passed in the template call. |
<w:p></w:p> |
These tags enclose a paragraph. |
<w:r></w:r> |
These tags enclose a set of WordprocessingML components. |
<w:t></w:t> |
These tags enclose plain text. |
<w:tbl></w:tbl> |
These tags enclose an entire table. |
<w:tr></w:tr> |
These tags enclose a table row. |
<w:tc></w:tc> |
These tags enclose a table cell. |
Warning
This list is not exhaustive.
Formatting container tags:
Tag | Function | Link to attributes |
---|---|---|
<w:pPr></w:pPr> |
Within these tags the formatting for paragraphs is defined. | Paragraph Properties |
<w:rPr></w:rPr> |
Within these tags the formatting for runs is defined. | Run Properties |
<w:tblPr></w:tblPr> |
Within these tags the formatting for entire tables is defined. | Table Properties |
<w:trPr></w:trPr> |
Within these tags the formatting for table rows is defined. | TableRow Properties |
<w:tcPr></w:tcPr> |
Within these tags the formatting for table cells is defined. | TableCell Properties |
<w:t></w:t> |
Plain text has no property tags, text is defined in the run property tags. | Text/Run Properties |
Operators
Operator | Function |
---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
div |
Division |
= |
Equal |
!= |
Unequal |
< / < |
Less than |
> / > |
Greater than |
<= / >= |
Less or equal |
>= / <= |
Greater or equal |
or |
Logical or |
and |
Logical and |
Mod |
Modulus |
$ |
is used to address a variable. |
// |
Double slash: specifies a path with "root" as starting point. |
/ |
Single slash: specifies a path with the current position as starting point. |
. |
Period: addresses the current element. |
.. |
Colon: addresses the parent element of the current element. |
@ |
Addresses attributes. |
| |
| character: is a logical and; you can logically connect several elements with each other. |
not() |
is used for a negation. |
Data access
Extended bindings can be used to access and use data in the same way as scripts. The data is stored in a variable.
Example of a variable:
<xsl:variable name="[NAME DER VARIABLE]" select="[REFERNZIERTES OBJEKT]" />
Example of accessing a text field in the Document Parameter:
<xsl:variable name="Subject" select="//Text[@id='DocParam.Subject']" />
The "DocParam" prefix is not mandatory. However, the OneOffixx conventions dictate that fields in the Document Parameter must be provided with this prefix.
Example of accessing a CheckBox in the Document Parameter:
<xsl:variable name="CheckBox" select="//CheckBox[@id='DocParam.CheckBox']" />
The "DocParam" prefix is not mandatory. However, the OneOffixx conventions dictate that fields in the Document Parameter must be provided with this prefix.
Example of accessing a ComboBox:
<xsl:variable name="ComboBox" select="//ComboBox[@id='DocParam.Combo']/@selectedValue" />
The "DocParam" prefix is not mandatory. However, the OneOffixx conventions dictate that fields in the Document Parameter must be provided with this prefix.
Example of accessing a script:
<xsl:variable name="ExampleSkript" select="//Text[@id='CustomElements.ExampleScript']" />
Unlike accessing the document parameter, the prefix 'CustomElements' is mandatory here.
Functionalities
Normalize space
The function "Normalize-Space()" cleans up variables, input fields, etc. That means, if there should be a space in a field by mistake, it will be considered as empty.
<xsl:variable name="Subject" select="normalize-space(//Text[@id='DocParam.Subject'])" />
The above variable contains the content of the subject field from the document parameter, cleaned from redundant spaces.
If
The "If" function offers the possibility to make actions dependent on conditions.
<xsl:template name="ConditionedSubject">
<xsl:variable name="Subject" select="//Text[@id='DocParam.Subject']">
<xsl:if test="normalize-space($Subject) != ''">
<w:p>
<w:r>
<w:t>
<xsl:value-of select="$Subject" />
</w:t>
</w:r>
</w:p>
</xsl:if>
</xsl:template>
The above template checks if the subject field in the Document Parameter is not empty. If it is, the value is output, otherwise nothing happens.
Choose
The function "Choose" is an extension of the function If
. It offers the additional possibility to make a statement if the condition does not apply. For this the tags When
and Otherwise
are used. What is between the When
tags will be executed if the condition is true. What is between the Otherwise
tags will be executed if the condition is not true.
<xsl:template name="ConditionedSubject">
<xsl:variable name="Subject" select="//Text[@id='DocParam.Subject']" />
<w:p>
<w:r>
<w:t>
<xsl:choose>
<xsl:when test="normalize-space($Subject) != ''">
<xsl:value-of select="$Subject" />
</xsl:when>
<xsl:otherwise>
Subject is empty
</xsl:otherwise>
</xsl:choose>
</w:t>
</w:r>
</w:p>
</xsl:template>
The above template checks if the subject field in the Document Parameter is not empty. If it is, the value will be output. If the subject field is empty, the information text "Subject is empty" is output.
Substring
The function "Substring" is divided into two sub-functions; there are Substirng-before and Substring-after. One passes to the template a string (text) and a character (character) at which the text is to be separated.
<xsl:template name="SubstringBeforeEMail">
<xsl:variable name="E-Mail" select="//Text[@id='DocParam.E-Mail']" />
<xsl:variable name="Charakter">@</xsl:variable>
<w:p>
<w:r>
<w:t>
<xsl:value-of select="substring-before($E-Mail, $Charakter)" />
</w:t>
</w:r>
</w:p>
</xsl:template>
<xsl:template name="SubstringAfterEMail">
<xsl:variable name="E-Mail" select="//Text[@id='DocParam.E-Mail']" />
<xsl:variable name="Charakter">@</xsl:variable>
<w:p>
<w:r>
<w:t>
<xsl:value-of select="substring-after($E-Mail, $Charakter)" />
</w:t>
</w:r>
</w:p>
</xsl:template>
*The first template outputs everything that comes before the "@" in the email. The second template outputs everything after the "@".
Warning
The character used as the starting point – in this case "@" – is not included in the output.
Concat
The Concat function is the opposite of the Substring function: it concatenates strings.
<xsl:template name="ConcatEMail">
<xsl:variable name="FirstName" select="//Text[@id='DocParam.FirstName']" />
<xsl:variable name="LastName" select="//Text[@id='DocParam.LastName']" />
<w:p>
<w:r>
<w:t>
<xsl:value-of select="concat($FirstName, '.', $LastName, '@beispiel.com')" />
</w:t>
</w:r>
</w:p>
</xsl:template>
The template above creates an email address from the first name and last name, a dot is placed between the first name and last name, and "@example.com" is added after the last name.
Examples
Recipient with shipping method
The shipping type and the recipient have different style information, moreover the shipping type is an optional input. If it is desired that the recipient moves up one line if the dispatch type is not filled in, this must be solved with an extended binding. The usual scripts cannot use different style information in one script.
Example of a recipient with and without shipping method |
<!-- Template for recipients with optional shipping method. -->
<xsl:template name="OptionalTransmission">
<!-- Variable with content of the shipping method. -->
<xsl:variable name="Transmission" select="//Text[@id='CustomElements.Versandart']" />
<!-- Variable with content of the recipient. -->
<xsl:variable name="Anschrift" select="//Text[@id='CustomElements.Anschrift']" />
<!-- Condition which checks if the variable for the shipping type has content. -->
<xsl:if test="normalize-space($Transmission) = ''">
<!-- Calling the template which replaces spaces with wraps so that the recipient information is displayed one below the other. -->
<xsl:call-template name="StringToList">
<xsl:with-param name="string" select="//Text[@id='CustomElements.Anschrift']" />
</xsl:call-template>
</xsl:if>
<xsl:if test="normalize-space($Transmission) != ''">
<w:p>
<w:pPr>
<w:pStyle w:val="Transmission" />
</w:pPr>
<w:r>
<w:t>
<xsl:value-of select="$Transmission" />
</w:t>
</w:r>
</w:p>
<!-- Calling the template which replaces spaces with wraps so that the recipient information is displayed one below the other. -->
<xsl:call-template name="StringToList">
<xsl:with-param name="string" select="//Text[@id='CustomElements.Anschrift']" />
</xsl:call-template>
</xsl:if>
</xsl:template>
Dynamic tables
Tables with static number of rows and columns but optional display of rows and columns are another example for the use of extended bindings. Whether a row or column is displayed can be defined in the document parameter using a CheckBox.
Example of a table with dynamically displayed rows / columns |
<!-- Template for dynamically displayed table -->
<xsl:template name="DynamicTable">
<w:p />
<w:tbl>
<w:tblPr>
<w:tblStyle w:val="Tabellenraster" />
<w:tblW w:w="0" w:type="auto" />
<w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1" />
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="1701" />
<w:gridCol w:w="1701" />
</w:tblGrid>
<!-- Condition at which it is checked whether the first row should be displayed [DocParam.Row1 = Show first row]. -->
<xsl:if test="//CheckBox[@id='DocParam.Row1'] = 'true'">
<w:tr>
<!-- Condition at which it is checked whether the first column should be displayed [DocParam.Column1 = Show first column]. -->
<xsl:if test="//CheckBox[@id='DocParam.Column1'] = 'true'">
<w:tc>
<w:tcPr>
<w:tcW w:w="1701" w:type="dxa" />
</w:tcPr>
<w:p>
<w:r>
<w:t>
Zeile 1 Spalte 1
</w:t>
</w:r>
</w:p>
</w:tc>
</xsl:if>
<!-- Condition at which it is checked whether the second column should be displayed [DocParam.Column2 = Show second column]. -->
<xsl:if test="//CheckBox[@id='DocParam.Column2'] = 'true'">
<w:tc>
<w:tcPr>
<w:tcW w:w="1701" w:type="dxa" />
</w:tcPr>
<w:p>
<w:r>
<w:t>
Zeile 1 Spalte 2
</w:t>
</w:r>
</w:p>
</w:tc>
</xsl:if>
</w:tr>
</xsl:if>
<!-- Condition at which it is checked whether the second row should be displayed [DocParam.Row2 = Show second row]. -->
<xsl:if test="//CheckBox[@id='DocParam.Row2'] = 'true'">
<w:tr>
<!-- Condition at which it is checked whether the first column should be displayed [DocParam.Column1 = Show first column]. -->
<xsl:if test="//CheckBox[@id='DocParam.Column1'] = 'true'">
<w:tc>
<w:tcPr>
<w:tcW w:w="1701" w:type="dxa" />
</w:tcPr>
<w:p>
<w:r>
<w:t>
Zeile 2 Spalte 1
</w:t>
</w:r>
</w:p>
</w:tc>
</xsl:if>
<!-- Condition at which it is checked whether the second column should be displayed [DocParam.Column2 = Show second column]. -->
<xsl:if test="//CheckBox[@id='DocParam.Column2'] = 'true'">
<w:tc>
<w:tcPr>
<w:tcW w:w="1701" w:type="dxa" />
</w:tcPr>
<w:p>
<w:r>
<w:t>
Zeile 2 Spalte 2
</w:t>
</w:r>
</w:p>
</w:tc>
</xsl:if>
</w:tr>
</xsl:if>
</w:tbl>
<w:p />
</xsl:template>