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