NICE! thanks, Jens!! I like that there is a choice of ";" or "," as field separator. I bet you could add a choice of to quote or not, too.
position() < last()
I think I would use:
position() != last()
The option to use quotes or not is actually in there already:
<!-- if next line is active, strings will be wrapped in `"' -->
<!-- if next line is active, strings will not be wrapped at all -->
<!-- xsl:template name="wrap-strings"><xsl:text></xsl:text></xsl:template -->
Thanks, David! I missed that.
Thank you for this file. You have helped expand my understanding of XSLT greatly.
How do you actually use this file?
copy the XSLT and save to wherever you can find it. make sure the extension is .xsl (not .xsl or .xml)
when Export (as XML) from your database table/layout. when the dialog appears select FMPXMLRESULT and specify the XSLT (that you saved).
Thanks Beverly for that. Extension is .xslt. You might name it 'export.xslt'.
If file 'export.xslt' is in the same folder as your database, the path is 'file:export.xslt'.
I recommend using .xsl for the extension so that it's more apt to be read correctly by other apps.
And if the FM Export is scripted, the path can be any valid path for the platform.
I called it
Thank you again for your great contributions to the FM-XML community!
Sent from miPhone
Hi beverly and JensT (Jens),
A question for my future knowledge.
Is it, (for distribution purposes), possible to store the XSLT-code inside your FileMaker solution, (preferably in a text field), and export it prior to the XML-export?
I only need a yes or no answer and some indication on difficulty level for now, so that I know in advance, if it should come up in the future.
With best regards Magnus Fransson.
Magnus, the export-field-contents (script step) is apt to munge the text if stored in a global TEXT field. If you followed my example XSLT, I recommend that you store the XSLT file in a CONTAINER field, then export when needed with Export Field Contents.
no: as text in a text field
yes: as a document in a container field
This is a very nice way to output headers with CSV data.
thanks for posting your work,
Maybe one could add an xslt to export the xslt as UTF-8?
I would perhaps myself also amend JensT's (Jens') xslt to use variables and and xsl-ifs or something to set each variable options at the top of the document, just for readability and easier modification. I don't know xml as well as you do, but hopefully that could be doable?
If you put your xslt in text field, use UTF-16.
Put it in a container field and you don't need to make the XSLT as UTF-16.
David, I have a way (a FMP database actually) to create an "import" which creates the XSLT to import into FileMaker from other XML sources. It's not fool-proof and some understanding of XPath is still required. I use it to import DDR and other XML.
There is a published XSLT that helps with some of the import and XPath issues:
(also by Jens! thank you!)
And there is a published Export to Excel (with XSLT), see these threads:
https://community.filemaker.com/message/558207 (latest version here)
(thank you Doug!)
But creating XSLT to create XSLT is possible, just don't use Export-Field-Contents to get the encoding correct!
And I would also amend Jens latest example and place the variables at the top. But if it works, why change it?
Lots of good ideas... I'll see what I come up with if and when I need to implement this for a client (or if I just feel like "playing" with it).
Would really like to see this - but I am unable to download the file. Permissions are blocking the download.
You don't have permission to access "http://community.filemaker.com/external-link.jspa?" on this server.
see Flexible CSV export from FileMaker via XSLT | DJT Organisationsberatung
Here is a good example where "your favorite new function (in FMP16)", TextEncode() suddenly made things a lot simpler.
Precisely! that's why I "updated" my article:
(and it points back to the original link, still valuable to read:
Retrieving data ...