1

I am using Saxon to perform a transformation of an XML document in my .NET application. I am passing in a parameter to my xslt document but I have no idea how to use it in my template.

Here is what I have done so far:

var zipcode = _db.AXCustomers.FirstOrDefault(x => x.ACCOUNTNUM == accNo).ZIPCODE;
transformer.SetParameter(new QName("CustomerZipCode"), new XdmAtomicValue(zipcode));

Then in my xslt document I am specifying the parameter like so:

<xsl:template match="/">
    <xsl:param name="CustomerZipCode" />

But when I try to use the parameter, nothing appears. I am using it like so:

<xsl:value-of select="substring-before($CustomerZipCode, ' ')"/>

But nothing is output even though my zipcode does contain a value

CallumVass
  • 11,288
  • 26
  • 84
  • 154

1 Answers1

1

You are using xsl:param inside a xsl:template element, it means that the param is for the template. The parameter you are passing from the .net code is a transformer parameter and related xsl:param must be placed at the top level of the stylesheet, into the xsl:stylesheet element.

kan
  • 28,279
  • 7
  • 71
  • 101