WinRT 中的 XsltProcessor 不起作用,但 Windows 10 通用应用程序中的相同 class 可以

XsltProcessor in WinRT does not work but the same class in a Windows 10 Universal App does

下面的代码适用于我在 Windows 10 通用应用程序中尝试过的所有示例。但在 Windows 8.1 应用程序中,它不会从 xsl 模板输出任何静态 html 内容,除了 xml 文档声明和内部 xml.

关于它在 WinRT 中为何表现如此的任何想法?

    private static string TransformToString(string xml, string xsl)
    {
        var xmlDocument = new XmlDocument();
        xmlDocument.LoadXml(xml);

        var xslDocument = new XmlDocument();
        xslDocument.LoadXml(xsl);

        var processor = new XsltProcessor(xslDocument);

        //string transformation = processor.TransformToString(xmlDocument.LastChild);
        string transformation = processor.TransformToString(xmlDocument);

        return transformation;
    }

范例xml:

<library xmlns='http://www.microsoft.com'>
    <book>
        <chapter></chapter>
        <chapter>
            <section>
                <paragraph a="b">1</paragraph>
                <paragraph a="b">2</paragraph>
            </section>
        </chapter>
    </book>
</library>

示例 xsl:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:m="http://www.microsoft.com">
<xsl:template match="/">
    <html><body><table>
    <tr>
    <td>Attribute</td>
    <td>Value</td>
    </tr>
    <xsl:for-each select="m:library/m:book/m:chapter/m:section/m:paragraph">
    <tr>
    <td><xsl:value-of select="@a"/></td>
    <td><xsl:value-of select="."/></td>
    </tr>
    </xsl:for-each>
    </table></body></html>
</xsl:template>

结果

<?xml version="1.0" encoding="utf-8"?>12

问题是用 xmlDocument.LastChild 而不是 xmlDocument 调用 TransformToString