-
-
Save andrewminton/7e9fdae581c144aea06c to your computer and use it in GitHub Desktop.
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> | |
<page-navigation> | |
<section id="1" handle="pages">Pages</section> | |
<entry id="5398"> | |
<title-en handle="exhibitor-registration">Exhibitor Registration</title-en> | |
<title-cy handle="cofrestru-arddangoswr">Cofrestru Arddangoswr</title-cy> | |
<slug handle="exhibitor-registration">exhibitor-registration</slug> | |
<page> | |
<page handle="exhibitor-registration" id="92" parent-id="9">Exhibitor Registration</page> | |
</page> | |
</entry> | |
<entry id="3935"> | |
<title-en handle="conference-programme">Conference Programme</title-en> | |
<title-cy handle="rhaglen-y-gynhadledd">Rhaglen y Gynhadledd</title-cy> | |
<slug handle="conference-programme">conference-programme</slug> | |
<page> | |
<page handle="conference-programme" id="104" parent-id="4">Conference Programme</page> | |
</page> | |
</entry> | |
<entry id="3934"> | |
<title-en handle="registration">Registration</title-en> | |
<title-cy handle="cofrestru">Cofrestru</title-cy> | |
<slug handle="registration">registration</slug> | |
<page> | |
<page handle="registration" id="94">Registration</page> | |
</page> | |
</entry> | |
<entry id="3595"> | |
<page> | |
<page handle="delegate-registration" id="103" parent-id="94">Delegate Registration</page> | |
</page> | |
</entry> | |
<entry id="3593"> | |
<title-en handle="partnering">Partnering</title-en> | |
<title-cy handle="partneru">Partneru</title-cy> | |
<slug handle="partnering">partnering</slug> | |
<page> | |
<page handle="partnering" id="102">Partnering</page> | |
</page> | |
</entry> | |
</page-navigation> | |
<navigation> | |
<page handle="home" id="1"> | |
<name>Home</name> | |
<types> | |
<type>index</type> | |
</types> | |
</page> | |
<page handle="programme" id="4"> | |
<name>Programme</name> | |
<types> | |
<type>topnav</type> | |
</types> | |
<page handle="conference-programme" id="104"> | |
<name>Conference Programme</name> | |
</page> | |
<page handle="speakers" id="36"> | |
<name>Speakers</name> | |
</page> | |
<page handle="speakers-at-2014" id="115"> | |
<name>Speakers at 2014</name> | |
</page> | |
<page handle="presentations" id="114"> | |
<name>Speaker Presentations</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="workshops" id="71"> | |
<name>Workshops</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="speaker-presentations" id="73"> | |
<name>Speaker Presentations</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="dinner" id="14"> | |
<name>Gala Dinner</name> | |
</page> | |
<page handle="speakers-2013" id="79"> | |
<name>Speakers at 2013</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
</page> | |
<page handle="registration" id="94"> | |
<name>Registration</name> | |
<page handle="delegate-registration" id="103"> | |
<name>Delegate Registration</name> | |
</page> | |
<page handle="complementary" id="98"> | |
<name>Complementary</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="speaker" id="99"> | |
<name>Speaker</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="student-complementary" id="100"> | |
<name>Student Complementary</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="welsh-government-complementary" id="101"> | |
<name>Welsh Government Complementary</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="dinner-only-complementary" id="106"> | |
<name>Dinner Only Complementary</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="checkout" id="96"> | |
<name>Checkout</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="complete" id="88"> | |
<name>Registration Complete</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="formstack" id="76"> | |
<name>Formstack</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
<page handle="receipt" id="87"> | |
<name>Receipt</name> | |
<types> | |
<type>hidden</type> | |
<type>pdf</type> | |
</types> | |
</page> | |
</page> | |
<page handle="partnering" id="102"> | |
<name>Partnering</name> | |
</page> | |
<page handle="thank-you-registers" id="78"> | |
<name>Thank You</name> | |
<types> | |
<type>hidden</type> | |
</types> | |
</page> | |
</navigation> | |
</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:variable name="root" select="'http://domain.com'"/> | |
<xsl:variable name="url-language" select="'cy'"/> | |
<xsl:variable name="current-page-id" select="'1'"/> | |
<xsl:template match="data"> | |
<xsl:apply-templates select="navigation"/> | |
</xsl:template> | |
<xsl:template match="navigation"> | |
<xsl:variable name="roots"><xsl:value-of select="$root" /><xsl:text>/</xsl:text><xsl:value-of select="$url-language" /></xsl:variable> | |
<nav> | |
<ul> | |
<xsl:apply-templates select="page"> | |
<xsl:with-param name="path" select="$roots" /> | |
<xsl:with-param name="collapse" select="'no'" /> | |
</xsl:apply-templates> | |
</ul> | |
</nav> | |
</xsl:template> | |
<xsl:template match="page"> | |
<xsl:param name="path" select="''" /> | |
<xsl:param name="collapse" select="'no'" /> | |
<xsl:if test="not(types/type = 'hidden') and not(types/type = 'admin')"> | |
<li> | |
<xsl:if test="@id = $current-page-id"> | |
<xsl:attribute name="class">active</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="descendant::node()[@id = $current-page-id]"> | |
<xsl:attribute name="class">activeparent</xsl:attribute> | |
</xsl:if> | |
<xsl:choose> | |
<xsl:when test="types/type = 'topnav' and not(types/type = 'hidden')"> | |
<a href="" class="colour-{position()}"> | |
<xsl:call-template name="gettitle"> | |
<xsl:with-param name="pageid" select="@id"/> | |
</xsl:call-template> | |
</a> | |
</xsl:when> | |
<xsl:otherwise> | |
<a href="{$path}/{@handle}/" class="colour-{position()}"> | |
<xsl:call-template name="gettitle"> | |
<xsl:with-param name="pageid" select="@id"/> | |
</xsl:call-template> | |
</a> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:if test="page != '' and ($collapse = 'no' or descendant-or-self::node()[@id = $current-page-id])"> | |
<ul class="children-{position()}"> | |
<xsl:apply-templates select="page"> | |
<xsl:with-param name="path" select="concat($path,'/',@handle)" /> | |
<xsl:with-param name="collapse" select="$collapse" /> | |
</xsl:apply-templates> | |
</ul> | |
</xsl:if> | |
</li> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match="navigation" mode="sitemap"> | |
<xsl:variable name="roots"><xsl:value-of select="$root" /><xsl:text>/</xsl:text><xsl:value-of select="$url-language" /></xsl:variable> | |
<ul class="sitemap"> | |
<xsl:apply-templates select="page"> | |
<xsl:with-param name="path" select="$roots" /> | |
<xsl:with-param name="collapse" select="'no'" /> | |
</xsl:apply-templates> | |
</ul> | |
</xsl:template> | |
<xsl:template name="gettitle"> | |
<xsl:param name="pageid"/> | |
<xsl:apply-templates select="//page-navigation/entry[page/page/@id = $pageid]" mode="langtitle"/> | |
</xsl:template> | |
<xsl:template match="//page-navigation/entry" mode="langtitle"> | |
<xsl:choose> | |
<xsl:when test="$url-language ='cy'"> | |
<xsl:value-of select="title-cy"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="title-en"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment