Skip to content

Instantly share code, notes, and snippets.

@iwyg
Created March 18, 2013 18:46
Show Gist options
  • Save iwyg/5189703 to your computer and use it in GitHub Desktop.
Save iwyg/5189703 to your computer and use it in GitHub Desktop.
<data>
<images>
<entry>
<image>myimage1.jpg</image>
</entry>
<entry>
<image>myimage2.jpg</image>
</entry>
<entry>
<image>myimage3.jpg</image>
</entry>
</images>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="quote">
<xsl:text>"</xsl:text>
</xsl:variable>
<xsl:template match="/">
<xsl:variable name="imagelist">
[<xsl:apply-templates select="/data/images/entry/image" mode="imagelist"/>]
</xsl:variable>
<script>window.imageslist = <xsl:value-of select="$imagelist"/>;</script>
</xsl:template>
<xsl:template match="entry/image" mode="imagelist">
<xsl:value-of select="concat($quote, .,$quote)"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment