Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 Display Modes
  #1 (permalink)  
Old October 30th, 2003, 03:25 PM
Registered User
 
Join Date: Jun 2003
Location: champaign, IL, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hello xsl friends

I'm very familiar with xml and xsl -- however, I do have a question. :D

IN my xml map - I have several elements like:
<plan1>
<plan2>
<plan3>
<plan4>
<plan5>
<plan6>
   through
<plan106>

I'm doing a lot of substring and contains and length and concat in my XSL.

I want to know.. In xsl, can you do something similiar to "for loop" for the <plan[i]> that will assign 1,2,3,4,5 to plan.

Now i'm creating individual XPATH for each plan1, plan2, etc... So, I have 106 set of instructions in the xsl when I should have one.

Thanks for your help. It is greatly appreciated.

Michael Hall
Reply With Quote
  #2 (permalink)  
Old October 31st, 2003, 03:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is there any particular reason you named the nodes like that? Does, say, plan1 have a different structure than plan2? If you had used <plan id="1">...<plan id="2"> etc then you wouldn't have this problem. Please elaborate on the structure and what you're trying to accomplish.
Reply With Quote
  #3 (permalink)  
Old October 31st, 2003, 01:22 PM
Registered User
 
Join Date: Jun 2003
Location: champaign, IL, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi PGtips,

Thanks for replying.

Here's my XML MAP:

<NOTE>
<ATTRIB Name="PLNOTES1" Field="BNDS1" dt="string" />
<ATTRIB Name="PLNOTES2" Field="BNDS2" dt="string" />
<ATTRIB Name="PLNOTES3" Field="BNDS3" dt="string" />
<ATTRIB Name="PLNOTES4" Field="BNDS4" dt="string" />
<ATTRIB Name="PLNOTES5" Field="BNDS5" dt="string" />
<ATTRIB Name="PLNOTES6" Field="BNDS6" dt="string" />
<ATTRIB Name="PLNOTES7" Field="BNDS7" dt="string" />
<ATTRIB Name="PLNOTES8" Field="BNDS8" dt="string" />
<ATTRIB Name="PLNOTES9" Field="BNDS9" dt="string" />
<ATTRIB Name="PLNOTES10" Field="BNDS10" dt="string" />
<ATTRIB Name="PLNOTES11" Field="BNDS11" dt="string" />
<ATTRIB Name="PLNOTES12" Field="BNDS12" dt="string" />
<ATTRIB Name="PLNOTES13" Field="BNDS13" dt="string" />
<ATTRIB Name="PLNOTES14" Field="BNDS14" dt="string" />
<ATTRIB Name="PLNOTES15" Field="BNDS15" dt="string" />
<ATTRIB Name="PLNOTES16" Field="BNDS16" dt="string" />
<ATTRIB Name="PLNOTES17" Field="BNDS17" dt="string" />
<ATTRIB Name="PLNOTES18" Field="BNDS18" dt="string" />
<ATTRIB Name="PLNOTES19" Field="BNDS19" dt="string" />
<ATTRIB Name="PLNOTES20" Field="BNDS20" dt="string" />
THROUGH
<ATTRIB Name="PLNOTES106" Field="BNDS106" dt="string" />
</NOTE>

__________________________________________________ ______________


My XSL:

<xsl:choose>
 <xsl:when test="contains(NOTE/@PLNOTES1, '|')">
   <tr>
     <TD Class="SmData" width="50%" align="left">
     <xsl:value-of select="substring-before(NOTE/@PLNOTES1, '|')" />
      </TD>
       <TD Class="SmData" width="50%" align="left">
    <xsl:value-of select="substring-after(NOTE/@PLNOTES1, '|')" />
       </TD>
     </tr>
 </xsl:when>
<xsl:when test="contains(NOTE/@PLNOTES1, '*****') or substring(NOTE/@PLNOTES1, 1, 4) = '----'"> <tr>
  <TD colspan="2" Class="SmData" width="689" align="center">
   <xsl:value-of select="NOTE/@PLNOTES1" />
  </TD>
</tr>
</xsl:when>
<xsl:otherwise>
  <tr>
    <TD colspan="2" Class="SmData" width="100%" align="left">
    <xsl:value-of select="NOTE/@PLNOTES1" />
    </TD>
  </tr>
</xsl:otherwise>
</xsl:choose>

I do thses instructions inside XSL 106 times - really. It goes from NOTE/@PLNOTES1, NOTE/@PLNOTES2, NOTE/@PLNOTES3, etc...

There must be a way to do something similar to a FOR LOOP? Correct?

Thanks for your help,
Mike
Reply With Quote
  #4 (permalink)  
Old November 3rd, 2003, 03:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Umm, maybe I'm missing something, but can't you just do:
<xsl:for-each select="NOTE/@*">
  <xsl:choose>
    <xsl:when test="contains(., '|')">
    ...etc
</xsl:for-each>
Reply With Quote
  #5 (permalink)  
Old November 3rd, 2003, 10:33 AM
Registered User
 
Join Date: Jun 2003
Location: champaign, IL, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi pgtips,

Thanks, it works fantastic! I had a (For Each) like your example, but I coded <xsl:for-each select="NOTE/@PLNOTES*"> and it didn't work.

Again - Thanks for your time -- I appreciate it greatly.

Thanks,
Mike
Reply With Quote
Reply


Thread Tools
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
Hi,Friends emmanuelmosses Crystal Reports 1 August 25th, 2008 12:38 PM
Hi friends help me vingo_mail ASP.NET 2.0 Professional 1 March 12th, 2008 07:35 AM
search friends of c# learner spring21st C# 0 April 7th, 2006 06:15 AM
friends help me plese! bad.for.good ASP.NET 1.0 and 1.1 Basics 1 May 18th, 2005 11:49 AM



All times are GMT -4. The time now is 07:48 PM.


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