Wiki source code of Aus XML importieren


Show last authors
1 {{figure image="xml_import_en.png" width="400" clear="h1"}}
2 Interface for setting the parameters of actions of type //Import from XML//.
3 {{/figure}}
4
5 Actions of the type //Import from XML// allow to fill form fields with the content of an XML document. To do this, for each form field to be populated, an [[XPath>>url:https://www.data2type.de/xml-xslt-xslfo/xpath/xpath-einfuehrung/]] [[specified>>url:http://www.zvon.org/xxl/XPathTutorial/General_ger/examples.html]] to an appropriate value in the XML.
6
7 == Parameters ==
8
9 === Details for importing form data ===
10
11 ; XML source
12 : Selection of an XML file, which should be used as XML source. Available are [[Formcycle files>>Formcycle.UserInterface.MyForms.Files]], [[Client files>>doc:Formcycle.UserInterface.FilesAndTemplates.Files]], files loaded via a URL (external resource), form record attachments or files from previous actions. See [[actions>>doc:Formcycle.Designer.Workflow.Actions.WebHome]] for a list of supported URL protocols.
13 ; XSL transformation
14 : Optionally, an XSL template can be specified which transforms the XML document before evaluation.
15
16 === Values to be set ===
17
18 ; Field name
19 : Name of the form element whose value will be set.
20 ; XPath
21 : XPath to a value in the XML document whose value is entered into the form field.
22
23 == Action variables ==
24
25 Actions of type //Import from XML// provide [[Action variables>>Formcycle.UserInterface.Variables||anchor="HActionvariables"]] which can be used in subsequent actions.
26
27 === Standard action variables ===
28
29 ; [%$<action name>.SUCCESS%]
30 : Return whether action was successfully executed. Returns Boolean (true/false).
31 ; [%$<action name>.RESULT%]
32 : Return all results provided by the action in structured form.
33
34 ; [%$<action name>.ERROR_CODE%]
35 : The error code thrown in case of an error in the action. Empty if no error occurred.
36 ; [%$<action name>.ERROR_MESSAGE%]
37 : The thrown error message in the action's error case. Empty if no error occurred.
38
39 === Action specific action variables ===
40
41 ; [%$<action name>.ERROR.message%]
42 : Error message returned if the PDF file could not be written to the file system, the specified URL does not match a valid format, no source file could be determined, the file format of the source file is not supported, an error occurs while processing the XML data, or the XSLT transformation was not successful.
43
44 == Example ==
45
46 For clarification, here is a brief example of how to use XPaths. For example, the XML document looks like this:
47
48 {{code language="XML"}}
49 <?xml version="1.0" encoding="UTF-8"?>
50 <xfc-data xfc-version="7.0.0" generation-date="2021-07-27 11:23:43.190 CET">
51 <processes>
52 <process process-uid="f1e677ad-012d-4586-884b-ac2ee029cb00" creation-date="2021-07-27 11:23:43.0 CET" project-name="XML" status="">
53 <form version="1">
54 <field name="upl1">
55 <plainValue><![CDATA[]]></plainValue>
56 <values count="0"/>
57 <label><![CDATA[]]></label>
58 </field>
59 <field name="tf1">
60 <plainValue><![CDATA[foobar]]></plainValue>
61 <values count="1">
62 <value index="0"><![CDATA[foobar]]></value>
63 </values>
64 <label><![CDATA[]]></label>
65 </field>
66 <field name="xf-action">
67 <plainValue><![CDATA[btnPrev]]></plainValue>
68 <values count="1">
69 <value index="0"><![CDATA[btnPrev]]></value>
70 </values>
71 <label><![CDATA[]]></label>
72 </field>
73 </form>
74 </process>
75 </processes>
76 </xfc-data>
77 {{/code}}
78
79 To select the value of the field named //tf1//, the following XPath can be used.
80
81 {{code language="XPath"}}
82 //processes//field[@name="tf1"]/plainValue/text()
83 {{/code}}