The xsl file is used in.net as a small example of a navigation menu

  • 2020-06-01 09:36:36
  • OfStack


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="testweb.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <asp:Xml TransformSource="XSLTFile1.xslt" ID="minanva" runat="server"></asp:Xml>
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace testweb
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            minanva.DocumentContent = @"< Site navigation list   Visiting staff =''>
                                          < Site navigation   The site name =' The design plan '  Site number ='EPM'  A link to the site ='../NWEPDI.EPM.WEB/../Project/ProjectList.aspx?QueueType=EPM0101' />
                                          < Site navigation   The site name =' Design work '  Site number ='DDM'  A link to the site ='../MoEngineer/ProjectMgr.aspx' />
                                          < Site navigation   The site name =' The design process '  Site number ='DFM'  A link to the site ='../MoFlow/CWorkItemList.aspx?QueueType=DFM0101' />
                                          < Site navigation   The site name =' Printing management '  Site number ='PPM'  A link to the site ='../MoPrint/PrintMgr.aspx?QueueType=PPM0101' />
                                          < Site navigation   The site name =' Time management '  Site number ='WHM'  A link to the site ='../MoWorkHour/HourMgrPrj.aspx?QueueType=WHM0103' />
                                          < Site navigation   The site name =' The electronic archive '  Site number ='ARC'  A link to the site ='../MoArchieve/ProjectMgr.aspx?QueueType=ARC0101' />
                                          < Site navigation   The site name =' Statistical reports '  Site number ='SSM'  A link to the site ='../MoReports/ReportView.aspx?QueueType=SSM0101' />
                                          < Site navigation   The site name =' Data management '  Site number ='DAM'  A link to the site ='../MoDocument/ProjectFileMgr.aspx?QueueType=DAM0101' />
                                          < Site navigation   The site name =' System management '  Site number ='DSM'  A link to the site ='../MoAdmin/CommonRuleList.aspx?QueueType=DSM0101' />
                                        </ Site navigation list >";
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="// Site navigation list ">
    <div>
      <ul>
        <li> navigation </li>
        <xsl:for-each select=" Site navigation ">
          <li>
            <xsl:value-of select="@ The site name "/>
            <xsl:attribute name="id">
              <xsl:value-of select="@ Site number "/>
            </xsl:attribute>
            <xsl:attribute name="href">
              <xsl:value-of select="@ A link to the site "/>
            </xsl:attribute>
          </li>
        </xsl:for-each>
      </ul>
    </div>
  </xsl:template>
</xsl:stylesheet>


Related articles: