Reputation: 11025
I want to use the document function of xslt to pull the input xml since I have multiple input xml files to parse. But the XslCompiledTransform
class does not seem to have a method to invoke the transformation without an input xml explicitly specified. I was seeking a response from gurus here, else I will have to do it in an unclean way.
Upvotes: 1
Views: 196
Reputation: 25034
If an XSLT stylesheet ignores its input, you can supply any XML document you like as the input. (You do have to specify some input, because the XSLT processing model assumes some input.)
One approach is to put an XML document where it can be referred to, with contents like this:
<dummy>This is an XML document used as dummy input to
the stylesheet ignores-input.xsl. Don't delete it!</dummy>
Another slightly more elegant approach is favored among the XSLT programmers I know; it sometimes has the added advantage of completely bewildering later maintenance programmers who haven't seen the idiom before (so use it carefully if the maintenance programmers can find out where you live). Specify the XSLT stylesheet itself as the input document. The XSLT stylesheet already has to be visible to the code invoking the transformation, and it's an XML document, so it satisfies the requirements without the need to make a new dummy XML document.
Upvotes: 1