我試圖將一些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