0
我试图分析出那有我有麻烦了几个特定的模板匹配情况下的FlowDocument属性的节点。XSLT匹配,其中一个孩子的孩子有一个值
所以,下面的XAML文档(这是通过打开Word,创建文本,然后复制到一个WPF的RichTextBox和提取的FlowDocument XAML中创建)。
<FlowDocument PagePadding="5,0,5,0" AllowDrop="True" NumberSubstitution.CultureSource="User" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Span xml:lang="en-us">
<Span.TextDecorations>
<TextDecoration Location="Underline" />
</Span.TextDecorations>
List Item 2
</Span>
<Run>
<Run.TextDecorations>
<TextDecoration Location="Underline" />
</Run.TextDecorations>
List Item 3
</Run>
</FlowDocument>
使用下面的XSLT,我想匹配的有有一个属性值“位置=下划线”子节点“TextDecoration”的跨度和运行的标签。
<?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"
xmlns:p="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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="p:FlowDocument">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="p:Run/Run.TextDecorations/TextDecoration[@Location='Underline']">
<u>
<xsl:apply-templates />
</u>
</xsl:template>
</xsl:stylesheet>
我知道上面的语句将无法正常工作,如果它实际上没有它可能会选择子节点,而不是说我希望得到的父节点。
我试图让输出如下:
<html xmlns:p="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<body>
<u>List Item 2</u>
<u>List Item 3</u>
</body>
</html>
我也有问题,只是匹配“号码:运行/ Run.TextDecorations”元素。使用Visual Studio,并逐步执行,它永远不会找到我试图找到的节点。
任何提示的欢迎!谢谢!
AHAH!命名空间的东西更有意义。这绝对是我错过的!谢谢! – Bryan 2012-02-03 18:20:39