2013-09-23 3 views
1

У меня есть ditamap с несколькими слоями вложенности. Это выглядит следующим образом:Выбор узла XML в вложенных ditamaps

<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() и применяйте шаблоны для перемещения по иерархии. Это должно сработать для вас:

<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> 
Смежные вопросы