Skip to content

Instantly share code, notes, and snippets.

@JakubMifek
Created February 8, 2018 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakubMifek/663a751a8d41fc3d46d8971cdf9ad593 to your computer and use it in GitHub Desktop.
Save JakubMifek/663a751a8d41fc3d46d8971cdf9ad593 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="windows-1250" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="panovnici">
<kings>
<xsl:apply-templates/>
</kings>
</xsl:template>
<xsl:template match="panovnik">
<king jmeno="{./jmeno}" od="{./panoval/od}" do="{./panoval/do}">
<xsl:call-template name="detail">
<xsl:with-param name="od" select="number(panoval/od)-1"/>
<xsl:with-param name="do" select="number(panoval/do)+1"/>
</xsl:call-template>
</king>
</xsl:template>
<xsl:template name="detail">
<xsl:param name="od"/>
<xsl:param name="do"/>
<xsl:variable name="events" select="doc('udalosti.xml')"/>
<xsl:for-each select="$events/udalosti/udalost">
<xsl:variable name="rok" select="number(@rok)"/>
<xsl:if test="$od &lt; $rok and $rok &lt; $do">
<udalost rok="{$rok}">
<xsl:value-of select="text()"/>
</udalost>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment