Simple question, but is the solution?
I have a typical C# Application that runs "new XslCompiledTransform.Transform(...);" I am passing it param arguments, all of type string.
I want to pass it a param that is of type array: strings, or even lets say an array of objects.
I am using C# I am being limited to XSL 1.0.
How am I able to preform this task, in a clean way to avoid writing unnecessary code in .NET?
XsltArgumentList.AddParam accepts the following types for the value:
W3C Type Equivalent.NET Class (Type) String (XPath) String Boolean (XPath) Boolean Number (XPath) Double Result Tree Fragment (XSLT) XPathNavigator Node Set (XPath) XPathNodeIterator, XPathNavigator[] Node* (XPath) XPathNavigator
So you can't pass in an array, but you could construct an XML fragment with your values and pass it as XPathNavigator.
Example
string[] strings = new string[] { "a", "b", "c" };
XPathNavigator[] navigators =
strings.Select(s => new XElement("item", s).CreateNavigator()).ToArray();
XsltArgumentList args = new XsltArgumentList();
args.AddParam("items", "", navigators);
The XML nodes constructed look like this:
<item>a</item>
<item>b</item>
<item>c</item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With