xml - How to add "common" functions to multiple XSLT files? -
i've written following code saxon.api.xslttransformer
object can use transform xml document. transformationxslt
string contains xslt.
xmldocument document = new xmldocument(); document.loadxml(transformationxslt); saxon.api.xdmnode input = processor.newdocumentbuilder().build(document); saxon.api.xsltcompiler xsltcompiler = processor.newxsltcompiler(); saxon.api.xsltexecutable xsltexecutable = xsltcompiler.compile(input); saxon.api.xslttransformer xslttransformer = xsltexecutable.load(); xslttransformers.add(transformation.name, xslttransformer); return xslttransformer;
suppose have dozen or more xslt templates want able call any xslt. how can make them available resulting saxon.api.xslttransformer
object.
suppose have this:
string commonxslt = "<xsl:param name="use_this_in_every_xslt">foo!</xsl:param>";
how can make "common" xslt available transformer?
the usual way xslt write stylesheet modules not depending on xslt processor api, rather put code in stylesheet (e.g. module1.xsl
) , include or import in other stylesheets using xsl:include
or xsl:import
. see http://www.w3.org/tr/xslt20/#combining-modules details. need make sure module complete, well-formed xslt document , not single xsl:param
element.
of course if have xslt available in memory strings need make sure http://www.saxonica.com/documentation/dotnetdoc/saxon/api/xsltcompiler.html#xmlresolver set xsltcompiler resolves relative url load module string.
Comments
Post a Comment