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 | 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 Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2003, 10:13 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default conditional statement based on attribute value

I'm trying to figure how to write a conditional statement in XSLT that will do one thing if a node attribute starts with a T and another thing if it starts with an M.

<member name="T:IHDomainElementManager">
  <summary>IHDomainElementManager Interface</summary>
</member>
<member name="M:Elements(HObject Param0, HObject Param1)">
  <summary>property Elements</summary>
</member>


I know my XSLT will look something like this:
<xsl:choose>

<xsl:when test=starts-with(@name,'T:H')>
    ...do something

but it's not matching on the test.

Thanks for your help.
Daniel


Reply With Quote
  #2 (permalink)  
Old November 7th, 2003, 11:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Nor Hachin, Kotayk, Armenia.
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

If you want to detect whether the name attribute starts with "T" or "M", write:

Code:
<xsl:choose>
 <xsl:when test="starts-with(@name,'T')">
    ...do something
 </xsl:when>
 <xsl:when test="starts-with(@name,'M')">
    ...do something
 </xsl:when>
</xsl:choose>
In your example you wrote test=starts-with(@name,'T:H')... and also the example is not a well-formed XML(quots are missing for attribute value).

Regards,
Armen
Reply With Quote
  #3 (permalink)  
Old November 7th, 2003, 12:50 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahhh, I knew it was going to be something like that. Missing quotes.

Thank you very much. Worked beautifully.


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
Need help with conditional sql statement MarkGT Classic ASP Basics 11 May 6th, 2008 08:41 PM
conditional xslt processing based on java array twilson997 XSLT 7 June 28th, 2006 07:32 AM
Match element based on attribute of child? transom XSLT 1 September 11th, 2005 03:26 PM
Conditional IF statement iloveoatmeal Classic ASP Basics 5 July 20th, 2005 08:33 PM
Rules based on attribute values... jacob XML 2 July 6th, 2005 01:50 PM



All times are GMT -4. The time now is 08:26 PM.


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