C# 如何使用XSLT将标准WPF RichTextBox中的Richtext图像转换为HTML?

C# 如何使用XSLT将标准WPF RichTextBox中的Richtext图像转换为HTML?,c#,html,wpf,xslt,richtextbox,C#,Html,Wpf,Xslt,Richtextbox,如何使用XSLT将标准WPF RichTextBox中的Richtext图像转换为HTML? 基于,我创建了以下XSLT文件。到目前为止,它可以转换粗体、斜体、下划线、字体系列、字体大小和字体颜色。现在我仍然需要它将Richtext中的图像转换为HTML 不必考虑图像对齐 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.or

如何使用XSLT将标准WPF RichTextBox中的Richtext图像转换为HTML?

基于,我创建了以下XSLT文件。到目前为止,它可以转换粗体、斜体、下划线、字体系列、字体大小和字体颜色。现在我仍然需要它将Richtext中的图像转换为HTML

不必考虑图像对齐

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    exclude-result-prefixes="msxsl x">

  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

  <xsl:template match="x:Section[not(parent::x:Section)]">
    <div>
      <xsl:apply-templates select="node()"/>
    </div>
  </xsl:template>

  <xsl:template match="x:Section">
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <xsl:template match="x:Paragraph">
    <p>
      <xsl:apply-templates select="node()"/>
    </p>
  </xsl:template>

  <xsl:template match="x:Run">
    <xsl:variable name="style">
      <xsl:if test="@FontStyle='Italic'">
        <xsl:text>font-style:italic;</xsl:text>
      </xsl:if>
      <xsl:if test="@FontWeight='Bold'">
        <xsl:text>font-weight:bold;</xsl:text>
      </xsl:if>
      <xsl:if test="contains(@TextDecorations, 'Underline')">
        <xsl:text>text-decoration:underline;</xsl:text>
      </xsl:if>
      <xsl:if test="@FontSize != ''">
        <xsl:text>font-size:</xsl:text>
        <xsl:value-of select="@FontSize" />
        <xsl:text>pt;</xsl:text>
      </xsl:if>
      <xsl:if test="@FontFamily != ''">
        <xsl:text>font-family:</xsl:text>
        <xsl:value-of select="@FontFamily" />
        <xsl:text>;</xsl:text>
      </xsl:if>
      <xsl:if test="@Foreground != ''">
        <xsl:text>color:#</xsl:text>
        <xsl:value-of select="substring(@Foreground, 4)"/>
        <xsl:text>;</xsl:text>
      </xsl:if>
    </xsl:variable>
    <span>
      <xsl:if test="normalize-space($style) != ''">
        <xsl:attribute name="style">
          <xsl:value-of select="normalize-space($style)"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:value-of select="text()"/>
    </span>
  </xsl:template>
</xsl:stylesheet>


字体:斜体; 字体大小:粗体; 文字装饰:下划线; 字体大小: pt; 字体系列: ; 颜色:# ;
您可以添加此模板-将其包含在最终模板上方


您的意思是将此
添加到
标题中吗?您可能需要添加更多解释。
  <xsl:template match="x:Image">
    <img src="@Source" />
  </xsl:template>