Copied to clipboard

Flag this post as spam?

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


  • Barry 99 posts 187 karma points
    Oct 21, 2009 @ 14:10
    Barry
    0

    Any idea of what is wrong with this and is there a better way to debug XSLT

    <?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"
        exclude-result-prefixes="msxml umbraco.library">


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

      <xsl:template match="/">



        <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='idb_Testimonials']/node ">

          <xsl:if test="position() = 1">
            <div class="featured_product">
              <xsl:element name="img">
                <xsl:attribute name="src">
                  <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='companyLogo'], 'false')/data [@alias = 'umbracoFile']"/>
                </xsl:attribute>
                <xsl:attribute name="alt">
                  <xsl:value-of select="@nodeName"/>
                </xsl:attribute>
              </xsl:element>

              <div class="featured_pro_details">
                <span class="section_title">Featured Customer</span>
                <h2>
                  <xsl:value-of select="@nodeName"/>
                </h2>
                <p>
                  <xsl:value-of select="$currentPage/data [@alias = 'bodyText']"/>
                </p>

                <xsl:if test="$currentPage/data [@alias = 'downloadUrl'] !=''">
                  <div class="link_btn">
                    <a href="{$currentPage/data [@alias ='downloadUrl']}">
                      <span>&nbsp;</span>View Testimonial
                    </a>
                  </div>

                </xsl:if>
                <div>
                  <xsl:attribute name="class">clearfix</xsl:attribute>&nbsp;
                </div>
              </div>
            </div>
          </xsl:if>
        </xsl:for-each>


      </xsl:template>

    </xsl:stylesheet>

     

    Throws an error...

  • Dirk De Grave 4532 posts 5976 karma points MVP 3x admin
    Oct 21, 2009 @ 14:12
    Dirk De Grave
    0

    Barry,

    Cool huh, an error? what error? can you get us an error description please?

     

    Cheers,

    /Dirk

  • dandrayne 1138 posts 2262 karma points
    Oct 21, 2009 @ 14:18
    dandrayne
    1

    If you disable testing, save and it works anyway it's probably a getmedia thing.

    http://our.umbraco.org/forum/using/ui-questions/4685-umbracoLibraryGetMedia%28%29-Problem?p=0#comment16882

    A little more info would help though...

  • Barry 99 posts 187 karma points
    Oct 21, 2009 @ 14:22
    Barry
    0

    Error parsing XSLT file: \xslt\idb_FeaturedTestimonial.xslt

     

     

  • Barry 99 posts 187 karma points
    Oct 21, 2009 @ 14:23
    Barry
    0

    So, not a great error. I can save it (if I click the "ignore the errors, I know what I'm doing button") but I get that message.

  • Barry 99 posts 187 karma points
    Oct 21, 2009 @ 14:26
    Barry
    0

    So, not a great error. I can save it (if I click the "ignore the errors, I know what I'm doing button") but I get that message.

     

     

  • dandrayne 1138 posts 2262 karma points
    Oct 21, 2009 @ 14:52
    dandrayne
    0

    Try adding

    ?umbdebugshowtrace=true

    on the end of your page url

    Dan

  • Lee Kelleher 3874 posts 14547 karma points MVP 9x admin c-trib
    Oct 21, 2009 @ 17:11
    Lee Kelleher
    0

    I have the same guess/suspicion as Dan, the GetMedia call looks to be the culprit!

    Either the 'companyLogo' property isn't a numeric - try casting it as a number().

    ... or the GetMedia isn't returning a node ... which means that trying to access the 'umbracoFile' property will fail too!

    It would be better to assign the GetMedia to a variable, then check if it has the 'umbracoFile' property... like so:

    <xsl:value-of name="media" select="umbraco.library:GetMedia(number($currentPage/data[@alias='companyLogo']), 'false')" />
    <xsl:if test="count($media/data[@alias='umbracoFile']) &gt; 0">
         <xsl:value-of select="$media/data[@alias='umbracoFile']" />
    </xsl:if>

    Hope that helps?

    Cheers, Lee.

  • Barry 99 posts 187 karma points
    Oct 22, 2009 @ 09:28
    Barry
    0

    The problem I am getting is on this line:

                   <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='companyLogo'], 'false')/data [@alias = 'umbracoFile']"/>

     

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
    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)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
    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)

     

    I tried converting to a number (<xsl:value-of select="umbraco.library:GetMedia(number($currentPage/data[@alias='companyLogo']), 'false')/data [@alias = 'umbracoFile']"/> ) , that didnt work. THe companyLogo property is a Media Picker type. 

  • Barry 99 posts 187 karma points
    Oct 22, 2009 @ 09:50
    Barry
    0

    I am begining to think its the document type - idb_Testimonials is the parent, idb_Testimonial is the child - I am looping and companyLogo is part of the child type. Is my /node select incorrect?

  • Barry 99 posts 187 karma points
    Oct 22, 2009 @ 10:01
    Barry
    0

    In other words, the properties I am expecting are no available in my for-each

  • dandrayne 1138 posts 2262 karma points
    Oct 22, 2009 @ 10:26
    dandrayne
    0

    That would certainly cause the error.  As for your for-each

    <xsl:for-each select="$currentPage//node [@nodeTypeAlias ='idb_Testimonials']/node ">

    Should do the what you're after.  The // means all descendants so the ancestor-or-self part is spurious.

    You could also try taking out the getMedia and just printing

    <xsl:copy-of select="current()" />

    to see if you've got the correct node IDs before you pass it in to getMedia.

    Dan

     

  • Barry 99 posts 187 karma points
    Oct 22, 2009 @ 14:17
    Barry
    0

    ok, getting there.. the problem was I had $currentPage\data.. when it should have been just data.

Please Sign in or register to post replies

Write your reply to:

Draft