xsl-list
[Top] [All Lists]

Re: Converting XML data

2004-08-10 00:30:02
Please try this XSL -

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
 
<xsl:output method="text"/> 

<xsl:template match="/root">
  <xsl:call-template name="FormatString">
     <xsl:with-param name="str" select="s" />  
  </xsl:call-template>
  <xsl:text>|</xsl:text>
</xsl:template> 
 
<xsl:template name="FormatString">
   <xsl:param name="str" />
   
   <xsl:if test="string-length($str) &gt; 0">
     <xsl:text>|</xsl:text><xsl:value-of
select="substring($str,1,1)" /> 
     <xsl:call-template name="FormatString">
       <xsl:with-param name="str"
select="substring($str,2,string-length($str))" />
     </xsl:call-template>
   </xsl:if>
   
</xsl:template>
  
</xsl:stylesheet>

For e.g., when it is applied to XML -
<?xml version="1.0"?>
<root>
  <s>HELLO</s>
</root>

it produces output -
|H|E|L|L|O|

Regards,
Mukul

--- Narasingarao Kommireddi
<Narasingarao(_dot_)Kommireddi(_at_)relianceinfo(_dot_)com> wrote:

I need to format data from the XML in my XSL using
functions.

example :   Input data from XML is HELLO , i want
the output as |  H  |   E
|  L  |  L  | O  |

How do i go abt it..



        
                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 


<Prev in Thread] Current Thread [Next in Thread>