Skip to content

Instantly share code, notes, and snippets.

@kognate
Created November 16, 2012 02:23
Show Gist options
  • Save kognate/4083374 to your computer and use it in GitHub Desktop.
Save kognate/4083374 to your computer and use it in GitHub Desktop.
xslt for generating list of segues
#!/bin/bash
# run this file by chmod 755 generate.sh
# and then (in the same path as the xslt files)
# ./generate.sh someoutputfile PATHTOSTORYBOARD
#
xsltproc segue-h.xslt $2 > ${1}.h
xsltproc segue-m.xslt $2 > ${1}.m
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output type="text" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="document"/>
</xsl:template>
<xsl:template match="document">
<xsl:apply-templates select="//segue/@identifier"/>
</xsl:template>
<xsl:template match="//segue/@identifier">
<xsl:text>extern NSString *const SEGUE_</xsl:text><xsl:value-of select="."/><xsl:text>;
</xsl:text>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output type="text" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="document"/>
</xsl:template>
<xsl:template match="document">
<xsl:apply-templates select="//segue/@identifier"/>
</xsl:template>
<xsl:template match="//segue/@identifier">
<xsl:text>NSString *const SEGUE_</xsl:text><xsl:value-of
select="."/><xsl:text> = @"</xsl:text><xsl:value-of select="."/><xsl:text>";
</xsl:text>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment