XSL Parameters   

Xsl development is very similar to procedural development. We can think of the XSL tranformation as a function. This function has sub-procedures that can be called recursively (templates).

The xsl and its templates can take parameters. This variables hold values that can be used to shape the transformation.

In this example we show how to use an XML control. We pass an XsltArgumentList which will hold the parameters.

In additon we set the url of the xsl stylesheet (TransformSource) and the xml to be manipulated (DocumentContent). Then we trigger the transformation (DataBind)
 

 XSL Global parameters

void DataBindXml1()
{
    int numberOfItems = GetNumberOfItems();

    // The argument list is the object that we pass to the xsl tranformation
    // This object contains parameters and extensions that can be used in the xsl.
    Xml1.TransformArgumentList = new XsltArgumentList();

    // Adding a variable 'numOfElems' with a integer
    // This variable will limit the elements shown
    // This is a global variable
    Xml1.TransformArgumentList.AddParam("numOfElems", string.Empty, numberOfItems);

    // URL of the xsl
    Xml1.TransformSource = "/xsl/xsl2.xslt";

    // xml to be processed
    Xml1.DocumentContent = GetSource();

    Xml1.DataBind();            
}

 Resources

 XSLT



  
  
    

    
    
    
      
      
Published  on  2/22/2010  by  xsolon
  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:          
Tags: xsl | Categories:
Technorati Tags:
 

Links to this post

Comments

Title:
Receieve Notification:
Website:
Email:
Comments:

CAPTCHA Image Validation