Re: uniPaaS 1.9d - Export through DataviewToXML


Andreas Sedlmeier
 

On Tue, Jul 30, 2019 at 11:30 PM, Steven Blank wrote:

This is purely a guess, but it seems to me that you could specify the necessary formatting in an XSLT file, and pass the name of this file in the DataviewToXML() function's fifth argument.

Implementing this solution, if possible, obviously assumes a certain amount of prior knowledge of XML Transformations which I, unfortunately, do not possess, but the scant online help/reference sounds promising.

The fifth column of DataviewToXML() is the name of the schema file (.xsd) which Magic will create when this parameter is not empty. This is not a XSLT file, which would be a XSL Template file , required for Something->Something transformations, like XML->XML or XML->XSV, ...
I have a sample program which shows usage of these xml technologies here: https://github.com/asedl/XpaDemo/blob/master/Doc/Samples/XpaTXML/OXMLT001_ExportCustomers.md

The program uses DataviewToXML() to create,
an XML File customers.xml
a XSD (Schema) file customers.xsd

The sample does not use the .xsd file. Magic would however use xsd datatypes different from "xs:string" when the original columns in data view differ from text (like dat, numeric, ...)
So, basically you could ask Excel to use that schema, when it imports the XML, thats just extremely complicated in Excel and a manual process
https://support.office.com/en-us/article/xml-schema-definition-xsd-data-type-support-7cd3c906-9b9e-4a64-ba77-1b23dc5c771c

Usage of XSLT the demo program shows too. Actually it uses XSLT to convert the customer.xml from above to .csv, and then actually opens that in Excel.
CSV does however not have data types at all so result would be the same: Excel would recognize the dates as text (unless you format it differently )
The XSLT file for that XML->CSC conversion would be that : https://github.com/asedl/XpaDemo/blob/master/Templates/Customerlist.xsl
Wont help, as mentioned and XML->XLSX (with XSLT) would be pretty complicated

In my opinion the best (and most straight-forward) approach to generate Excel with Magic is:
Generate Java source  like from a (merge) template which generates the Excel you want, compile it and run it.
Thats very simple programs.
 
Actually you can use any JVM language, even one which does not require compilation like groovy
http://jameskleeh.com/groovy-excel-builder/
Its based on Apache POI

Maybe I do that "Magic -> Excel" sample one day. Described it meanwhile pretty often here ^^
.NET is an option ofc too, only that its not really cools and when you do not have a framework like Apache POI, you need to have Excel installed.

Best regards,

Andreas




Join main@magicu-l.groups.io to automatically receive all group messages.