Hello!
I would like to request a new method on the XsltArgumentList class, allowing
developers to check the presense of a key/value pair. If you try to add a
key/value pair that has already been defined in the list, an exception is
thrown.
Rather than using the "GetParam" method, it would be usefull to have a
method called ".Exists" available on the XsltArgumentList. I think this
allows for cleaner and more readable code. Or, perhaps even better - an
overloaded "AddParam" that allows you to force an existing key/value pair to
be overridden with a new value.
Imagine a class API that provides an XsltArgumentList populated with the
contents of the Request.QueryString collection (and possible the
Request.Form too). The XsltArgumentList object is then passed to an
XsltTransform object, allowing the Xslt document to reference all the
key/value pairs.
Without making changes to the C# code, the developer has got an easiy way to
pass data forth and back between the Xslt document.
However, in the class API that builds the XsltArgumentList, an exception is
thrown if an equal key/value pair is defined in both the Request.QueryString
and Request.Form collection.
Comments are welcome!
The code below illustrates the current implementation:
C#:
XsltArgumentList RequestArgList = new XsltArgumentList();
// Iterate QueryString collection
foreach (string thisKey in Request.QueryString)
{
// The current key is not defined in the list
if (RequestArgList.GetParam(thisKey, "") == null)
{
// Add current key to list
RequestArgList.AddParam(thisKey, "",
Request.QueryString[thisKey].ToString());
}
}
I'd like to do the following:
C#:
XsltArgumentList RequestArgList = new XsltArgumentList();
// Iterate QueryString collection
foreach (string thisKey in Request.QueryString)
{
// The current key is not defined in the list
if (RequestArgList.Exists(thisKey) == false)
{
// Add current key to list
RequestArgList.AddParam(thisKey, "",
Request.QueryString[thisKey].ToString());
}
}
--
venlig hilsen / with regards
anders borum
--