Есть две очевидные проблемы с предоставленным кодом :
Единственный шаблон в коде соответствует root
, но нет root
элемент вообще в предоставленном элементе XML - поэтому этот шаблон вообще не выбран для выполнения.
Элементы в предоставленном документе XML не имеют дочерних текстовых узлов.Так как в предоставленном коде XSLT нет другого шаблона, для обработки документа XML используются только встроенные шаблоны XSLT.Их эффект заключается в копировании на вывод только текстовых узлов - поэтому ничего не выводится в качестве вывода.
Решение :
Измените match='root'
на match='Root'
.
Добавьте правило идентификации, чтобы копировать каждый узел.
После применения этих двух исправлений к вашему коду он становится :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asp="http://test.com/asp"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Root">
<root>
<xsl:apply-templates select="asp:TableRow">
<xsl:sort select="@ID" data-type="text" order="ascending"/>
</xsl:apply-templates>
</root>
</xsl:template>
</xsl:stylesheet>
и при применении к предоставленному документу XML :
<Root xmlns:asp="http://test.com/asp" xmlns:meta="http://test.com/meta" xmlns:cc1="http://test.com/cc1">
<asp:TableRow ID="A02">
<asp:TableCell>
<asp:Localize ID="tagthreeCtrlNumberRes" meta:resourcekey="tagthreeCtrlNumberRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagthreeCtrlDescRes" meta:resourcekey="tagthreeCtrlDescRes" runat="server" />
<asp:Localize ID="tagthreeCtrlNoteRes" meta:resourcekey="tagthreeCtrlNoteRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:RadioButtonList ID="rblthreeCtrlRes0" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Yes" meta:resourcekey="rblthreeCtrl0Res0" Value="1" />
<asp:ListItem Text="No" meta:resourcekey="rblthreeCtrl1Res0" Value="0" />
<asp:ListItem Text="N/A" meta:resourcekey="rblthreeCtrl2Res0" Value="2" />
</asp:RadioButtonList>
<asp:RadioButtonList ID="rblthreeCtrlRes1" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Yes" meta:resourcekey="rblthreeCtrl0Res1" Value="1" />
<asp:ListItem Text="No" meta:resourcekey="rblthreeCtrl1Res1" Value="0" />
<asp:ListItem Text="N/A" meta:resourcekey="rblthreeCtrl2Res1" Value="2" />
</asp:RadioButtonList>
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdthreeCtrlRes" meta:resourcekey="cmdthreeCtrlRes" runat="server" OnClick="FormDataSave_Click" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmthreeCtrlRes" meta:resourcekey="lblAssmthreeCtrlRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblQualthreeCtrlRes" meta:resourcekey="lblQualthreeCtrlRes" runat="server" />
<asp:Button ID="cmdQualAcceptthreeCtrlRes" meta:resourcekey="cmdQualAcceptthreeCtrlRes" OnClick="cmdQualAccept_Click" runat="server" Text="Accept" Visible="True" />
</asp:TableCell>
<asp:TableCell />
<asp:TableCell />
</asp:TableRow>
<asp:TableRow ID="A01">
<asp:TableCell>
<asp:Localize ID="tagtwoCtrlNumberRes" meta:resourcekey="tagtwoCtrlNumberRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtwoCtrlDescRes" meta:resourcekey="tagtwoCtrlDescRes" runat="server" />
<asp:Localize ID="tagtwoCtrlNoteRes" meta:resourcekey="tagtwoCtrlNoteRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtxttwoCtrlRes0" meta:resourcekey="tagtxttwoCtrlRes0" runat="server" />
<asp:Textbox ID="txttwoCtrlRes0" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdtwoCtrlRes" meta:resourcekey="cmdtwoCtrlRes" runat="server" OnClick="FormDataSave_Click" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmtwoCtrlRes" meta:resourcekey="lblAssmtwoCtrlRes" runat="server" />
</asp:TableCell>
<asp:TableCell />
<asp:TableCell />
<asp:TableCell />
</asp:TableRow>
<asp:TableRow ID="A03">
<asp:TableCell>
<asp:Localize ID="tagoneCtrlNumberRes" meta:resourcekey="tagoneCtrlNumberRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagoneCtrlDescRes" meta:resourcekey="tagoneCtrlDescRes" runat="server" />
<asp:Localize ID="tagoneCtrlNoteRes" meta:resourcekey="tagoneCtrlNoteRes" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtxtoneCtrlRes0" meta:resourcekey="tagtxtoneCtrlRes0" runat="server" />
<asp:Textbox ID="txtoneCtrlRes0" runat="server" />
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdoneCtrlRes" meta:resourcekey="cmdoneCtrlRes" runat="server" OnClick="FormDataSave_Click" />
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmoneCtrlRes" meta:resourcekey="lblAssmoneCtrlRes" runat="server" />
</asp:TableCell>
<asp:TableCell />
<asp:TableCell />
<asp:TableCell />
</asp:TableRow>
</Root>
желаемый, правильный (отсортированный) результат выдается :
<?xml version="1.0" encoding="UTF-16"?>
<root xmlns:asp="http://test.com/asp">
<asp:TableRow ID="A01" xmlns:meta="http://test.com/meta" xmlns:cc1="http://test.com/cc1">
<asp:TableCell>
<asp:Localize ID="tagtwoCtrlNumberRes" meta:resourcekey="tagtwoCtrlNumberRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtwoCtrlDescRes" meta:resourcekey="tagtwoCtrlDescRes" runat="server"></asp:Localize>
<asp:Localize ID="tagtwoCtrlNoteRes" meta:resourcekey="tagtwoCtrlNoteRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtxttwoCtrlRes0" meta:resourcekey="tagtxttwoCtrlRes0" runat="server"></asp:Localize>
<asp:Textbox ID="txttwoCtrlRes0" runat="server"></asp:Textbox>
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdtwoCtrlRes" meta:resourcekey="cmdtwoCtrlRes" runat="server" OnClick="FormDataSave_Click"></asp:Button>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmtwoCtrlRes" meta:resourcekey="lblAssmtwoCtrlRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="A02" xmlns:meta="http://test.com/meta" xmlns:cc1="http://test.com/cc1">
<asp:TableCell>
<asp:Localize ID="tagthreeCtrlNumberRes" meta:resourcekey="tagthreeCtrlNumberRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagthreeCtrlDescRes" meta:resourcekey="tagthreeCtrlDescRes" runat="server"></asp:Localize>
<asp:Localize ID="tagthreeCtrlNoteRes" meta:resourcekey="tagthreeCtrlNoteRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:RadioButtonList ID="rblthreeCtrlRes0" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Yes" meta:resourcekey="rblthreeCtrl0Res0" Value="1"></asp:ListItem>
<asp:ListItem Text="No" meta:resourcekey="rblthreeCtrl1Res0" Value="0"></asp:ListItem>
<asp:ListItem Text="N/A" meta:resourcekey="rblthreeCtrl2Res0" Value="2"></asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="rblthreeCtrlRes1" RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Yes" meta:resourcekey="rblthreeCtrl0Res1" Value="1"></asp:ListItem>
<asp:ListItem Text="No" meta:resourcekey="rblthreeCtrl1Res1" Value="0"></asp:ListItem>
<asp:ListItem Text="N/A" meta:resourcekey="rblthreeCtrl2Res1" Value="2"></asp:ListItem>
</asp:RadioButtonList>
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdthreeCtrlRes" meta:resourcekey="cmdthreeCtrlRes" runat="server" OnClick="FormDataSave_Click"></asp:Button>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmthreeCtrlRes" meta:resourcekey="lblAssmthreeCtrlRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblQualthreeCtrlRes" meta:resourcekey="lblQualthreeCtrlRes" runat="server"></asp:Localize>
<asp:Button ID="cmdQualAcceptthreeCtrlRes" meta:resourcekey="cmdQualAcceptthreeCtrlRes" OnClick="cmdQualAccept_Click" runat="server" Text="Accept" Visible="True"></asp:Button>
</asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="A03" xmlns:meta="http://test.com/meta" xmlns:cc1="http://test.com/cc1">
<asp:TableCell>
<asp:Localize ID="tagoneCtrlNumberRes" meta:resourcekey="tagoneCtrlNumberRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagoneCtrlDescRes" meta:resourcekey="tagoneCtrlDescRes" runat="server"></asp:Localize>
<asp:Localize ID="tagoneCtrlNoteRes" meta:resourcekey="tagoneCtrlNoteRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="tagtxtoneCtrlRes0" meta:resourcekey="tagtxtoneCtrlRes0" runat="server"></asp:Localize>
<asp:Textbox ID="txtoneCtrlRes0" runat="server"></asp:Textbox>
</asp:TableCell>
<asp:TableCell>
<asp:Button ID="cmdoneCtrlRes" meta:resourcekey="cmdoneCtrlRes" runat="server" OnClick="FormDataSave_Click"></asp:Button>
</asp:TableCell>
<asp:TableCell>
<asp:Localize ID="lblAssmoneCtrlRes" meta:resourcekey="lblAssmoneCtrlRes" runat="server"></asp:Localize>
</asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
</root>