Show last authors
1 ==== Purpose: ====
2
3 The SetFile method is designed to store XML content in a database by saving it as a file and returning the file's unique identifier.
4
5 ==== How it Works: ====
6
7 * The method takes XML content as input.
8 * It writes the XML content to a file.
9 * The file is saved in the database, and its file ID is returned for future reference.
10
11 ==== optional parameters: ====
12
13 * **fileName** (optional): Specifies a custom name for the saved file. If not provided (null or empty), the file will be saved with its unique file ID as the name.
14 * **folder** (optional): Defines the folder where the file will be stored (e.g., "work", "out", etc.). If not specified (null or empty), the file will be placed in the default "work" folder.
15 * **synchrone **(optional): Defaults to false. Determines whether the file is set synchronously or asynchronously
16
17 {{code language="XML"}}
18 SetFile(xmlContent,fileName,folder)
19 {{/code}}
20
21 ==== Usage Example: ====
22
23 Consider the following XSLT transformation that calls the SetFile method:
24
25
26 {{code language="XML"}}
27 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28 xmlns:ixf="http://www.ixPath.com/Function"
29 xmlns:xs="http://www.w3.org/2001/XMLSchema"
30 xmlns:ix="localFunction"
31 xmlns:fn="http://www.w3.org/2005/xpath-functions"
32 version="2.0">
33
34 <xsl:output method="xml" indent="yes"></xsl:output>
35
36 <!-- Start of the Transformation -->
37 <xsl:template match="/">
38 <iXDOC>
39 <!-- Define the XML content you want to save -->
40 <xsl:variable name="xmlContent">
41 <MyXML>
42 <XML>
43 <iXDoc>
44 <Invoice>
45 <InvoiceHeader>
46 <InvoiceNumber>123456</InvoiceNumber>
47 <InvoiceDate>2019-01-01</InvoiceDate>
48 <InvoiceDueDate>2019-01-31</InvoiceDueDate>
49 <InvoiceCurrency>USD</InvoiceCurrency>
50 <InvoiceTotal>1000.00</InvoiceTotal>
51 <InvoiceTax>100.00</InvoiceTax>
52 <InvoiceNet>900.00</InvoiceNet>
53 <InvoicePaid>0.00</InvoicePaid>
54 <InvoiceBalance>900.00</InvoiceBalance>
55 <InvoiceStatus>Open</InvoiceStatus>
56 <InvoiceTerms>Net 30</InvoiceTerms>
57 <InvoiceNotes>Thank you for your business!</InvoiceNotes>
58 </InvoiceHeader>
59 <!-- Additional Invoice Items -->
60 </Invoice>
61 </iXDoc>
62 </XML>
63 </MyXML>
64 </xsl:variable>
65
66 <!-- Call the SetFile method and pass the XML content -->
67 <xsl:variable name="fileId" select="ixf:SetFile($xmlContent)"></xsl:variable>
68
69 <!-- Output the ID of the saved file -->
70 <returnedFiles>
71 <fileId>
72 <xsl:value-of select="$fileId"></xsl:value-of>
73 </fileId>
74 </returnedFiles>
75 </iXDOC>
76 </xsl:template>
77
78 </xsl:stylesheet>
79
80 {{/code}}
81
82 ==== Output: ====
83
84 The method will return the unique ID of the file saved in the database, which can be accessed as shown in the XSLT example.
85
86 ==== ====
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian