2017-04-10 4 views
0

확인 : 내가 처음 <pmEntry>부모의 선행 형제 감안할 때 XSLT

의 첫 번째 <dmRef>에서 콘텐츠 템플릿의 표를 호출 할

<pm> 
    <content> 
     <pmEntry> 
      <pmEntryTitle>Test</pmEntryTitle> 
      <dmRef> 
       <dmRefIdent> 
        <dmCode infoCode="100" infoCodeVariant="A" /> 
       </dmRefIdent> 
      </dmRef> 
     </pmEntry> 
     <pmEntry> 
      <pmEntryTitle>Test2</pmEntryTitle> 
      <dmRef> 
       <dmRefIdent> 
        <dmCode infoCode="200" infoCodeVariant="A" /> 
       </dmRefIdent> 
      </dmRef> 
     </pmEntry> 
     <pmEntry> 
      <pmEntryTitle>Test3</pmEntryTitle> 
      <dmRef> 
       <dmRefIdent> 
        <dmCode infoCode="300" infoCodeVariant="A" /> 
       </dmRefIdent> 
      </dmRef> 
     </pmEntry> 
    </content> 
</pm> 

을하지만이 예상되는 출력을 제공하지 않는, 때로는 부르고 다시 pmEntry 목록뿐만 아니라 첫 번째 pmEntry 목록에서 TOC.

<xsl:if test="ancestor::content[count(pmEntry) > 1]/pmEntry and count(../preceding-sibling::pmEntry) = 0"> 
    <xsl:call-template name="contents" /> 
</xsl:if> 

count(../preceding-sibling::pmEntry)이 pmEntries 목록의 중간에 0을 반환하는 이유를 알지 못합니다.

모든 도움이나 제안은 언제나 감사하겠습니다.

<xsl:template match="pmEntry/dmRef"> 
       <!-- Front Matter template infocode = 001 before TOC--> 
    <xsl:choose> 
      <xsl:when test="ancestor::content/pmEntry/dmRef/dmRefIdent/dmCode[@infoCode='001']"> 
        <xsl:apply-templates/> 
        <xsl:if test="dmRefIdent/dmCode/@infoCode='001'"> 
         <xsl:call-template name="contents" /> 
         <xsl:call-template name="figlist" > 
         </xsl:call-template> 
        </xsl:if> 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:choose> 
        <!--Only one pmEntry, at first dmRef create TOC --> 
         <xsl:when test="ancestor::content[count(pmEntry) = 1]/pmEntry and count(preceding-sibling::dmRef) = 0"> 
          <xsl:call-template name="contents" /> 
          <xsl:call-template name="figlist" /> 
         </xsl:when> 
         <!--Multiple pmEntry, at first create TOC --> 
         <xsl:when test="count(../preceding-sibling::pmEntry)=0 and count(../preceding-sibling::dmRef)=0"> 
          <xsl:call-template name="contents" /> 
          <xsl:call-template name="figlist" /> 
         </xsl:when> 
         <xsl:otherwise /> 
        </xsl:choose> 
        <xsl:apply-templates/> 
       </xsl:otherwise> 
      </xsl:choose>  
      </xsl:template> 

답변

0

당신이 시도 할 수 있습니다 :

이 전체 템플릿입니다. 그것이 당신이 원하는 것이 아니라면, 우리에게 당신의 산출물에 대한 아이디어를주십시오.

<xsl:template match="dmRef"> 
    <xsl:if test="count(../preceding-sibling::pmEntry)=0 and count(preceding-sibling::dmRef)=0"> 
    <xsl:call-template name="contents" /> 
    </xsl:if> 
</xsl:template> 
+0

감사의 말, 나는 귀하의 제안을 시도했으며, 여전히 두 개의 목차가 필요합니다. 하나는 처음에는 원했고 하나는 중간에있었습니다. 원하는 출력은 그 외계 TOC를 제거하는 것입니다. – Caroline

+0

필자는'' 여분의 TOC는 있지만 로직이 옳지 않은 것처럼 보입니다. – Caroline

+0

그래서 내가 게시 한 것은 시작하기위한 코드 조각 일뿐입니다. 아마 당신은 어떤 형태의 신원 기능도 필요로 할 것입니다. 코드를 게시 할 수 있습니까? 그리고 당신이 기대하고있는 XML의 모형이 있습니까? – Bluewood66

관련 문제