Wiki source code of SetFile
Version 2.1 by Outhman Moustaghfir on 2024/09/24 16:54
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | |||
2 | |||
3 | ==== Purpose: ==== | ||
4 | |||
5 | 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. | ||
6 | |||
7 | ==== How it Works: ==== | ||
8 | |||
9 | * The method takes XML content as input. | ||
10 | * It writes the XML content to a file. | ||
11 | * The file is saved in the database, and its file ID is returned for future reference. | ||
12 | |||
13 | ==== Usage Example: ==== | ||
14 | |||
15 | Consider the following XSLT transformation that calls the SetFile method: | ||
16 | |||
17 | |||
18 | {{code language="XML"}} | ||
19 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
20 | xmlns:ixf="http://www.ixPath.com/Function" | ||
21 | xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
22 | xmlns:ix="localFunction" | ||
23 | xmlns:fn="http://www.w3.org/2005/xpath-functions" | ||
24 | version="2.0"> | ||
25 | |||
26 | <xsl:output method="xml" indent="yes"></xsl:output> | ||
27 | |||
28 | <!-- Start of the Transformation --> | ||
29 | <xsl:template match="/"> | ||
30 | <iXDOC> | ||
31 | <!-- Define the XML content you want to save --> | ||
32 | <xsl:variable name="xmlContent"> | ||
33 | <MyXML> | ||
34 | <XML> | ||
35 | <iXDoc> | ||
36 | <Invoice> | ||
37 | <InvoiceHeader> | ||
38 | <InvoiceNumber>123456</InvoiceNumber> | ||
39 | <InvoiceDate>2019-01-01</InvoiceDate> | ||
40 | <InvoiceDueDate>2019-01-31</InvoiceDueDate> | ||
41 | <InvoiceCurrency>USD</InvoiceCurrency> | ||
42 | <InvoiceTotal>1000.00</InvoiceTotal> | ||
43 | <InvoiceTax>100.00</InvoiceTax> | ||
44 | <InvoiceNet>900.00</InvoiceNet> | ||
45 | <InvoicePaid>0.00</InvoicePaid> | ||
46 | <InvoiceBalance>900.00</InvoiceBalance> | ||
47 | <InvoiceStatus>Open</InvoiceStatus> | ||
48 | <InvoiceTerms>Net 30</InvoiceTerms> | ||
49 | <InvoiceNotes>Thank you for your business!</InvoiceNotes> | ||
50 | </InvoiceHeader> | ||
51 | <!-- Additional Invoice Items --> | ||
52 | </Invoice> | ||
53 | </iXDoc> | ||
54 | </XML> | ||
55 | </MyXML> | ||
56 | </xsl:variable> | ||
57 | |||
58 | <!-- Call the SetFile method and pass the XML content --> | ||
59 | <xsl:variable name="fileId" select="ixf:SetFile($xmlContent)"></xsl:variable> | ||
60 | |||
61 | <!-- Output the ID of the saved file --> | ||
62 | <returnedFiles> | ||
63 | <fileId> | ||
64 | <xsl:value-of select="$fileId"></xsl:value-of> | ||
65 | </fileId> | ||
66 | </returnedFiles> | ||
67 | </iXDOC> | ||
68 | </xsl:template> | ||
69 | |||
70 | </xsl:stylesheet> | ||
71 | |||
72 | {{/code}} | ||
73 | |||
74 | ==== Output: ==== | ||
75 | |||
76 | The method will return the unique ID of the file saved in the database, which can be accessed as shown in the XSLT example. | ||
77 | |||
78 | ==== ==== |