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 May 7th, 2014, 09:58 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default how to differentiate templates based on cases

Hi i've the below two cases in XML.

Case1:

Code:
<para num="01"><page num="05"/>abcdefghij ancfrgthig</para>
Case2:

Code:
<para num="01">abcdefgrghy sdfdfhrtfd<page num="05"/></para>
Case3:

Code:
<para num="01">abcdefgrghy <page num="05"/>sdfdfhrtfd</para>
Case4:

Code:
<para num="01"><span class="bold">abcdefgrghy sdfdfhrtfd</span><page num="05"/></para>
Case5:

Code:
<para num="01"><span class="bold">abcdefgrghy</span><page num="05"/> sdfdfhrtfd</para>
Case6:

Quote:
<para num="01"><span class="bold">abcdefgrghy</span> sdfdfhrtfd<page num="05"/> </para>
Case7:

Code:
<para num="01"><span class="bold">abcdefgrghy sdfdfhrtfd</span><page num="05"/> </para>
I need to differentiate these two cases, because i want to make different templates for each.

I use directly <xsl:apply-templates/>, but here if i have the first case stated above, first the page template needs to be called by the para template.

Thanks
Reply With Quote
  #2 (permalink)  
Old May 7th, 2014, 10:04 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,133
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Two cases? I see 7...

Please explain your XML and what you ar expecting to happen, I.e. Your expected output.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
Reply With Quote
  #3 (permalink)  
Old May 7th, 2014, 10:30 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi Thanks for the reply, actually i've solved this. Thanks again. And here is the solution.

Code:
<xsl:choose>
            <xsl:when test="child::node()[1][self::*]">
													<xsl:apply-templates select="child::page[1]"/>
													  <div class="para">
               <xsl:call-template name="phrase"/>												
                <xsl:apply-templates select="child::node()[not(self::page)]"/>
                </div>
												</xsl:when>  
												
                <xsl:otherwise>
                 <div class="para">
                     <xsl:call-template name="phrase"/>												
                    <xsl:apply-templates/>
                </div>
                </xsl:otherwise>
            </xsl:choose>
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
Sorting elements accessed via apply-templates based on the real XML tag name in XSLT azikh XSLT 2 August 29th, 2013 07:56 PM
Applying Templates Based on Attributes JoshC XSLT 6 February 21st, 2009 06:31 PM
How to ignore cases on attribute value 2BOrNot2B XSLT 2 January 30th, 2009 11:03 AM
How to differentiate to number lists gilgalbiblewheel Java GUI 0 September 15th, 2004 07:22 PM
How do we differentiate b/w User and Sys tables softwarearchitect SQL Server 2000 5 May 30th, 2004 08:39 AM



All times are GMT -4. The time now is 01:23 AM.


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