Wiki source code of XSL-Transformation
Hide last authors
author | version | line-number | content |
---|---|---|---|
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]]. | |
4.1 | 2 | ||
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/]]. | |
4.1 | 4 | ||
4.16 | 5 | == Supported versions of the XSLT and XPath standards == | |
4.1 | 6 | ||
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. | |
4.1 | 8 | ||
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. | |
4.1 | 10 | ||
4.16 | 11 | == Differences in the use of XSL transformations in {{formcycle/}} version 7.3 or higher == | |
4.3 | 12 | ||
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. | |
4.3 | 14 | ||
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. | |
4.3 | 16 | ||
4.16 | 17 | So far, the following problems are known: | |
4.7 | 18 | ||
4.16 | 19 | === Nested function calls === | |
20 | |||
21 | Function calls in the form | ||
22 | |||
4.7 | 23 | {{code language="xml"}} | |
4.6 | 24 | <xsl:variable name="dd"> | |
25 | <xsl:value-of select="format-number(substring-before($datestr,'.'), '0' )" /> | ||
26 | </xsl:variable> | ||
27 | {{/code}} | ||
4.7 | 28 | ||
4.16 | 29 | are no longer possible. Instead, you can cache the result of the inner function in variables, for example: | |
4.7 | 30 | ||
4.6 | 31 | {{code language="xml"}} | |
32 | <xsl:variable name="ddtemp"> | ||
33 | <xsl:value-of select="substring-before($datestr,'.')" /> | ||
34 | </xsl:variable> | ||
4.3 | 35 | ||
4.6 | 36 | <xsl:variable name="dd"> | |
37 | <xsl:value-of select="format-number($ddtemp, '0' )" /> | ||
4.8 | 38 | </xsl:variable> | |
4.6 | 39 | {{/code}} | |
40 | |||
4.16 | 41 | === Spaces === | |
4.3 | 42 | ||
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: | |
4.3 | 44 | ||
4.11 | 45 | {{code language="xml"}} | |
4.10 | 46 | <xsl:if test="position()=1 and .!=''"> | |
47 | {{/code}} | ||
48 | |||
4.16 | 49 | Spaces must be present here as follows: | |
4.10 | 50 | ||
4.11 | 51 | {{code language="xml"}} | |
4.10 | 52 | <xsl:if test="position() = 1 and . != ''"> | |
53 | {{/code}} | ||
54 | |||
4.16 | 55 | === Functions in For-Each Loops === | |
4.3 | 56 | ||
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. | |
4.3 | 58 | ||
4.11 | 59 | {{code language="xml"}} | |
4.14 | 60 | <xsl:if test="position()='1'"> | |
4.9 | 61 | {{/code}} | |
4.3 | 62 | ||
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: | |
4.3 | 64 | ||
4.11 | 65 | {{code language="xml"}} | |
4.12 | 66 | <xsl:if test="position() = 1"> | |
4.9 | 67 | {{/code}} | |
4.3 | 68 |