Xslt 将doxygen xml转换为有效且语义丰富的HTML

Xslt 将doxygen xml转换为有效且语义丰富的HTML,xslt,doxygen,Xslt,Doxygen,考虑由Doxygen生成的代码: 此函数通过应用以下规则,使用$param_inline(模板_字符串)的内容填充缓冲区: 小于$param_inline(strings)中%in后面的$param_inline(strings)中的元素数的任何数字都将引用到$param_inline(strings)中的索引。 如果%后面的任何符号不是有效的十进制数字,则将按原样对其进行撬拨。 如果包含NULCHAR的结果字符串长度超过$param_inline(buffer_length),则该字符串将被

考虑由Doxygen生成的代码:


此函数通过应用以下规则,使用$param_inline(模板_字符串)的内容填充缓冲区:
小于$param_inline(strings)中%in后面的$param_inline(strings)中的元素数的任何数字都将引用到$param_inline(strings)中的索引。
如果%后面的任何符号不是有效的十进制数字,则将按原样对其进行撬拨。
如果包含NULCHAR的结果字符串长度超过$param_inline(buffer_length),则该字符串将被截断。
如果无法转换%后面的数字,或者该数字大于或等于$param_inline(strings)中的元素数,则函数返回。
在任何情况下,缓冲区都以NULCHAR终止。
如果函数成功,则为非零,否则为零。
使用xslt,我想把它转换成像这样干净的HTML

此函数

  • 任何数字

  • 任何符号

  • ...

非零,如果…

您希望这项工作吗

XSLT1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>

<xsl:template match="/*">
    <html>
        <body>
            <xsl:apply-templates/>
        </body>
    </html>
</xsl:template>

<!-- rename -->
<xsl:template match="itemizedlist">
    <ul>
        <xsl:apply-templates/>
    </ul>
</xsl:template>

<!-- rename -->
<xsl:template match="listitem">
    <li>
        <xsl:apply-templates select="para/node()"/>
    </li>
</xsl:template>

<!-- default: keep as is -->
<xsl:template match="*">
    <xsl:copy>
        <xsl:apply-templates/>
    </xsl:copy>
</xsl:template>

