Copied to clipboard

Flag this post as spam?

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


  • ridi 71 posts 103 karma points
    Sep 26, 2011 @ 02:23
    ridi
    0

    Get value from XSLT file to the other XSLT file

    Dear All, i have two XSLT , e.g the XSLT A and XSLT B, the XSLT B get the value from the result of XSLT A. However when i try the code like below i can't get what expected. Any advise for this

    <?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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" xmlns:uTube.XSLT="urn:uTube.XSLT"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary uTube.XSLT ">


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

    <xsl:param name="currentPage"/>

    <xsl:template name="showResults">
    <xsl:variable name="strList" select="Exslt.ExsltStrings:split($currentPage/@nodeName, ' ')"/>
    <xsl:variable name="strListCount" select="count($strList)"/>
    <xsl:variable name="strCondition">
    (
    <xsl:for-each select="$strList">
    contains(@nodeName,
    '<xsl:value-of select="."/>'
    )
    <xsl:if test="position() &lt; $strListCount">
    or
    </xsl:if>
    </xsl:for-each>
    )
    </xsl:variable>
    <xsl:value-of select="$strCondition"/>

    </xsl:template>

    <xsl:template match="/">

    <xsl:if test="string-length($currentPage/relatedTags ) != ''">

    <xsl:variable name="kondisi">
    <xsl:call-template name="showResults" />
    </xsl:variable>

    <xsl:variable name="relatedposts" select="$currentPage/../umbBlogPost [ $kondisi and ./@id!=$currentPage/@id ] " />
    <xsl:if test="count($relatedposts) &gt; 0">
    <!--Result-->
    </xsl:if>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

    The called template is showResults and the result is stored in Kondisi, however when i called $kondisi the value is not there... please suggest

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 26, 2011 @ 09:33
    Chriztian Steinmeier
    1

    Hi ridi,

    Can you explain to me what you're trying to do (which nodes you're trying to show and how they relate to the currentPage)?

    It seems like you're doing this in a very complicated way that's not at all necessary - XSLT works very different than other programming languages, so sometimes you need to think about a problem in another way.

    Anyways, you're trying to "build" an XPath expression ($kondisi) which requires some additional extension magic to get to work. But my guess is that it's not at all necessary for what you're trying to accomplish.

    /Chriztian

  • praveity 100 posts 125 karma points
    Sep 26, 2011 @ 12:10
    praveity
    0

    Hi Ridi,

    you could try something like this;

     <xsl:include href="../xslt/YourXSLTtobecalled.xslt"/>

    you could use the variable defined within YourXSLTtobecalled.xslt on other xslt where it is being referenced.

    Hope this helps

Please Sign in or register to post replies

Write your reply to:

Draft