2014-01-30 7 views
0

xml 및 xslt에서 작업 중입니다. 나는 XSLTxslt의 단일 태그에서 여러 태그의 텍스트를 구문 분석

내가 EPUB이 XML을 변환해야
<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

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

을 다음했다. Epub로 변환하기 위해, 먼저 XSLCompiledTransform을 사용하여 html로 변환 한 다음 xhtml로 html로 변환 한 다음 Spire.doc를 사용하여이 xhtml을 Epub로 변환합니다.

하지만 가능한 요소 text.List 포함되지 수 같은 오류를 'http://www.w3.org/1999/xhtml'네임 스페이스

요소 '신체'를주고 EPUB의 Spire.doc에 XHTML 변환 동안 기대 값 : 'http://www.w3.org/1999/xhtml:p H1 H2 H3을 H4 H5 H6에 DIV UL OL DL 전 시간 인용구 ...

나는 ") (텍스트"를 분석하기 위해 XSLT에서해야 변경 정확히 무엇을 얻고 있지 않다.

+1

표시 한 XSLT가 XML과 일치하지 않는 것 같습니다. XSLT는 XML에 존재하지 않는 "책 파트"와 일치하는 것을 찾고 있습니다. 이상적으로 질문은 "Spire.doc"에 대한 입력을 생성하는 데 사용되는 XML 및 XSLT를 표시해야합니다. 감사! –

+0

또한 표시하는 XML 입력에 표시되는 오류를 가져 오는 것은 불가능합니다. 실제 XML 입력에서'body' 요소의 자식으로 텍스트 내용이 있어야합니다 (금지되어 있습니다). –

+0

@Tim C 정확한 XML을 업데이트했습니다. 지금 당면한 문제의 이유를 설명해주십시오. – user

답변

0

귀하의 스타일 시트가 잘못된 XHTML을 생성했다고 생각합니다. 따라서 XHTML을 처리하여 (XHTML에서 Epub로 변환) 두 번째 단계에서이를 거부합니다. 이 문제를 확인하는 첫 번째 단계는 생성 한 XHTML을 보는 것입니다.

스키마 인식 XSLT를 사용하면 디버깅을 훨씬 쉽게 할 수 있습니다. XHTML 출력이 생성되는 동안 유효성을 검사 할 수 있으며 행운과 함께 문제가되는 내용을 생성하는 스타일 시트의 위치를 ​​제공합니다.