xsl-list
[Top] [All Lists]

Re: [xsl] Please look at my mini-template

2009-05-16 10:02:36
Do the exslt functions work in browsers?

You are right, sofar even EXSLT support in FF3 is limited (but really
works!), see:
http://www.oreillynet.com/xml/blog/2007/01/limited_exslt_support_in_mozil.html


I tested func:function and FF3 complained about an unknown XPATH extension.

[Btw, below I meant "condensed" instead of "comprehensive"]


Mit besten Grüßen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


                                                                       
             Dmitri Snytkine                                           
             <d(_dot_)snytkine(_at_)gmail                                       
  
             .com>                                                      To
                                       
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
             05/16/2009 02:38                                           cc
             AM                                                        
                                                                   Subject
                                       Re: [xsl] Please look at my     
             Please respond to         mini-template                   
             xsl-list(_at_)lists(_dot_)mu                                       
  
              lberrytech.com                                           
                                                                       
                                                                       
                                                                       
                                                                       




Do the exslt functions work in browsers?



On Fri, May 15, 2009 at 8:34 PM, Hermann Stamm-Wilbrandt
<STAMMW(_at_)de(_dot_)ibm(_dot_)com> wrote:

Dmitri,

if you do not want to directly output the converted hex string as David
pointed out
a more comprehensive solution is using a func:function:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:func="http://exslt.org/functions";
 xmlns:ns="namespace"

 <xsl:output method="xml" />

 <xsl:template match="/hex2path">
   <xsl:value-of select="ns:hex2path(.)" />
 </xsl:template>

 <func:function name="ns:hex2path">
   <xsl:param name="str" />
   <xsl:choose>
     <xsl:when test="(string-length($str) &gt; 2)">
       <func:result select="concat(substring($str, 1, 2), '/',
                            ns:hex2path(substring($str, 3)))" />
     </xsl:when>
     <xsl:otherwise>
       <func:result select="$str" />
     </xsl:otherwise>
   </xsl:choose>
 </func:function>

</xsl:stylesheet>>


Mit besten Grüßen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
----- Forwarded by Hermann Stamm-Wilbrandt/Germany/IBM on 05/16/2009
02:30
AM -----

            Dmitri Snytkine
            <d(_dot_)snytkine(_at_)gmail
            .com>                                                      To
                                      xsl-list
            05/16/2009 01:41         
 <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
            AM                                                         cc

                                                                  Subject
            Please respond to         [xsl] Please look at my
            xsl-list(_at_)lists(_dot_)mu         mini-template
             lberrytech.com









Hello!

I needed this functionality:
Given the input of a HEX number (example 2A32BF42)
I needed to split the string in such a way that a '/' is inserted
after every 2 characters except that
the '/' should NOT be added at the end of string.

So 2A32BF42 has to become 2A/32/BF/42

This had to be done in XSLT 1 because its for browser-based
transformations.

I wrote a template for this and want to hear the opinion of the
experts. I just started learning XSLT about a week ago.
So what do you think?

Here it is:

<xsl:template name="hex2path">
       <xsl:param name="left" select="''"/>
       <xsl:param name="right"/>
       <xsl:choose>
           <xsl:when test="(string-length($right) > 2)">

               <xsl:call-template name="hex2path">
                   <xsl:with-param name="left">
                       <xsl:value-of select="concat($left,
concat(substring($right, 1, 2), '/'))"/>
                   </xsl:with-param>

<xsl:with-param name="right">

<xsl:value-of select="substring($right, 3)"/>

</xsl:with-param>
               </xsl:call-template>

           </xsl:when>
           <xsl:otherwise>
               <xsl:value-of select="concat($left, $right)"/>
           </xsl:otherwise>
       </xsl:choose>
   </xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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