Copied to clipboard

Flag this post as spam?

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


  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 23, 2010 @ 22:20
    Dennis Aaen
    0

    Error when saving XSLT-file with parameters

    Hey Folks,

    I just started my second umbraco and I have run into some problems with my XSLT.

    I try to send a parameter, with my XSLT. But when i´m trying to save, my file, I got this error.

    Error occured
    System.ArgumentNullException: Value cannot be null.
    Parameter name: fieldName
    at umbraco.library.Item(Int32 nodeId, String fieldName, String displayValue)

    I have added this settings in the macro parameters: Alias: PropertyAlias Name: PropertyAlias Type: contentPicker

    My XSLT looks like this:

    I use the XSLT prototype ReleatedLinks

    <?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"/>
      
      <!-- Input the related links property alias here -->
        <xsl:variable name="propertyAlias" select="/macro/propertyAlias"/>
      
      <xsl:template match="/">

        <!-- The fun starts here -->
        <b><xsl:value-of select="johnsen_settings_footer_cases_heading"/></b>
        <ul>
          <xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link">
            <li>
              <xsl:element name="a">
                <xsl:if test="./@newwindow = '1'">
                  <xsl:attribute name="target">_blank</xsl:attribute>
                </xsl:if>
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="./@link"/>
                    </xsl:attribute>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="./@title"/>
              </xsl:element>
            </li>
          </xsl:for-each>
        </ul>

        <!-- Live Editing support for related links. -->
        <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />

      </xsl:template>

    </xsl:stylesheet>

    Can not figure out what I'm doing wrong. Hope some of you can help me.

    Best regards,

    Dennis Aaen

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 23, 2010 @ 22:59
    Chriztian Steinmeier
    0

    Hi Dennis,

    The reason you get this error when saving, is because Umbraco does kind of a test transformation before saving, to test for well-formedness etc. When doing that, there is no document to get the values from, so the call to Item() will fail.

    You can do a couple of things to fix it:

    1. Check the "Skip errors" box when saving the file

    2. Wrap an if statement around that line:

    <xsl:if test="$propertyAlias">
            ...
    </xsl:if>
    

    3. If you're not using Canvas mode you can just delete the line, as that's what it's needed for.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft