Reputation: 908
I have following problem that in a transformation (which is completely done in memory) should recieve an additional XSLT parameter containing another XML stream. It's like merging two XML documents together in memory. Writing it down on the drive and load it dynamically is not a possibility.
To develop I use .Net together with Visual Studio 2010.
Upvotes: 1
Views: 924
Reputation: 908
It's possible with .NET (i've tested 4.0). It worked with following code:
C#:
XslCompiledTransform proc = new XslCompiledTransform();
proc.Load(path + "test_parameter.xslt");
System.IO.TextWriter result = new StreamWriter(path + "result.html");
XmlDocument docA = new XmlDocument();
docA.Load(path + "documentA.xml");
XmlDocument docB = new XmlDocument();
docB.Load(path + "documentB.xml");
XsltArgumentList xsltArgs = new XsltArgumentList();
xsltArgs.AddParam("xmlDoc", "", docB);
proc.Transform(docA, xsltArgs, result);
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- THIS FILE GENERATES A SIMPLE HTML -->
<xsl:output method="html" indent="yes"/>
<xsl:param name="xmlDoc" />
<xsl:template match="/document">
<xsl:apply-templates select="$xmlDoc/foo/bar"/>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Reputation: 167561
Well which programming language, which XSLT processor do you use? What kind of parameters an XSLT processor takes is processor dependent, for instance with .NET's XslCompiledTransform you could certainly define a global parameter in your XSLT code and then use the XsltArgumentList to pass in an IXPathNavigable (i.e. XmlDocument or XPathDocument) created from your stream.
Upvotes: 1