2

I'm new to XSLT and I'm wondering if it is possible to create a flexible XSLT template for processing any XML into CSV, where all I would need to do is change a variable in XSLT containing a separated list of XPath to include in the output? I need to use vanilla XSLT 1.0 with now external libraries. Something like the following, is this possible?

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csv="csv:csv">
    <xsl:output method="text" encoding="utf-8"/>
    <xsl:strip-space elements="*"/>
    <xsl:variable name="outputlist" select="/*/CUSTOMER_ID;/*/CUSTOMER_NAME;/*/ADDRESS/POSTCODE" />

<!--Split outputlist variable and use each split string as the template match to output those elements-->

</xsl:stylesheet>
paulzip
  • 86
  • 6
  • There is no dynamic XPath evaluation in XSLT 1.0. So, nice as the idea is to pass in a comma-separated list of different expressions, it won't work. Do you have a chance to work with XSLT 2.0? – Tomalak Jul 02 '13 at 20:55
  • Could you use a two pass method, where XSLT is used to interpret the CSV and generate another XSLT that is actually applied to the XML? – Ross Presser Jul 03 '13 at 04:18
  • possible duplicate of [Is it possible to use a Dynamic xPath expression in a xslt style sheet?](http://stackoverflow.com/questions/1551526/is-it-possible-to-use-a-dynamic-xpath-expression-in-a-xslt-style-sheet) – Paul Sweatte May 07 '14 at 19:09

0 Answers0