Skip to content

Instantly share code, notes, and snippets.

Created September 6, 2013 16:07
Show Gist options
  • Save anonymous/6466013 to your computer and use it in GitHub Desktop.
Save anonymous/6466013 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Sep 6, 2013.
    12 changes: 12 additions & 0 deletions master.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <data>
    <entry>
    <caption mode="formatted">
    <p>A fairly long looking <a href="http://www.stackoverflow.com">caption with a link</a> that goes to an external site.</p>
    </caption>
    </entry>
    <entry>
    <caption mode="unformatted">
    <![CDATA[A fairly long looking <a href="http://www.stackoverflow.com">caption with a link</a> that goes to an external site.]]>
    </caption>
    </entry>
    </data>
    35 changes: 35 additions & 0 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">

    <xsl:include href="https://gist.github.com/andrewminton/6465924/raw/72d6f6833a282da5ef0d2a8aa22087f71150a59e/nodetostring" />

    <xsl:output method="xml" indent="yes" />

    <xsl:template match="/">
    <xsl:apply-templates select="data/entry"/>
    </xsl:template>

    <xsl:template match="data/entry">
    <xsl:variable name="html-ready">
    <xsl:apply-templates select="caption/*"/>
    </xsl:variable>

    <!-- process contents of caption node-->
    <!-- stringify it -->

    <li>
    <xsl:copy-of select="$cap"/> //outside of attribute it works
    <img>
    <xsl:attribute name="src">/image/2/150/112/5<xsl:value-of select="@path"/>/<xsl:value-of select="filename"/></xsl:attribute>
    <xsl:attribute name="data-caption">
    <xsl:call-template name="nodetostring">
    <xsl:with-param name="node" select="$html-ready"/>
    <xsl:with-param name="esc-dblq" select="true()"/>
    </xsl:call-template>
    </xsl:attribute>
    </img>
    </li>
    </xsl:template>



    </xsl:stylesheet>