• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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

0
mmalik15
Asked:
mmalik15
1 Solution
 
Geert BormansInformation ArchitectCommented:
just wrap it        


<xsl:call-template name="process-values">
            <xsl:with-param name="list" select="';'"/>
            <xsl:with-param name="remaining" >
                    <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>          
            </xsl:with-param>
        </xsl:call-template>

or make the call in a variable and use the variable as the param value
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now