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 January 3rd, 2008, 05:53 AM
Authorized User
 
Join Date: Nov 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Anyone help on this xslt coding

Hii...

I am transforming an xml file through xslt..

This is my master xml file syntax:

<figure><caption>Transportation Industry</caption><p>Indiana is a leading producer of automobile parts.</p></figure>

I want to transform the xml file like:

<imggroup><caption><strong>Transportation Industry</strong><p>Indiana is a leading producer of automobile parts.</p></caption></imggroup>

Thanks in Advance,
srkumar

 
Old January 3rd, 2008, 06:06 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

This is fairly simple XSLT. You'd do well to follow some on-line tutorials or by a good book.

<xsl:template match="figure">
<imggroup><caption><xsl:apply-templates/></caption></imggroup>
</xsl:template>

<xsl:template match="caption">
<strong><xsl:apply-templates/></strong>
</xsl:template>

<xsl:template match="p">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>


/- Sam Judson : Wrox Technical Editor -/
 
Old January 3rd, 2008, 06:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't really infer your transformation rules from one example - for example it's not clear whether there is always exactly one <p> element after the <caption>, or whether other examples might have things inside the <figure> that shouldn't end up inside the <caption>. However, from the information given, Sam's code is as good as one can do.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 3rd, 2008, 07:44 AM
Authorized User
 
Join Date: Nov 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ya.. Its working

Thanks sam...







Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone help on this XSLT coding srkumar XSLT 1 December 17th, 2007 05:25 AM
Good XSLT coding Architecture for transformation anil2020 XSLT 0 August 27th, 2007 12:10 PM
Coding question (New to XSLT) jcrowley XSLT 2 August 26th, 2007 03:42 PM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
can someone help me in coding this? somanchivasu Access 1 April 5th, 2004 02:41 PM





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