xls 和 xml 数据 排序 绑定 -原创

xls 和 xml 排序

 

 

xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type= "text/xsl" href= "test.xsl"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<languages>
    <languageList>
        <language name="Chinese" >
            <codeList >
                <code >zh</code>
            </codeList>
        </language>
        <language name="English" >
            <codeList >
                <code >en</code>
            </codeList>
        </language>
    </languageList>
</languages>

 

 

xsl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="UTF-8"?>
 
<!--
    Document   : test.xsl
    Created on : 2013年12月26日, 下午9:37
    Author     : ideaam
    Description:
        Purpose of transformation follows.
-->
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
 
  <xsl:variable name="vsortKey" select="'name'"/>
  <xsl:variable name="vsortOrder" select="'descending'"/>
 
 
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*">
        <xsl:sort select="/language[name()=$vsortKey] | @*[name()=$vsortKey]" data-type="text" order="{$vsortOrder}"/>
        <xsl:sort select="@*"  />
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

 

WebForm DataBind:

1
2
3
4
5
6
7
<asp:ListView ID="ListView1" runat="server" DataSourceID="XmlDataSource1">
     <ItemTemplate>
         <label><%#Eval("name")%></label>
     </ItemTemplate>
     </asp:ListView>
     <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/test.xml"
          XPath="//language" TransformFile="~/test.xsl"></asp:XmlDataSource>

 

posted @   iDEAAM  阅读(311)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
点击右上角即可分享
微信分享提示