0

I have a ASP.NET snippet where I would like xsl to apply to the xml. For some reason, I get runtime errors when I use TransformFile to try and transform the xml. Here is the aspx,

<%@ Import Namespace="System.Data" %>

<form runat="server">
          <asp:Repeater ID="myMusic" runat="server" DataSourceID="XmlDataSource1">
            <HeaderTemplate>
                <table class="songs">
                 <tr>
                        <th width="35%">Title</th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td><%# XPath("title")%></td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="alice_music_list.xml" TransformFile="cd_collection.xsl"         XPath="/music_songs/song" />
</form>

Can anyone please provide some pointers on why TransformFile does not work?
Thanks for your help.

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by dnanetwork
0

Well, I read the two links you sent, but I am not sure if this applies to my situation. My XML does display correctly when I have the XML and XSL attached withouut ASP.NET, so I don't thinn tk my XPath declarations on my XSL is a problem.

I ran the app again, and now I do get some things from my XSL, but I don't get any content regarding anything I have indicated in my XPath, even though I have declared them in XSL and indicated them in my ASP.NET page.

This is the portion of the code that I have now on display:

<HeaderTemplate>
                <table class="songs">
                 <tr>
                        <th width="35%">Title</th>
                        <th width="25%">Album</th>
                        <th width="20%">Artist</th>
                        <th width="20%">Date</th>
                    </tr>
            </HeaderTemplate>

What I don't have:

<ItemTemplate>
                <tr title='<%# XPath("category")%>'>
                    <td><%# XPath("title")%></td>
                    <td><%# XPath("album")%></td>
                    <td><%# XPath("artist")%></td>
                    <td><%# XPath("date/@added")%></td>
                </tr>
            </ItemTemplate>

Is there something going on in my ASP.NET, that my XML does display correctly with its XSL attached?

Thanks for your help.

0

Oh, I just figured out that I am supposed to do the xsl:sort before anything is processed.

Here it is:

<xsl:apply-templates select="music_songs/song">
                      <xsl:sort select="title"/>
                      <xsl:sort select="artist"/>
                       </xsl:apply-templates>

Everything is working now. Thanks.

0

Oh, I just figured out that I am supposed to do the xsl:sort before anything is processed.

Here it is:

<xsl:apply-templates select="music_songs/song">
                      <xsl:sort select="title"/>
                      <xsl:sort select="artist"/>
                       </xsl:apply-templates>

Everything is working now. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.