我试图将一些Xaml转换为使用.NET XslCompiledTransform的HTML,并且遇到了使xslt与Xaml标签匹配的困难。例如与此XAML输入:xsl:模板匹配找不到匹配
<FlowDocument PagePadding="5,0,5,0" AllowDrop="True" NumberSubstitution.CultureSource="User" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph>a</Paragraph>
</FlowDocument>
而这个XSLT:
<?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="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="FlowDocument">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Paragraph" >
<p>
<xsl:apply-templates />
</p>
</xsl:template>
我得到这样的输出:
<html>
<body>
a
</body>
</html>
低于预期的相反:
<html>
<body>
<p>a</p>
</body>
</html>
莫非这是名称空间的问题?这是我第一次尝试xsl转换,所以我不知所措。
Thanks Robert - 我曾尝试将名称空间添加到xsl:stylesheet标记,但未将名称空间添加到匹配字段。 – dmo 2008-11-07 19:20:46