Copied to clipboard

Flag this post as spam?

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


  • Christian W. Larsen 27 posts 49 karma points
    Jul 29, 2009 @ 16:36
    Christian W. Larsen
    0

    XsltContext needed

    Hi,

    I'm building a user control which queries content using XPath.I need to make use of Exslt extensions (and umbraco.library), so I added the namespace using XmlNamespaceManager. But I'm still getting an error: XsltContext needed

    What am I missing here?

    XPathNavigator nav = content.Instance.XmlContent.CreateNavigator();            

    XmlNamespaceManager nsMgr = new XmlNamespaceManager(nav.NameTable);
    nsMgr.AddNamespace("Exslt.ExsltStrings", "Exslt.ExsltStrings");

    XPathExpression expr = nav.Compile("./descendant::node[@nodeTypeAlias='Person' and contains(Exslt.ExsltStrings:uppercase(data[@alias='fornavn']), 'JENS')]");

    XPathNodeIterator doc = nav.Select(expr.Expression, nsMgr);

    This works fine without

    Exslt.ExsltStrings:uppercase(..)

    Best regards
    Christian

     

  • Tommy Poulsen 514 posts 708 karma points
    Jul 29, 2009 @ 17:24
    Tommy Poulsen
    0

    Hi Christian, just a quick suggestion here - could it be something with the expression contect of your data element (missing appropriate context) ? I wonder if you reference the right content node by default here. If you want to use something like $currentpage you probably have to find it using something like

    //node[@id=”currentNodeId“]

    where currentNodeId is the nodeid for the current node, available from ((umbraco.cms.businesslogic.datatype.DefaultData)_data).NodeId.

     

    >Tommy

     

     

  • Christian W. Larsen 27 posts 49 karma points
    Jul 29, 2009 @ 18:42
    Christian W. Larsen
    0

    Hi Tommy.

    Thank you for your answer. I don't think it has to do with the XPath it self.

    This works fine (all nodes of type person where 'fornavn' contains 'Jens''):

    ./descendant::node[@nodeTypeAlias='Person' and contains(data[@alias='fornavn'], 'Jens')]

    This doesn't work - because of the xslt-extension:

    ./descendant::node[@nodeTypeAlias='Person' and contains(Exslt.ExsltStrings:uppercase(data[@alias='fornavn']), 'JENS')]

    I've made my own xslt-extension and tried to reference it in the same way, but I still get the same error. Everything works fine in a plain xsl-file, but for different reasons I need to work with the nodes ind the usercontrol.

     

     

     

  • Tommy Poulsen 514 posts 708 karma points
    Jul 29, 2009 @ 22:16
    Tommy Poulsen
    0

    ahh, I see.

    I have not tried it myself, but you may need to do some extra work on the context. I found this link: http://msdn.microsoft.com/en-us/library/ms950806.aspx - maybe it's usefull (last section, putting it all together)

  • cardinal252 21 posts 33 karma points
    Aug 05, 2009 @ 10:35
    cardinal252
    0

    Assuming you are just after converting any case to upper case, you could actually use the xsl translate function if you wanted, e.g.

        <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
        <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
        <xsl:value-of select="translate('CaTeRpiLLar', $lcletters, $ucletters)"/>

    in my case, I store the two variables in a common xslt include. so I can call the translate on any template that includes it.

Please Sign in or register to post replies

Write your reply to:

Draft