-
-
Save iwyg/1880414 to your computer and use it in GitHub Desktop.
format css grid in xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
<entry>Text</entry> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" indent="yes" /> | |
<xsl:template match="/"> | |
<xsl:for-each select="data/entry"> | |
<div> | |
<xsl:attribute name="class"> | |
<xsl:text>grid_1</xsl:text> | |
<!-- every 1st item in a row --> | |
<xsl:if test="position() = 1 or (position() - 5) mod 4 = 0"> | |
<xsl:text> alpha</xsl:text> | |
</xsl:if> | |
<!-- every 4th item in a row --> | |
<xsl:if test="position() mod 4 = 0"> | |
<xsl:text> omega</xsl:text> | |
</xsl:if> | |
</xsl:attribute> | |
<xsl:call-template name="content"/> | |
</div> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="content"> | |
<p><xsl:value-of select="." /></p> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment