I have a two-step build process. In the first step I want to read configuration from a small XML file conforming to a well-defined XSD schema into an XSLT stylesheet which then outputs another intermediate XSLT stylesheet containing a list of <xsl:param />
elements with the data from the configuration XML. In the second step I want to run a transform on my main XML document with a stylesheet that references the output of the first step with <xsl:include>
.
I am stuck at the first step - because the XSLT transformer understands the <xsl:...>
schema, it won't blindly output elements in that schema as it would elements in literally every other schema.
I am using XSLT 1.0 because I am in .NET land.
I realise can (and probably will have to) write a console app to read the config XML and set the global params for the transform, but I was hoping to achieve the whole thing with XSLT...
I've tried fiddling with the namespaces in the <xsl:stylesheet>
element but I can't figure out a way to get it to emit a valid XSLT stylesheet.
Yes, you can use XSLT to generate XSLT, use <xsl:namespace-alias stylesheet-prefix = prefix | "#default" result-prefix = prefix | "#default" />
, see https://www.w3.org/TR/xslt-10/#section-Creating-Elements-and-Attributes.
As for being restricted to XSLT 1.0, Saxon HE exists for .NET framework from Saxonica https://www.nuget.org/packages/Saxon-HE and I have repackaged that for .NET 6 or 8 with https://www.nuget.org/packages/SaxonHE10Net31Xslt. But that is not relevant to namespace aliasing.