Copied to clipboard

Flag this post as spam?

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


  • glenn 5 posts 25 karma points
    Jan 15, 2011 @ 20:48
    glenn
    0

    List item style not displaying when used in xslt.

    Hiya Guys. Bit of a long shot this one.

    I have a style which works fine in html but when I try to implement the style in the standard topnavigation macro it breaks.

    Ive tried editing the tag in the xslt file to output html 4 and ive looked at my stylesheet over and over again.

    This works fine as part of the master page : -

    <ul class="art-menu">
                      <li><a href="#" class=" active"><span class="l"></span><span class="r"></span><span class="t">Home</span></a></li>
    </ul>

     

    In the xslt i have it like this :-

        <xsl:template match="/">
                  <ul class="art-menu">
       
            <!-- The fun starts here -->
                        <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = $level]/* [string(umbracoNaviHide) != '1' and @isDoc]">
                    <li>
                        <a href="{umbraco.library:NiceUrl(@id)}"><span class="l"></span><span class="r"></span><span class="t"> <xsl:value-of select="@nodeName"/> </span>                   </a>
                    </li>
                </xsl:for-each>
                </xsl:template>

    </ul>

    Any thoughts?

     

    Thanks

     

    G

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 21:04
    Daniel Bardi
    0

    Tags with no content between them are converted in xslt  (i.e. <span></span> will be come <span/>)

    Try inserting a non-breaking space (i.e. <span>&nbsp;</span>)

  • glenn 5 posts 25 karma points
    Jan 15, 2011 @ 21:13
    glenn
    0

    Hiya, Tried this - didnt work! LOL. Good suggestion thanks!

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 21:17
    Daniel Bardi
    0

    I thought about it and realized that I had the same issue with my website about a year ago.

    Here's the solution.

    <xsl:text disable-output-escaping="yes">
          &lt;span class="l"&gt;&lt;/span&gt;
          &lt;span class="r"&gt;&lt;/span&gt;
    </xsl:text>


  • aghy 129 posts 308 karma points
    Jan 15, 2011 @ 21:28
    aghy
    0

    Hi Glenn,

    I think if you try changing 

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

    to 

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

    it will work.

    Ben

  • glenn 5 posts 25 karma points
    Jan 15, 2011 @ 21:28
    glenn
    0

    Hiya!

     

    like this?

    <xsl:text disable-output-escaping="yes">

                        <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = $level]/* [string(umbracoNaviHide) != '1' and @isDoc]">
                                        <li><a href="{umbraco.library:NiceUrl(@id)}"> &lt;span class="l"&gt;&nbsp; &lt;/span&gt;&nbsp; &lt;span class="r"&gt;&nbsp; &lt;/span&gt; &lt;span class="t"&gt;<xsl:value-of select="@nodeName"/> &lt;/span&gt;</a></li>
                                </xsl:for-each>

    </xsl:text>

    Thanks.

  • glenn 5 posts 25 karma points
    Jan 15, 2011 @ 21:32
    glenn
    0

    I tried <xsl:output method="html" omit-xml-declaration="yes"/> and that didnt work sadly.

     

    I tried again now using the above code with &lt; &gt; for  < > and that didnt work either.

    :) Feeling a bit stupid as both what you have said make some sense! Whys it not working??

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 21:46
    Daniel Bardi
    0

    You got it a bit out of sequence.  Do the following:

    <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:text disable-output-escaping="yes">
            &lt;span class="l"&gt;&lt;/span&gt;
            &lt;span class="r"&gt;&lt;/span&gt;
          </xsl:text>
          <span class="t">
            <xsl:value-of select="@nodeName"/>
          </span>
        </a>
      </li>

     

     

  • aghy 129 posts 308 karma points
    Jan 15, 2011 @ 21:47
    aghy
    0

    Just noticed you have the second <ul> after the </xsl:template> try putting it inside the template and see if that helps

    Ben

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 21:57
    Daniel Bardi
    0

    Glenn,

    Aghy is is correct about the </ul> tag...

    Do what I posted above and move the </ul> to just before </xsl:template>

  • glenn 5 posts 25 karma points
    Jan 15, 2011 @ 22:06
    glenn
    0

    Hiya. I realy didnt want to be a pain in the neck with this guys sorry.

    I tried pasting the code above in and got this

     

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 22:28
    Daniel Bardi
    0

    Check the ignore error box and save again.

    Or you can wrap the code in an xsl:if statement to check for a value.

    It's a common error and can be ignored if your confident that the id will be available to the xslt.

    Could you paste your entire xslt here?  I'll give it a once over.

  • aghy 129 posts 308 karma points
    Jan 15, 2011 @ 22:28
    aghy
    0

     

    <?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" xmlns:HelloWorldExt="urn:HelloWorldExt" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets HelloWorldExt ">


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

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <href="{umbraco.library:NiceUrl(@id)}">
          <span class="l"></span>
          <span class="r"></span>
          <span class="t"><xsl:value-of select="@nodeName"/></span>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    This worked for me. From scratch I just created a new xslt with the template Navigation Prototype then copied your <li> ... </li> from your first post.

    Then changed the output method to html.

    All seems fine and in firefox with firebug I can see this in the html

    <li><a href="/page"><span class="l"></span><span class="r"></span><span class="t">Page</span></a></li>

    Ben

  • Daniel Bardi 927 posts 2562 karma points
    Jan 15, 2011 @ 22:30
    Daniel Bardi
    0

    Brilliant!

Please Sign in or register to post replies

Write your reply to:

Draft