Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2005, 03:19 AM
Authorized User
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Functions, select case and the like...

Hi Gents

I'm kinda new to XSLT and have a few (probably easy) questions...

Background: Im building a vb.net app that builds classes according to a template (xslt) and in doing so needs some tricky tweaking.

Question:

Can you in XSLT create your own functions? Ie. send a variable to an xslt function that returns a result after some computation...

Basically a similar piece of code will occur throughout and the last thing I want to do is code it again and again in various places...

Thanks



Reply With Quote
  #2 (permalink)  
Old April 26th, 2005, 04:33 AM
Authorized User
 
Join Date: Apr 2005
Location: Chennai, Tamil Nazdu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes!

1. For "Functions" in vb.net you can use

The below xsl statements are recursive templates just like finding a factorial of a given number in VB/VB.net

<xsl:call-template name="Print">
      <xsl:with-param name="i" select="'10'"/>


</xsl:call-template

<xsl:template name="Print">
 <xsl:param name="i"/>
  <xsl:value-of select="$i"/><br/>
<xsl:if test="$i &lt; 10">

     <xsl:call-template name="Print">
          <xsl:with-param name="i" select="$i"/>

      </xsl:call-template>
</xsl:if>
</xsl:template>

2. for "select case" statements

   <xsl:choose>
     <xsl:when test="$i=1">
         <xsl:value-of select="you have entered number 1"/>
     </xsl:when>


     <xsl:when test="$i=2">
         <xsl:value-of select="you have entered number 3"/>
    </xsl:when>

     <xsl:when test="$i=3">
         <xsl:value-of select="you have entered number 3"/>
     </xsl:when>

     <xsl:otherwise>
         <xsl:value-of select="you have entered number 0 or greater then 3"/>


  </xsl:otherwise>



    </xsl:choose>


Reply With Quote
  #3 (permalink)  
Old April 26th, 2005, 04:49 AM
Authorized User
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Raman

That is brilliant thanks so much. Should meet my needs perfectly. I presume that the <xsl:template name="Print"> etc... will just sit within the template/file that I am working in? And then when I call it the response would go directly into where i called it from? So somthing like...

some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some
<xsl:call-template name="Print">
      <xsl:with-param name="i" select="'10'"/>
</xsl:call-template>
code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla

Would become...


some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some
<result>
code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla some code some code some code bla bla bla

? Make sence? Or would I have to use another command to use the result of the function?

Thanks again :P

Reply With Quote
  #4 (permalink)  
Old April 26th, 2005, 05:02 AM
Authorized User
 
Join Date: Apr 2005
Location: Chennai, Tamil Nazdu, India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You does not what is XML concept. Learn the XML and XSLT concepts

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select case bacster Classic ASP Basics 2 May 1st, 2006 06:31 PM
Using IS in Select Case mega Pro VB 6 4 August 22nd, 2005 08:40 AM
Select Case junaidraja30 Access VBA 1 February 5th, 2005 08:30 PM
Select Case morpheus VB How-To 1 August 13th, 2003 09:14 AM
Select Case andy24 Classic ASP Databases 5 July 25th, 2003 07:52 AM



All times are GMT -4. The time now is 07:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.