Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在xslt中解析单个标记下的多个标记的文本_C#_Xml_Xslt_Xslt 1.0_Spire.doc - Fatal编程技术网

C# 在xslt中解析单个标记下的多个标记的文本

C# 在xslt中解析单个标记下的多个标记的文本,c#,xml,xslt,xslt-1.0,spire.doc,C#,Xml,Xslt,Xslt 1.0,Spire.doc,我在使用xml和xslt。我有以下xml <book> <book-part book-part-type="chapter" book-part-number="1" id="PT-161_ch_1"> <book-meta> <book-title-group> <book-title>Software&#x002d;Hardware Integration in Automotive Product

我在使用xml和xslt。我有以下xml

<book>
  <book-part book-part-type="chapter" book-part-number="1" id="PT-161_ch_1">
 <book-meta>
 <book-title-group>
        <book-title>Software&#x002d;Hardware Integration in Automotive Product Development</book-title>
      </book-title-group>
    </book-meta>
    <book-part-meta>
     <title-group>
    <title>
      <bold>2008-21-0043</bold>
      </title>
      </title-group>
     </book-part-meta>
<body>
   <sec id="ch1.1">
    <title>INTRODUCTION</title>
    <p>The trends of increased functionality, improved performance, reduced size and increased complexity continue to evolve in the automotive electronics market. New system architectures are providing the performance and memory capability necessary to keep up with the hardware performance and software growth required by the automotive market trends. All of this technology growth implies a higher product cost and increased engineering effort required to develop these new products.</p>
   </sec>
</body>

软件&x002d;汽车产品开发中的硬件集成
2008-21-0043
介绍
在汽车电子市场中,功能增加、性能提高、尺寸减小和复杂性增加的趋势继续发展。新的系统架构提供了与汽车市场趋势所需的硬件性能和软件增长保持同步所需的性能和内存能力。所有这些技术增长都意味着开发这些新产品所需的更高的产品成本和更多的工程工作

我有以下XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>

<xsl:template match="book-part">

<html>
  <head>

  </head>
  <body>
    <xsl:for-each select="book-meta">
      <p>
        <b>
          <xsl:value-of select="book-title-group/book-title"/>
        </b>
      </p>
    </xsl:for-each>
    <xsl:for-each select="book-part-meta">
      <p>
        <b>
          <xsl:value-of select="title-group/title"/>
        </b>
      </p>
    </xsl:for-each>
    <xsl:for-each select="body/sec">
      <p>
        <ol>
          <li>
        <b>
          <div>
          <xsl:value-of select="title"/>
          </div>
        </b>
          </li>
        </ol>
        <xsl:for-each select="p">
          <xsl:value-of select="text()"/>
        </xsl:for-each>
      </p>
      <xsl:for-each select="sec">
        <p>
          <ol>
            <li>
              <b>
                <div>
            <xsl:value-of select="title"/>
                </div>
              </b>
            </li>
          </ol>
          <xsl:value-of select="p"/>
        </p>
      </xsl:for-each>
    </xsl:for-each>
    </body>
    </html>
  </xsl:template>
  <xsl:template match="text()[parent::xref]"/>
</xsl:stylesheet>


  • 我必须将此XML转换为EPub。为了将其转换为Epub,我首先使用XSLCompiledTransform将其转换为html,然后使用html转换为xhtml,然后使用Spire.doc将此xhtml转换为Epub

    但在将xhtml转换为Epub Spire.doc时,会出现以下错误

    命名空间“”中的元素“body”无法删除 包含文本。预期的可能元素列表: 'h1 h2 h3 h4 h5 h6分区在前 区块报价


    我不知道为了解析“text()”我应该在xslt中做什么样的更改。

    我认为您的样式表生成了无效的XHTML,因此第二个处理阶段(XHTML到Epub的转换)拒绝了它。识别这个问题的第一步是查看您生成的XHTML


    使用支持模式的XSLT可以使调试变得更加容易-它允许您在生成XHTML输出时验证XHTML输出,幸运的是,它会在样式表中为您提供生成错误内容的位置。

    您显示的XSLT似乎与XML不匹配。XSLT希望匹配XML中不存在的“图书部分”。理想情况下,问题需要显示用于生成“Spire.doc”输入的XML和XSLT。谢谢此外,不可能通过显示的XML输入获得显示的错误。在您转换的实际XML输入中,必须有作为
    body
    元素的子元素的文本内容(这是禁止的)。@Tim C我已经更新了确切的XML,现在请解释我面临的问题的原因。但是,您更新的XML输入没有意义,并且格式不正确。