vendredi 31 juillet 2015

Associate captions with images

I have two images in my xml:

<imageGroup>
    <image xlink:href="mums528-i001-001.png"/>
    <caption>page 1</caption>
</imageGroup>
<imageGroup>
    <image xlink:href="mums528-i001-002.png"/>
    <caption>page 2</caption>
</imageGroup>

I want my xsl to put each caption with its associated image, rather than having the images appear together, then the captions. This is my xsl:

<xsl:if test="//imageGroup">
        <xsl:for-each select="//image/@xlink:href">
            <img>
                <xsl:attribute name="src">
                    <xsl:value-of select="."/>
                </xsl:attribute>
            </img>
        </xsl:for-each>
        <xsl:for-each select="//caption">
            <p><xsl:value-of select="."/></p>
        </xsl:for-each>
    </xsl:if>

How can I put the images and the captions inside the same xsl for-each statement?

Aucun commentaire:

Enregistrer un commentaire