2013-09-23 7 views
1

중첩의 여러 레이어가있는 ditamap이 있습니다. 그것은 다음과 같습니다중첩 된 ditamaps에서 XML 노드 선택

<map> 
    <title>This is the document title</title> 
    <mapref href="section1.ditamap" format="ditamap"/> 
    <mapref href="section2.ditamap" format="ditamap"/> 
</map> 

section1.ditampa은 다음과 같습니다

<map> 
    <topicref href="section1.dita"> 
     <topicref href="subsection1.dita"> 
      <topicref href="subsubsection1.dita"/> 
      <topicref href="subsubsection2.dita"/> 
      <topicref href="subsubsection3.dita"/> 
     </topicref> 
    </topicref> 
</map> 

section1.dita은 다음과 같습니다

<topic> 
    <title>This is the title for section 1</title> 
</topic> 

및 subsection1.dita은 다음과 같습니다

<topic> 
    <title>This is the title for subsection 1</title> 
</topic> 

어떻게해야합니까? 제 변형의 섹션 1과 서브 섹션 1의 제목을 선택하십시오.

+0

섹션 1.ditampa, section1.dita 및 subsection1.dita 모두 다른 파일입니까, 아니면 모두 함께 있습니까? –

답변

2

document() 함수와 apply-templates를 사용하여 계층 구조를 탐색하십시오. 이것은 당신을 위해 작동해야합니다 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     version="1.0"> 

    <xsl:template match="/map"> 
     <xsl:apply-templates select="mapref"/> 
    </xsl:template> 
    <xsl:template match="mapref"> 
     <xsl:apply-templates select="document(@href)/map/topicref"/> 
    </xsl:template>  
    <xsl:template match="topicref"> 
     <xsl:apply-templates select="document(@href)/topic"/> 
     <xsl:apply-templates select="topicref"/> 
    </xsl:template>  
    <xsl:template match="topic"> 
     <xsl:message> 
      <xsl:value-of select="title"/> 
     </xsl:message> 
    </xsl:template> 
    </xsl:stylesheet>