<!-- exceptions: suppress -->
<xsl:template match="para[itemizedlist or descendant::para] | simplesect">
    <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

  • 应用于输入示例时,结果为:

    <html>
       <body>
          <para>This function fills buffer with the content of $param_inline(template_string) by applying to the following rules:</para>
          <ul>
             <li>Any number less than the number of elements in $param_inline(strings) following a % in reffers to an index in $param_inline(strings).</li>
             <li>Any symbol following a % that is not a valid decimal digit will be prited as it is.</li>
             <li>If the resulting string including NULCHAR is longer than $param_inline(buffer_length), the string is truncated.</li>
             <li>If a number following a % cannot be converted, or the number is larger than or equal to the number of elements in $param_inline(strings),
                the function returns.
             </li>
             <li>In any case, buffer is terminated with a NULCHAR.</li>
          </ul>
          <para>Non-zero if the function succeeded, zero otherwise.</para>
       </body>
    </html>
    
    
    此函数通过应用以下规则,使用$param_inline(模板_字符串)的内容填充缓冲区:
    
    • 小于$param_inline(strings)中%in后面的$param_inline(strings)中的元素数的任何数字都将引用到$param_inline(strings)中的索引
    • 如果%后面的任何符号不是有效的十进制数字,则将按原样对其进行撬拨
    • 如果包含NULCHAR的结果字符串长度超过$param_inline(buffer_length),则该字符串将被截断
    • 如果无法转换%后面的数字,或者该数字大于或等于$param_inline(字符串)中的元素数, 函数返回。
    • 在任何情况下,缓冲区都以NULCHAR终止
    如果函数成功,则为非零,否则为零。
    试试这个:

    输入XML:

    <detaileddescription>
      <para>This function fills buffer with the content of $param_inline(template_string) by applying to the following rules:</para>
      <para>The list
        <itemizedlist>
          <listitem>
            <para>Any number less than the number of elements in $param_inline(strings) following a % in reffers to an index in $param_inline(strings).</para>
          </listitem>
          <listitem>
            <para>Any symbol following a % that is not a valid decimal digit will be prited as it is.</para>
          </listitem>
          <listitem>
            <para>If the resulting string including NULCHAR is longer than $param_inline(buffer_length), the string is truncated.</para>
          </listitem>
          <listitem>
            <para>If a number following a % cannot be converted, or the number is larger than or equal to the number of elements in $param_inline(strings), the function returns.</para>
          </listitem>
          <listitem>
            <para>In any case, buffer is terminated with a NULCHAR.</para>
          </listitem>
        </itemizedlist>
      </para>
      <para><i>Italic text</i></para>
      <para><i>Italic text</i> normal text</para>
      <para><b>Bold text</b></para>
      <para><b>Bold text</b> normal text</para>
      <para>
        <simplesect kind="return">
          <para>Non-zero if the function succeeded, zero otherwise.</para>
        </simplesect>
      </para>
    </detaileddescription>
    
    
    此函数通过应用以下规则,使用$param_inline(模板_字符串)的内容填充缓冲区:
    名单
    小于$param_inline(strings)中%in后面的$param_inline(strings)中的元素数的任何数字都将引用到$param_inline(strings)中的索引。
    如果%后面的任何符号不是有效的十进制数字,则将按原样对其进行撬拨。
    如果包含NULCHAR的结果字符串长度超过$param_inline(buffer_length),则该字符串将被截断。
    如果无法转换%后面的数字,或者该数字大于或等于$param_inline(strings)中的元素数,则函数返回。
    在任何情况下,缓冲区都以NULCHAR终止。
    斜体
    斜体文本普通文本
    粗体文本
    粗体文本普通文本
    如果函数成功,则为非零,否则为零。
    
    XSLT:

    
    

    • 输出:

      <p>This function fills buffer with the content of $param_inline(template_string) by applying to the following rules:</p>
      <p>The list
          </p>
      <ul>
         <li>
            <p>Any number less than the number of elements in $param_inline(strings) following a % in reffers to an index in $param_inline(strings).</p>
         </li>
         <li>
            <p>Any symbol following a % that is not a valid decimal digit will be prited as it is.</p>
         </li>
         <li>
            <p>If the resulting string including NULCHAR is longer than $param_inline(buffer_length), the string is truncated.</p>
         </li>
         <li>
            <p>If a number following a % cannot be converted, or the number is larger than or equal to the number of elements in $param_inline(strings), the function returns.</p>
         </li>
         <li>
            <p>In any case, buffer is terminated with a NULCHAR.</p>
         </li>
      </ul>
      <p>
         <i>Italic text</i>
      </p>
      <p>
         <i>Italic text</i> normal text</p>
      <p>
         <b>Bold text</b>
      </p>
      <p>
         <b>Bold text</b> normal text</p>
      <p>Non-zero if the function succeeded, zero otherwise.</p>
      
      此函数通过应用以下规则,使用$param_inline(模板_字符串)的内容填充缓冲区:

      名单

      • 小于$param_inline(strings)中%in后面的$param_inline(strings)中的元素数的任何数字都将引用到$param_inline(strings)中的索引

      • 如果%后面的任何符号不是有效的十进制数字,则将按原样对其进行撬拨

      • 如果包含NULCHAR的结果字符串长度超过$param_inline(buffer_length),则该字符串将被截断

      • 如果无法转换%后面的数字,或者该数字大于或等于$param_inline(strings)中的元素数,则函数返回

      • 在任何情况下,缓冲区都以NULCHAR终止

      斜体

      斜体文本普通文本

      粗体文本

      粗体文本普通文本

      如果函数成功,则为非零,否则为零


      您的输出不是有效的HTML
      ul
      不得出现在
      p
      内,
      p
      不得出现在
      p
      内。您有多大信心包含
      itemizedlist
      段落不包含任何其他内容?dimitri应该知道。@user877329“dimitri应该知道。”哈?我想Doxygen的首席开发人员比其他任何人都更了解文档模型。您的测试的问题是,对于
      某些文本
      @michael.hor257k,u r correct,我将进一步检查代码以解决您的建议。实际上,所有内联元素的测试都应该为真。请在下面的答案区域查看我的最新更新。您检查过我的更新吗?
      
      <p>This function fills buffer with the content of $param_inline(template_string) by applying to the following rules:</p>
      <p>The list
          </p>
      <ul>
         <li>
            <p>Any number less than the number of elements in $param_inline(strings) following a % in reffers to an index in $param_inline(strings).</p>
         </li>
         <li>
            <p>Any symbol following a % that is not a valid decimal digit will be prited as it is.</p>
         </li>
         <li>
            <p>If the resulting string including NULCHAR is longer than $param_inline(buffer_length), the string is truncated.</p>
         </li>
         <li>
            <p>If a number following a % cannot be converted, or the number is larger than or equal to the number of elements in $param_inline(strings), the function returns.</p>
         </li>
         <li>
            <p>In any case, buffer is terminated with a NULCHAR.</p>
         </li>
      </ul>
      <p>
         <i>Italic text</i>
      </p>
      <p>
         <i>Italic text</i> normal text</p>
      <p>
         <b>Bold text</b>
      </p>
      <p>
         <b>Bold text</b> normal text</p>
      <p>Non-zero if the function succeeded, zero otherwise.</p>