Wiki source code of XSL-Transformation


Hide last authors
gru 4.16 1 Templates of type //XSL transformation// are utilized to transform an XML export file and can be used, for example, in actions of type [[Export (XML-File)>>doc:Formcycle.Designer.Workflow.Actions.ExportXML]] or for [[exporting a form record in an Inbox>>doc:Formcycle.Inbox.WebHome]].
gru 4.1 2
gru 4.16 3 There are some tutorials on XSL transformation at [[w3schools>>url:https://www.w3schools.com/xml/xsl_transformation.asp]] and [[TutorialsPoint>>url:https://www.tutorialspoint.com/xslt/]].
gru 4.1 4
gru 4.16 5 == Supported versions of the XSLT and XPath standards ==
gru 4.1 6
gru 4.16 7 Up to and including {{formcycle/}} version 7.2.1, only //XSL transformations// using the XSLT 1.0 and XPath 1.0 language standards are supported.
gru 4.1 8
gru 4.16 9 {{version major="7" minor="3" patch="0"/}}Starting with {{formcycle/}} version 7.3, a different processor is used, which supports XSLT 3.0 and XPath 3.1.
gru 4.1 10
gru 4.16 11 == Differences in the use of XSL transformations in {{formcycle/}} version 7.3 or higher ==
gru 4.3 12
gru 4.16 13 Basically, the XSLT processor used in newer {{formcycle/}} XSLT processor used in newer {{formcycle/}} versions supports all the language features that the older processor supported, since it is backward compatible with XSLT 1.0.
gru 4.3 14
gru 4.16 15 However, the XSLT processor used in older {{formcycle/}} versions allowed certain statements that are not mandated by the language standard. This can cause existing XSL transformations to fail after updating to a {{formcycle/}} version greater than or equal to 7.3.
gru 4.3 16
gru 4.16 17 So far, the following problems are known:
gru 4.7 18
gru 4.16 19 === Nested function calls ===
20
21 Function calls in the form
22
gru 4.7 23 {{code language="xml"}}
gru 4.6 24 <xsl:variable name="dd">
25 <xsl:value-of select="format-number(substring-before($datestr,'.'), '0' )" />
26 </xsl:variable>
27 {{/code}}
gru 4.7 28
gru 4.16 29 are no longer possible. Instead, you can cache the result of the inner function in variables, for example:
gru 4.7 30
gru 4.6 31 {{code language="xml"}}
32 <xsl:variable name="ddtemp">
33 <xsl:value-of select="substring-before($datestr,'.')" />
34 </xsl:variable>
gru 4.3 35
gru 4.6 36 <xsl:variable name="dd">
37 <xsl:value-of select="format-number($ddtemp, '0' )" />
gru 4.8 38 </xsl:variable>
gru 4.6 39 {{/code}}
40
gru 4.16 41 === Spaces ===
gru 4.3 42
gru 4.16 43 Particularly when resolving loop variables, spaces are mandatory in certain constellations where this was not necessary before. This can be seen in the following example:
gru 4.3 44
gru 4.11 45 {{code language="xml"}}
gru 4.10 46 <xsl:if test="position()=1 and .!=''">
47 {{/code}}
48
gru 4.16 49 Spaces must be present here as follows:
gru 4.10 50
gru 4.11 51 {{code language="xml"}}
gru 4.10 52 <xsl:if test="position() = 1 and . != ''">
53 {{/code}}
54
gru 4.16 55 === Functions in For-Each Loops ===
gru 4.3 56
gru 4.16 57 The comparison of the //position()// variable e.g. within an xsl:if block could previously be done against a string with the position value.
gru 4.3 58
gru 4.11 59 {{code language="xml"}}
gru 4.14 60 <xsl:if test="position()='1'">
gru 4.9 61 {{/code}}
gru 4.3 62
gru 4.16 63 This never conformed to the standard, and is no longer possible. Instead, the comparison must be made with the pure numerical value:
gru 4.3 64
gru 4.11 65 {{code language="xml"}}
gru 4.12 66 <xsl:if test="position() = 1">
gru 4.9 67 {{/code}}
gru 4.3 68