Copied to clipboard

Flag this post as spam?

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


  • Duc Tran 20 posts 41 karma points
    Jan 16, 2014 @ 02:51
    Duc Tran
    0

    Value from Split can't be used in if statement

    I'm trying ot get a value from a splitted CSV variable and test it against a querystring value but keep getting this error with no description of the error

    Error parsing XSLT file: \xslt\GalleryXSLT.xslt

    Here is the code:

    // value from querystring
    <xsl:variable name="selectedTag" select="umbraco.library:RequestQueryString('tag')"/>
    
    //the CSV values in a variable
    <xsl:variable name="items" select="umbraco.library:Split($tagsFromNodes,',')" />  
    
    <xsl:for-each select="$items//value">
        <xsl:if test="$selectedTag=current()">  //IT FAILS HERE
            //Do something
        </xsl:if> 
        <xsl:value-of select="umbraco.library:Replace(current(),' ',' ')"/>
    </xsl:for-each>
    

    If I reverse the test I get this error

    <xsl:if test="current()=$selectedTag">
    

    System.Xml.Xsl.XslTransformException: Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.

    Any ideas what I am doing wrong?

    Thanks.

    DT

    FYI, I'm on Umbraco 7

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 16, 2014 @ 08:07
    Dennis Aaen
    0

    Hi Duc,

    I just looked at your code. When I try to save your XSLT file in a Umbraco 7 I get this error message.

    System.Xml.Xsl.XslLoadException: The variable or parameter 'tagsFromNodes' is either not defined or it is out of scope. An error occurred at d:\web\localuser\dennisaaen.dk\umbraco\xslt\635254561292967509_temp.xslt(22,1).
    
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    So I think at you are using the $tagsFromNodes variable before you have declared it.

    Hope this can help you further.

    /Dennis

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jan 16, 2014 @ 09:08
    Chriztian Steinmeier
    0

    Hi Duc,

    Could you paste the entire stylesheet - or at least the contents of the <xsl:template> that surrounds your code - the errormessage you're getting is very much depending on the context, so will need to check that for what's going on.

    /Chriztian

  • Duc Tran 20 posts 41 karma points
    Jan 16, 2014 @ 12:22
    Duc Tran
    0

    Thanks for the reply. After copying the code here to share, I checked it again and then realised it was a coding error.

    My question is no longer valid.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies