Question

I have a ditamap with several layers of nesting. It looks like this:

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

section1.ditampa looks like this:

<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 looks like this:

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

and subsection1.dita looks like this:

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

How can I select the titles for section1 and subsection1 in my transformation?

No correct solution

OTHER TIPS

Use document() function and apply-templates to navigate the hierarchy. This should work for you:

    <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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top