| Author | 
		  Message
		 | 
		
		  | vasanthapriyas | 
		  
		    
			  
				 Posted: Tue Aug 25, 2009 5:39 am    Post subject: XSLT Transformation Primitive | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 05 Jul 2009 Posts: 12
  
  | 
		  
		    
			  
				Hi all,
 
 
I have used the following xslt code to do translate a field IN Custom option in WID 6.2
 
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
    version="1.0"
 
    xmlns:xalan="http://xml.apache.org/xslt">
 
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/>
 
 
<!-- The rule represents a custom mapping: "io3:VehicleNo" to "io3:VehicleNo". -->
 
  <xsl:template name="VehicleNoToVehicleNo" match="sendAutoClaimAdviceRequest">
 
<xsl:if test="VehicleNo=TN1234">        
 
                <xsl:text/>TN01234<xsl:text/>         
 
      </xsl:if>
 
 
 <xsl:value-of select="VehicleNo"/>    
 
  </xsl:template>
 
</xsl:stylesheet>
 
 
but the output VehicleNo is empty.
 
 
Please help me in fixing the issue.
 
 
Note:Input Used(Input and output are of same type)
 
<sendAutoClaimAdviceRequest>
 
<VehicleNo>TN1234</VehicleNo>
 
</sendAutoClaimAdviceRequest> | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Ratan | 
		  
		    
			  
				 Posted: Wed Aug 26, 2009 2:20 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 18 Jul 2002 Posts: 1245
  
  | 
		  
		    
			  
				<xsl:text/>TN01234<xsl:text/>   should be <xsl:text>TN01234</xsl:text> _________________ -Ratan | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vasanthapriyas | 
		  
		    
			  
				 Posted: Wed Aug 26, 2009 4:06 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 05 Jul 2009 Posts: 12
  
  | 
		  
		    
			  
				Hi ,
 
 
The below code also didn't work always it goes in to other wise block
 
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
    version="1.0"
 
    xmlns:xalan="http://xml.apache.org/xslt">
 
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/>
 
<xsl:strip-space elements="*"/>
 
<!-- The rule represents a custom mapping: "io3:VehicleNo" to "io3:VehicleNo". -->
 
   <xsl:template name="VehicleNoToVehicleNo" match="sendAutoClaimAdviceRequest">
 
      <xsl:choose>
 
          <xsl:when test="VehicleNo!=''">
 
             <xsl:text>Hi</xsl:text>
 
          </xsl:when>
 
          <xsl:otherwise>
 
             <xsl:text>pri</xsl:text>
 
          </xsl:otherwise>
 
        </xsl:choose>	   
 
  </xsl:template>
 
</xsl:stylesheet>
 
 
Can you please explain,what will be input to the custom xslt defined only for one element?will that be a variable in that case how to access it .I feel i go wrong with the xpath. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Ratan | 
		  
		    
			  
				 Posted: Fri Aug 28, 2009 1:39 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 18 Jul 2002 Posts: 1245
  
  | 
		  
		    
			  
				
   
	| Code: | 
   
  
	
 
I have used the following xslt code to do translate a field IN Custom option in WID 6.2 
 
 
<?xml version="1.0" encoding="UTF-8"?> 
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 
version="1.0" 
 
xmlns:xalan="http://xml.apache.org/xslt"> 
 
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/> 
 
 
<!-- The rule represents a custom mapping: "io3:VehicleNo" to "io3:VehicleNo". --> 
 
<xsl:template name="VehicleNoToVehicleNo" match="sendAutoClaimAdviceRequest"> 
 
<xsl:if test="VehicleNo=TN1234"> 
 
<xsl:text/>TN01234<xsl:text/> 
 
</xsl:if> 
 
 
<xsl:value-of select="VehicleNo"/> 
 
</xsl:template> 
 
</xsl:stylesheet> 
 
 
but the output VehicleNo is empty. 
 
 
 | 
   
 
 
 
your xsl code should be 
 
 
   
	| Code: | 
   
  
	
 
 
<?xml version="1.0" encoding="UTF-8"?> 
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 
version="1.0" 
 
xmlns:xalan="http://xml.apache.org/xslt"> 
 
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/> 
 
 
<!-- The rule represents a custom mapping: "io3:VehicleNo" to "io3:VehicleNo". --> 
 
<xsl:template name="VehicleNoToVehicleNo" match="sendAutoClaimAdviceRequest"> 
 
 
<xsl:param name="VehicleNo"/>
 
 
<xsl:if test="$VehicleNo='TN1234'"> 
 
<xsl:text>TN01234</xsl:text> 
 
</xsl:if> 
 
 
 
</xsl:template> 
 
</xsl:stylesheet> 
 
 
 
 
 | 
   
 
 
Notice the addition of  <xsl:param  statement and changes in <xsl:if  xxx> statement.
 
you do not need <xsl:value-of xxx> statement. _________________ -Ratan | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Ratan | 
		  
		    
			  
				 Posted: Fri Aug 28, 2009 1:41 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 18 Jul 2002 Posts: 1245
  
  | 
		  
		    
			  
				
   
	| Code: | 
   
  
	
 
Hi , 
 
 
The below code also didn't work always it goes in to other wise block 
 
 
<?xml version="1.0" encoding="UTF-8"?> 
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 
version="1.0" 
 
xmlns:xalan="http://xml.apache.org/xslt"> 
 
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/> 
 
<xsl:strip-space elements="*"/> 
 
<!-- The rule represents a custom mapping: "io3:VehicleNo" to "io3:VehicleNo". --> 
 
<xsl:template name="VehicleNoToVehicleNo" match="sendAutoClaimAdviceRequest"> 
 
<xsl:choose> 
 
<xsl:when test="VehicleNo!=''"> 
 
<xsl:text>Hi</xsl:text> 
 
</xsl:when> 
 
<xsl:otherwise> 
 
<xsl:text>pri</xsl:text> 
 
</xsl:otherwise> 
 
</xsl:choose> 
 
</xsl:template> 
 
</xsl:stylesheet> 
 
 
Can you please explain,what will be input to the custom xslt defined only for one element?will that be a variable in that case how to access it .I feel i go wrong with the xpath.
 
 | 
   
 
 
 
Add $ in front of  VehicleNo in this statement <xsl:when test="VehicleNo!=''"> _________________ -Ratan | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vasanthapriyas | 
		  
		    
			  
				 Posted: Tue Sep 22, 2009 6:00 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 05 Jul 2009 Posts: 12
  
  | 
		  
		    
			  
				Hi Ratan,
 
 
Thanks for your help .It works | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |