Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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="http://www.w3.org/1999/XSL/Transform" 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:call-template>
                            </xsl:variable> 
          
                          <Accounttype>
                            <xsl:value-of select="$AccountType1"/>
                          </Accounttype> 
t;  
    </xsl:template>
    </xsl:stylesheet>


<pre>My imported file contains:

<xsl:template name="AccountType">
        <xsl:param name="AAccountType"/>
        <xsl:choose>
            <xsl:when test="$AAccountType='01'">A</xsl:when>
            <xsl:when test="$AAccountType='02'">B</xsl:when>
            <xsl:when test="$AAccountType='03'">C</xsl:when>            
        </xsl:choose>
</xsl:template>
<pre><xsl:template name="PartnerShipTypecode">
        <xsl:param name="ZPartnerShipType"/>
        <xsl:choose>
            <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:

<Employee>
<EmployeeType>
<Type>
<Account>
<EmpAccountType>02</EmpAccountType>
</Account>
</Type>
</EmployeeType>
</Employee>


My expected output:
<Employee>
<EmployeeType>
<Type>
<Account>
<EmpAccountType>0B</EmpAccountType>
</Account>
</Type>
</EmployeeType>
</Employee>
Posted
Updated 16-Nov-20 20:45pm
v7

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.
 
Share this answer
 
Comments
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.

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