Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eddie Foreman 215 posts 288 karma points
    Jul 10, 2010 @ 23:29
    Eddie Foreman
    0

    Picking up accessKey property

    Hi

    I have a master document type with a property called accessKey.  My xslt is showing a parse error, when I add the test condition to check if the accessKey is emtpy on any pages nested under the home page.  The xslt works ok on the home page if I remove the test in the for-each statement.

    Would ideally like this to work across all pages, any ideas?

    Thanks

    Eddie

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <ul>
    <li>
    <xsl:if test="string($currentPage/@level) = '1'">
    <xsl:attribute name="class">active</xsl:attribute>
    </xsl:if>
    <a href="/">
    <xsl:attribute name="title">
    <xsl:text>Home</xsl:text>
    </xsl:attribute>
    <xsl:if test="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey']) = '')]">
    <xsl:attribute name="accesskey">
    <xsl:for-each select="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey'])='')]">
    <xsl:sort select="position()" data-type="number" order="descending"/>
    <xsl:if test="position()=1">
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:if>
    </xsl:for-each>
    </xsl:attribute>
    </xsl:if>
    <xsl:text>Home</xsl:text>
    </a>
    </li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/node [string(data[@alias='showInFooter']) = '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName" />
    <xsl:if test="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey']) = '')]">
    <xsl:attribute name="accesskey">
    <xsl:for-each select="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey'])='')]">
    <xsl:sort select="position()" data-type="number" order="descending"/>
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:for-each>
    </xsl:attribute>
    </xsl:if>
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>
  • Eddie Foreman 215 posts 288 karma points
    Jul 10, 2010 @ 23:44
    Eddie Foreman
    0

    Ok, think I've got it...

    But just noticed that the home page link is still displayed, whether the showInFooter is checked or not?

    Any ideas?

    Eddie


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <ul>
    <li>
    <xsl:if test="string($currentPage/@level) = '1'">
    <xsl:attribute name="class">active</xsl:attribute>
    </xsl:if>
    <a href="/">
    <xsl:attribute name="title">
    <xsl:text>Home</xsl:text>
    </xsl:attribute>
    <xsl:if test="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey']) = '')]">
    <xsl:attribute name="accesskey">
    <xsl:for-each select="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey'])='')]">
    <xsl:sort select="position()" data-type="number" order="descending"/>
    <xsl:if test="position()=1">
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:if>
    </xsl:for-each>
    </xsl:attribute>
    </xsl:if>
    <xsl:text>Home</xsl:text>
    </a>
    </li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/node [string(data[@alias='showInFooter']) = '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:attribute name="title">
    <xsl:value-of select="@nodeName" />
    </xsl:attribute>
    <xsl:if test="./data [@alias = 'accessKey'] != ''">
    <xsl:attribute name="accesskey">
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@nodeName" />
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>
  • Eddie Foreman 215 posts 288 karma points
    Jul 11, 2010 @ 00:06
    Eddie Foreman
    0

    Not sure if this is progress, but the showInFooter works on the home page.  But now the home page shows up on sub pages whether its checked or not : - (

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <ul>
    <xsl:if test="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'showInFooter']) != '1')]">
    <li>
    <xsl:if test="string($currentPage/@level) = '1'">
    <xsl:attribute name="class">active</xsl:attribute>
    </xsl:if>
    <a href="/">
    <xsl:attribute name="title">
    <xsl:text>Home</xsl:text>
    </xsl:attribute>
    <xsl:if test="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey']) = '')]">
    <xsl:attribute name="accesskey">
    <xsl:for-each select="$currentPage/ancestor-or-self::node[not(string(./data [@alias = 'accessKey'])='')]">
    <xsl:sort select="position()" data-type="number" order="descending"/>
    <xsl:if test="position()=1">
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:if>
    </xsl:for-each>
    </xsl:attribute>
    </xsl:if>
    <xsl:text>Home</xsl:text>
    </a>
    </li>
    </xsl:if>
    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/node [string(data[@alias='showInFooter']) = '1']">
    <li>
    <xsl:choose>
    <xsl:when test="position() = last()">
    <xsl:attribute name="class">last</xsl:attribute>
    </xsl:when>
    </xsl:choose>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:attribute name="title">
    <xsl:value-of select="@nodeName" />
    </xsl:attribute>
    <xsl:if test="./data [@alias = 'accessKey'] != ''">
    <xsl:attribute name="accesskey">
    <xsl:value-of select="./data [@alias = 'accessKey']" />
    </xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@nodeName" />
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft