XSLT Parameters: Watch Your Namespaces!

I found out the hard way that when you specify a namespace to go along with an XSLT parameter, that it had better match the namespace your transform uses, or else it will be invisible to you. Of course it fails silently.

Check out this code:

string xslpath = Server.MapPath("/vroot/xsl/my.xslt");
XPathDocument xml = new XPathDocument(response.GetResponseStream());

XslCompiledTransform trans = new XslCompiledTransform(true);
XsltArgumentList args = new XsltArgumentList();
args.AddParam("foo", "http://foo.com", "Some Value");
trans.Load(xslpath);

In that second-to-last line, if your transform is not using (or expecting?) the “http://foo.com” namespace, the input parameter will be essentially invisible.

It would be tres chic if you could specify a debug parameter that essentially says “throw a huge nasty error if you get parameters that you aren’t expecting to handle.”

Advertisements

0 Responses to “XSLT Parameters: Watch Your Namespaces!”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: