XSLT中的单个标签下的多个标签的解析文本



我在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>

我有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时给出以下错误

命名空间中的元素"正文" http://www.w3.org/1999/xhtml'不能 包含文本。列出可能的要素的清单: 'http://www.w3.org/1999/xhtml:p H1 H2 H2 H3 H4 H4 H4 H6 DIV UL OL dl pre hr blockquote ...

我没有得到我在XSLT中应进行的更改,以解析" text()"。

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

使用模式了解XSLT可以使调试变得更加容易 - 它允许您在生产时验证XHTML输出,并且运气运气会为您提供产生有问题的内容的样式表中的位置。

相关内容

  • 没有找到相关文章

最新更新