Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2013, 11:23 AM
Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Default XML to HTML convertion using XSLT

Please have a look onto below XML with HTML format which I would like to have a output

XML:-
<section><title>Title 1</title></section>
<section><title>Title 2</title></section>
<section><title>Title 3</title></section>
<section><title>Title 4</title></section>

HTML:-
<div class="h3">Title 1</div>
<div class="h3_1">Title 2</div>
<div class="h3_1">Title 3</div>
<div class="h3_1">Title 4</div>


In short, I would want 1st title to be with "h3" class & rest of the title with "h3_1" class.

Any help would be appreciated
 
Old August 2nd, 2013, 03:24 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

To get the first of something you simply do this: "title[1]", and to get the rest you do this: "title[position()>1]". Try putting that into some XSLT and see what happens.

If you still can't work it out then show us what you've tried and we'll help you understand where you are going wrong.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 2nd, 2013, 03:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Or write one template rule with match="div[1]" and another that matches "div" (which will automatically have lower priority).

You're on a forum provided for readers of Wrox books. Which book are you using? This is very basic stuff that any book should cover.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
An XML value in an Html tag (xslt) ismailc XSLT 9 October 19th, 2009 07:27 AM
Regarding xml-html transformation of an xml string using xslt and javascript suprakash444 XSLT 1 January 12th, 2009 01:23 AM
html to xml convertion using xslt moshaik BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 2 November 24th, 2008 10:33 AM
XSLT convertion help mwells XSLT 3 February 2nd, 2007 10:00 AM
Two HTML Tables and Two XSLT with Two XML? gman44 XSLT 1 March 1st, 2006 04:53 AM





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