Export (0) Print
Expand All

XmlDataSource.TransformFile Property

Note: This property is new in the .NET Framework version 2.0.

Specifies the file name of an Extensible Stylesheet Language (XSL) file (.xsl) that defines an XSLT transformation to be performed on the XML data managed by the XmlDataSource control.

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

public:
virtual property String^ TransformFile {
	String^ get ();
	void set (String^ value);
}
/** @property */
public String get_TransformFile ()

/** @property */
public void set_TransformFile (String value)

public function get TransformFile () : String

public function set TransformFile (value : String)

Property Value

The absolute physical path or relative path of the XSL style sheet file that defines an XML transformation to be performed on the data contained in the Data or DataFile properties. The default value is String.Empty.

If both the TransformFile and Transform properties are set, the TransformFile property takes precedence and the data in the XSL style sheet file (.xsl) is used instead of the style sheet elements specified in the Transform property. If an XPath expression is set using the XPath property, it is applied after the XML data is transformed.

If you change the value of the Transform property, the DataSourceChanged event is raised. If caching is enabled and you change the value of Transform, the cache is invalidated.

The following code example demonstrates how to use an XmlDataSource control and a TreeView control to display transformed XML data on a Web form. The transformation is performed using the style sheet indicated by the TransformFile property. You can optionally supply transformation arguments for the style sheet using an XsltArgumentList. For more information, see the TransformArgumentList property.

No code example is currently available or this language may not be supported.
<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
  <BODY>

    <form runat="server">
      <asp:XmlDataSource
        id="XmlDataSource1"
        runat="server"
        datafile="bookstore.xml"
        transformfile="bookstore.xsl"/>

      <!- TreeView uses hierachical data, so the
          XmlDataSource uses an XmlHierarchicalDataSourceView
          when a TreeView is bound to it. -->

      <asp:treeview
        id="TreeView1"
        runat="server"
        datasourceid="XmlDataSource1">
        <databindings>
          <asp:treenodebinding depth="1" datamember="genre"
             textfield="name" valuefield="name"/>
          <asp:treenodebinding depth="2" datamember="book"
            textfield="title" valuefield="ISBN"/>
          <asp:treenodebinding depth="3" datamember="chapter"
            textfield="name" valuefield="num"/>
        </databindings>
      </asp:treeview>

    </form>
    
  </BODY>
</HTML>

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 XSL style sheet that performs the XML transformation has the following structure:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <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"/>
     </xsl:attribute>
     <xsl:attribute name="price">
       <xsl:value-of select="price"/>
     </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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft