?
Solved

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

Posted on 2011-10-05
1
Medium Priority
?
306 Views
Last Modified: 2012-05-12
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
Comment
Question by:mmalik15
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 36925571
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question