clean.xsl

来自「a a a a a a a a a a a a a a a a a a a a 」· XSL 代码 · 共 88 行

XSL
88
字号
<?xml version="1.0"?><!-- Copyright (C) 2006 Ferdinand Prantl <prantl@users.sourceforge.net> -->
<!-- All rights reserved. -->
<!-- -->
<!-- This work is licensed under a Creative Commons Attribution 2.5 --><!-- License. See the attached file LICENSE for more information. --><!-- See also http://creativecommons.org/licenses/by/2.5/. --><!-- -->
<!-- See http://domino-javadoc.sourceforge.net for the most recent version -->
<!-- and more information. -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" />
<xsl:template match="description | table | row | cell | see">
  <xsl:element name="{name()}">
    <xsl:apply-templates />
  </xsl:element>
</xsl:template>

<xsl:template match="paragraph">
  <xsl:apply-templates select="*" />
</xsl:template>

<xsl:template match="code">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="paragraph[code]">
  <xsl:if test="not(preceding-sibling::paragraph[1]/code)">
    <xsl:text disable-output-escaping="yes">&lt;code&gt;</xsl:text>
  </xsl:if>
  <xsl:apply-templates select="*" />
  <xsl:if test="not(following-sibling::paragraph[1]/code)">
    <xsl:text disable-output-escaping="yes">&lt;/code&gt;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="paragraph[item]">
  <xsl:if test="not(preceding-sibling::paragraph[1]/item)">
    <xsl:text disable-output-escaping="yes">&lt;list&gt;
</xsl:text>
  </xsl:if>
  <xsl:apply-templates select="*" />
  <xsl:if test="not(following-sibling::paragraph[1]/item)">
    <xsl:text disable-output-escaping="yes">
&lt;/list&gt;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="text">
  <xsl:if test="not(preceding-sibling::text)">
    <xsl:element name="{name()}">
      <xsl:apply-templates select="../text" mode="join" />
    </xsl:element>
  </xsl:if>
</xsl:template>

<xsl:template match="title">
  <xsl:if test="not(preceding-sibling::title)">
    <xsl:element name="{name()}">
      <xsl:apply-templates select="../title" mode="join" />
    </xsl:element>
  </xsl:if>
</xsl:template>

<xsl:template match="item">
  <xsl:if test="not(preceding-sibling::item)">
    <xsl:element name="{name()}">
      <xsl:apply-templates select="../item" mode="join" />
    </xsl:element>
  </xsl:if>
</xsl:template>
<xsl:template match="item | text | title" mode="join">
  <xsl:apply-templates />
</xsl:template>
<xsl:template match="link">
  <xsl:element name="{name()}">
    <xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
    <xsl:apply-templates />
  </xsl:element>
</xsl:template>

</xsl:stylesheet>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?