Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlDataSource.TransformArgumentList Property

Provides a list of XSLT arguments that are used with the style sheet defined by the Transform or TransformFile properties to perform a transformation on the XML data.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[<BrowsableAttribute(false)>]
abstract TransformArgumentList : XsltArgumentList with get, set
[<BrowsableAttribute(false)>]
override TransformArgumentList : XsltArgumentList with get, set

Property Value

Type: System.Xml.Xsl.XsltArgumentList
An XsltArgumentList object that contains XSLT parameters and objects to be applied to XML data when it is loaded by the XmlDataSource control. The default value is a null reference (Nothing in Visual Basic).

Set the TransformArgumentList property when the Transforming event is raised to ensure the XSLT parameters are available at the time that the XSLT transformation is applied to the XML data.

If the EnableCaching property is set to true and the TransformArgumentList property is set, the cache entries are not automatically invalidated when the parameters change in the transforms argument list. In that case, you must write code to invalidate the cache by setting the CacheKeyDependency property.

The following code example demonstrates how to use an XmlDataSource with a TreeView control to display transformed XML data. The XML transformation is performed using the style sheet indicated by the TransformFile property. Additionally, the style sheet uses transform arguments that are passed to the data source control in an XsltArgumentList object at run time. The code example demonstrates how to pass the XsltArgumentList to the data source control by handling the Transforming event with a custom event handler.

No code example is currently available or this language may not be supported.

The XML file in the code example has the following data:

<bookstore>
   <genre name="fiction">
     <book ISBN="0000000000">
       <title>Secrets of Silicon Valley</title>
       <price>12.95</price>
       <chapters>
         <chapter num="1" name="Introduction" />           
         <chapter num="2" name="Body" />          
         <chapter num="3" name="Conclusion" />
       </chapters>
     </book>
   </genre>
   <genre name="novel">
     <book genre="novel" ISBN="1111111111">
       <title>Straight Talk About Computers</title>
       <price>24.95</price>
       <chapters>
         <chapter num="1" name="Introduction" /> 
         <chapter num="2" name="Body" />
         <chapter num="3" name="Conclusion" />
       </chapters>
     </book>
   </genre>
</bookstore>

The transformation of the XML data is performed with the following style sheet.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:param name="purchdate"/>
 <xsl:template match="bookstore">
   <bookstore>
     <xsl:apply-templates select="genre"/>
   </bookstore>
 </xsl:template>
 <xsl:template match="genre">
   <genre>
     <xsl:attribute name="name">
       <xsl:value-of select="@name"/>
     </xsl:attribute>
     <xsl:apply-templates select="book"/>
   </genre>
 </xsl:template>
 <xsl:template match="book">
   <book>
     <xsl:attribute name="ISBN">
       <xsl:value-of select="@ISBN"/>
     </xsl:attribute>
     <xsl:attribute name="title">
       <xsl:value-of select="title"/>
       Price: <xsl:value-of select="price"/>
           15% discount if purchased by: <xsl:value-of select="$purchdate"/>      
     </xsl:attribute>
     <xsl:apply-templates select="chapters/chapter" />
   </book>
 </xsl:template>
 <xsl:template match="chapter">
   <chapter>
     <xsl:attribute name="num">
       <xsl:value-of select="@num"/>
     </xsl:attribute>
     <xsl:attribute name="name">
       <xsl:value-of select="@name"/>
     </xsl:attribute>
     <xsl:apply-templates/>
   </chapter>
 </xsl:template>
</xsl:stylesheet>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft