Copied to clipboard

Flag this post as spam?

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


  • Doogie Talons 183 posts 318 karma points
    Feb 10, 2011 @ 17:53
    Doogie Talons
    0

    Help with translation to multinode picker.

    Hi there I have been working with some output appliing templates like....

    <xsl:apply-templates select="$currentPage/* [@isDoc]" mode="Product">

    links to this...

    <xsl:template match="* [@isDoc]" mode="Product">

     

     

    And want to work with the multinode picker but getting my brain in a twist...

    Here is what I am getting at... that doesn't work.

    <xsl:apply-templates select="$currentPage/specialOffers/MultiNodePicker/nodeId" mode="Product">

    to link to...

    <xsl:template match="nodeId" mode="Product">

     

    If anyone could help I would be greatful.

    Cheers


    Doogie.


  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Feb 10, 2011 @ 22:14
    Chriztian Steinmeier
    0

    Hi Doogie,

    Could you be alittle more specific? What happens when you run the macro - do you get unexpected output? Is your "nodeId" template never hit?

    Based upon what I see, I would expect the nodeId to just be that (an id) which you would then need to fetch the actual XMLnode for, either using the extension function GetXmlNodeById() or just by finding it from $currentPage with an XPath, e.g:

    <xsl:template match="nodeId" mode="Product">
        <!-- Find with extension -->
        <xsl:variable name="extNode" select="umbraco.library:GetXmlNodeById(.)" />
    
        <!-- Find by XPath -->
        <xsl:variable name="xpathNode" select="$currentPage/ancestor-or-self::root//*[@id = .]" />
    
        <!-- Pick either one for scrutinizing: -->
        <textarea rows="8" cols="40"><xsl:copy-of select="$xpathNode" /></textarea>
    </xsl:template>

    Note: When using the XPath you must optimize with all the steps you know, e.g. use:

     $currentPage/ancestor::Website/Page[@nodeName = 'Pages To Relate']/*[@id = .]

    - if you know that all the related pages reside under the "Pages To Relate" node etc.

    XPath method will not throw an exception if the node doesn't exist (or is an empty string) - whereas the extension method will yell at you, instantly...

    Let us know your findings...

    /Chriztian

  • Doogie Talons 183 posts 318 karma points
    Feb 11, 2011 @ 11:39
    Doogie Talons
    0

    I put the word test in the template and it is not hit.

    Hmmmm it's hard to describe what I want to achieve as I am new (ish) to xslt.

    The extNode code you gave me fills the text boxes with what I want in the template. But I down know what is happening.

    Basicall when I call a template using all the the sub nodes of the current page I use..

     

    <xsl:apply-templates select="$currentPage/* [@isDoc]" mode="Product">

    ..............

    <xsl:template match="* [@isDoc]" mode="Product">

    <xsl:value-of select="@nodeName"/>

    </xsl:template>

    But I wanted instead to call the nodes from the multipicker in uComponents I thought this would work...

     

    <xsl:apply-templates select="$currentPage/specialOffers/MultiNodePicker/nodeId" mode="Product">

    ...........................

    <xsl:template match="nodeId" mode="Product">

    <xsl:value-of select="@nodeName"/>

    </xsl:template>

     

    When I used your code

    <xsl:template match="nodeId" mode="Product">
           
    <!-- Find with extension -->
           
    <xsl:variable name="extNode" select="umbraco.library:GetXmlNodeById(.)" />
           
           
    <!-- Find by XPath -->
           
    <xsl:variable name="xpathNode" select="$currentPage/ancestor-or-self::root//*[@id = .]" />
           
           
    <!-- Pick either one for scrutinizing: -->
           
    <textarea rows="8" cols="40"><xsl:copy-of select="$xpathNode" /></textarea>
    </xsl:template>

    I got a bunch of text boxes each with the right data in but couldn't then apply it the way the first example works.

     

    Hmmm my lack of knowledge means my question sounds backwards...

  • Doogie Talons 183 posts 318 karma points
    Feb 11, 2011 @ 12:20
    Doogie Talons
    0

    OK see if this explanation helps.

    This works fine. It's where I call a list from the currentpage's sub pages.

    ---------------------------------------------------------------------------------------------------------------------

     

    <?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:teacommerce="urn:teacommerce"
      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 teacommerce Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <div class="page-title"><xsl:value-of select="$currentPage/@nodeName"/></div>
    <xsl:apply-templates select="$currentPage/* [@isDoc]" mode="Product">
    </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="* [@isDoc]" mode="Product">
    <h1><xsl:value-of select="productTitle"/></h1>
    </xsl:template>

    </xsl:stylesheet>

    ---------------------------------------------------------------------------------------------------------------------

    I would like to achieve the same result from the contents of a MultiNodePicker...

     

    I thought something like this would work.

    ---------------------------------------------------------------------------------------------------------------------

    <?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:teacommerce="urn:teacommerce"
      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 teacommerce Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <div class="page-title"><xsl:value-of select="$currentPage/@nodeName"/></div>
    <xsl:apply-templates select="$currentPage/specialOffers/MultiNodePicker/nodeId" mode="Product">
    </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="nodeId" mode="Product">
    <h1><xsl:value-of select="productTitle"/></h1>
    </xsl:template>

    </xsl:stylesheet>

    ---------------------------------------------------------------------------------------------------------------------

     

    It doesn't all the template at all.

  • Doogie Talons 183 posts 318 karma points
    Feb 11, 2011 @ 13:35
    Doogie Talons
    0

    Thanks I looked closer at what you wrote and the solution is...

    Posted for anyone else looking.

     

    ----------------------------------------------------------------------


    <xsl:template match="/">
      <h2><xsl:value-of select="$currentPage/copyHeader"/></h2>
      <xsl:value-of select="$currentPage/copyContent" disable-output-escaping="yes"/>

      <xsl:apply-templates select="$currentPage/specialOffers/MultiNodePicker/nodeId" mode="Product">
    <xsl:with-param name="currentCurrency" select="$currentCurrency" />
    </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="specialOffers/MultiNodePicker/nodeId" mode="Product">
    <xsl:variable name="extNode" select="umbraco.library:GetXmlNodeById(.)" />
    <h1><xsl:value-of select="$extNode/productTitle"/></h1>
    </xsl:template>
    </xsl:stylesheet>

     

    ----------------------------------------------------------------------

Please Sign in or register to post replies

Write your reply to:

Draft