Subject:Generate an XSLT from an XML file for subsequent use on other XML Author:Gregory McKenzie Date:10 Oct 2007 11:55 AM
We are looking at taking an XML definition of a data table, generating an Excel XSLT from the XML definition of the data table. The generated Excel XSLT is then to be used on serialised data that is stored in the data table.
XML Definition of Data Table
----------------------------
Provided below is a cut down version of an XML definition of a table.
Generating an Excel XSLT from XML
---------------------------------
The Excel XSLT that we want to create takes the XML definition of the table and generates an XLST output that can then be used on XML data to output an Excel XML document. An example of the a cut down version of the Excel XSLT we are *trying to generate* is provided below.
Applying Generated XSLT to XML
------------------------------
The generated Excel XSLT will then be applied to serialized data stored in the table. An example of the XML data on which the XSLT is applied is provided below.
The XML above is transformed into an XML Excel document.
Issues
------
(A) Creating the XSLT that generates the Excel XSLT from the XML definition of the data table. The problems are outputting tags such as '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'.
Have identified some useful commands along the was such as:
Should we change our output method to TEXT instead of XML and generate the Excel XSLT that way. Alternatively, does somebody have an example of how we can use XSLT to generate XLST from XML?
Subject:Generate an XSLT from an XML file for subsequent use on other XML Author:(Deleted User) Date:10 Oct 2007 12:30 PM
Hi Gregory,
what you are trying to do is called "meta stylesheet", where an XSLT stylesheet has as output another XSLT stylesheet. The trick to make it work is to generate the XSLT keywords in a different namespace (like out:stylesheet, with "out" assigned to the "xxxxx" namespace URI), and then have a xsl:namespace-alias instruction to convert it to the real one.
See http://www.xml.com/pub/a/2003/11/05/xslt.html for a nuce tutorial on this technique.