Avatar of mmalik15
mmalik15

asked on 

How to pass out put of an xslt template as an input to another template

My xslt and xml are attached. I am calling a template    <xsl:call-template name="strip-tags"> and passing a parameter. This template produces an output. Then I need to call another template <xsl:template name="process-values"> and pass in the output of the strip tags template as a parameter to this template. how can we achive this?

Thanks,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	
	  <xsl:variable name="lc" select="'azertyuiopqsdfghjklmwxcvbn'"/>
        <xsl:variable name="uc" select="'AZERTYUIOPQSDFGHJKLMWXCVBN'"/>
         
        
	<xsl:template match="/">
		<Records>
			<xsl:for-each select="/documents/document">
				<record>
				
					
        <xsl:call-template name="strip-tags">
			<xsl:with-param name="text" select="translate(normalize-space(substring-after(concat(element[@name='MSHValues']/value,element[@name='MTHValues']/value,element[@name='SNOMEDCTValues']/value), ':')), $uc, $lc)" />
          </xsl:call-template>
          
          
       </record>
			</xsl:for-each>
				</Records>
			  </xsl:template>
			
    <xsl:template name="process-values">
        <xsl:param name="list"/>
        <xsl:param name="remaining"/>
        <xsl:choose>
            <xsl:when test="contains($remaining, ';')">
                <xsl:variable name="new-list">
                    <xsl:call-template name="filter-and-add">
                        <xsl:with-param name="list" select="$list"/>
                        <xsl:with-param name="term" select="substring-before($remaining, ';')"/>
                    </xsl:call-template>
                </xsl:variable>
                 <xsl:call-template name="process-values">
                    <xsl:with-param name="list" select="$new-list"/>
                    <xsl:with-param name="remaining" select="substring-after($remaining, ';')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="new-list">
                    <xsl:call-template name="filter-and-add">
                        <xsl:with-param name="list" select="$list"/>
                        <xsl:with-param name="term" select="$remaining"/>
                    </xsl:call-template>
                </xsl:variable>
                <xsl:value-of select="substring($new-list, 3)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="filter-and-add">
        <xsl:param name="list"/>
        <xsl:param name="term"/>
        <xsl:param name="norm-term" select="normalize-space(translate($term, '()1234567890', ''))"></xsl:param>
        <xsl:choose>
            <xsl:when test="not(contains(concat($list, '; '), concat('; ', $norm-term, '; ')))">
                <xsl:value-of select="concat($list, '; ', $norm-term)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$list"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="strip-tags">
		<xsl:param name="text"/>
		<xsl:choose>
			<xsl:when test="contains($text, '&lt;')">
				<xsl:value-of select="substring-before($text, '&lt;')"/>
				<xsl:call-template name="strip-tags">
					<xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"/>
			</xsl:otherwise>
		</xsl:choose>
		
		
	</xsl:template>
	
     
</xsl:stylesheet>

Open in new window

<?xml version="1.0" encoding="utf-8"?>
<documents><document id="http://www.qualitymeasures.ahrq.gov/content.aspx?id=26549"><element name="MSHValues"><value>: 

                                            &lt;a href='/search/search.aspx?term=Cross+Infection &amp;umls=1'&gt;Cross Infection&lt;/a&gt;; &lt;a href='/search/search.aspx?term=Postoperative+Complications &amp;umls=1'&gt;Postoperative Complications&lt;/a&gt;; &lt;a href='/search/search.aspx?term=Sepsis &amp;umls=1'&gt;Sepsis&lt;/a&gt;

                                        </value></element><element name="MTHValues"><value>: 

                                            &lt;a href='/search/search.aspx?term=Systemic+infection &amp;umls=1'&gt;Systemic infection&lt;/a&gt;

                                        </value></element><element name="SNOMEDCTValues"><value>: 

                                            &lt;a href='/search/search.aspx?term=Cross+infection &amp;umls=1'&gt;Cross infection&lt;/a&gt; (36406009); &lt;a href='/search/search.aspx?term=Nosocomial+infectious+disease &amp;umls=1'&gt;Nosocomial infectious disease&lt;/a&gt; (19168005); &lt;a href='/search/search.aspx?term=Postoperative+complication &amp;umls=1'&gt;Postoperative complication&lt;/a&gt; (385486001); &lt;a href='/search/search.aspx?term=Systemic+infection &amp;umls=1'&gt;Systemic infection&lt;/a&gt; (91302008)


</document></documents>

Open in new window

XMLWeb Languages and Standards

Avatar of undefined
Last Comment
Gertone (Geert Bormans)
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Web Languages and Standards
Web Languages and Standards

Web development can range from developing the simplest static single page of plain text to the most complex web-based internet applications, electronic businesses, and social network services using a wide variety of languages and standards, including the familiar HTML, JavaScript and jQuery, ASP and ASP.NET, PHP, ColdFusion, CSS, PHP, Flex and Flash, but also the implementation of a broad list of standards including XML, WSDL, SSDL, VoiceXML and many more.

40K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo