Click here to Skip to main content
14,771,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hope I get a solution here. I have imported "Codelist.xsl" file in my another xslt and trying to call the template based upon the codes. In the imported file it contains list of code values. the input contains the codes. I'm not able to execute xslt based upon the input request. Below is my xslt which i tried.

But I'm getting empty response.Can someone please help on this as this is our urgent requirement ?

What I have tried:

<xsl:stylesheet xmlns:xsl="" version"1.0">
<xsl:import href="local:///CodeList.xsl"/> 
    <xsl:template match="/">
<xsl:variable name="EmpAccountType" select="Employee/EmployeeType/Type/Account/EmpAccountType"/>
            <xsl:variable name="AccountType1">
                                <xsl:call-template name="AccountType">
                                    <xsl:with-param name="AAccountType" select="$EmpAccountType"/>
                            <xsl:value-of select="$AccountType1"/>

<pre>My imported file contains:

<xsl:template name="AccountType">
        <xsl:param name="AAccountType"/>
            <xsl:when test="$AAccountType='01'">A</xsl:when>
            <xsl:when test="$AAccountType='02'">B</xsl:when>
            <xsl:when test="$AAccountType='03'">C</xsl:when>            
<pre><xsl:template name="PartnerShipTypecode">
        <xsl:param name="ZPartnerShipType"/>
            <xsl:when test="$ZPartnerShipType='Collaboration Partner B2C'">Z01</xsl:when>
			<xsl:when test="$ZPartnerShipType='Solution Partner B2B'">Z02</xsl:when>
            <xsl:when test="$ZPartnerShipType='Franchise Partner B2C'">Z03</xsl:when>

My input will be like:


My expected output:
Updated 16-Nov-20 21:45pm

1 solution

The URI you've specified for your import is not valid. Assuming the files are in the same folder, remove the local:/// prefix.
GeetYG 16-Nov-20 2:38am
Actually the original path is <xsl:import href="local:///Creation/DTR_XSL/CodeList.xsl">. Should I change to <xsl:import href="Creation/DTR_XSL/CodeList.xsl"> ? Please correct me.
Richard Deeming 16-Nov-20 3:02am
As far as I can see, local: is not a registered URI scheme. Depending on where your code is running, you may need to specify a relative path, or use a file: URI.
GeetYG 16-Nov-20 4:43am
Now, I'm getting new error: Call to unknown template PartnerShipTypecode.
Richard Deeming 16-Nov-20 4:45am
There's nothing in your question to show where you're calling that template.
GeetYG 16-Nov-20 4:55am
Now i have added the missing code. I have shortened my code since my original code is lengthy. Please check.
Richard Deeming 16-Nov-20 5:00am
So the AccountType template works, but the PartnerShipTypecode template doesn't?

There must be something else going on. Are both template elements direct children of the imported <xsl:stylesheet> node? Have you double-checked the case of the template name?
GeetYG 16-Nov-20 5:08am
I have given the wrong path for PartnerShipTypecode, so now error was gone but in the output..its displaying empty tags. </partnershiptype> and . But in the output I should get <empaccounttype>B</empaccounttype> if code is 02 and the same for partnership tag.
Richard Deeming 16-Nov-20 5:13am
You're calling the AccountType template with the $EmpAccountType variable before you've declared the variable. Try moving the variable declaration line above the call-template line.
GeetYG 16-Nov-20 5:26am
Done the changes. but still getting empty tags without values. Not getting the expected output.
GeetYG 18-Nov-20 2:30am
Problem solved. Thankyou !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900