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 4th, 2011, 05:04 AM
Authorized User
 
Join Date: Apr 2007
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Question How to ignore nested tags in an element while applying XSLT

I am converting following html to xml
Code:
<html>
	<body>
		something in body
		<table>
			<thead>
				<tr>
					<th>Heading 1</th>
				</tr>
				<tr>
					<th>Heading 2</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>content starts<b>bold <i>start italic in bold ends here </i>bold continue</b>plain text here</td>
				</tr>
				<tr>
					<td>content 2<p>para here</p>continue</td>
				</tr>
			</tbody>
		</table>
	</body>
</htm
> I would like it to convert to following xml

Code:
<topic>
 <table>
     <row>
<cell>cel<b>bold <i>start italic in bold ends</i>here</b>1 is here</cell></row>
     <row>
<cell>content 2<p>para here</p>continue</cell>
</row>
</topic>
Basically I want to copy everything that comes in TD to the cell element i XML. However when I apply XSLT, the <b> and <i> tags are supressed. How can I copy all the contents of TD to cell element of XML?

thanks

Kapil
 
Old August 4th, 2011, 05:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You are probably using xsl:value-of. Use xsl:copy-of instead.

This will copy the node, rather than creating a text node with the string value of the select statement (which is what xsl:value-of does).
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 4th, 2011, 05:14 AM
Authorized User
 
Join Date: Apr 2007
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Samjudson,
Copy-of is working to perfection..

Thanks
Kapil
 
Old August 4th, 2011, 05:37 AM
Authorized User
 
Join Date: Apr 2007
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Default

There is one issue with copyof. It is also emitting the tag name for TD.
Whereas I just need the string value in the TD.
 
Old August 4th, 2011, 05:41 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Assuming your current context is the TD element and you are doing <xsl:copy-of select="."/> then change it to <xsl:copy-of select="node()"/> instead.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
kaps77 (August 4th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I display xml element tags as it is in HTML gkrishna.tibco XSLT 2 November 22nd, 2010 07:42 AM
To select infinite nested element in XSLT1.0 rajatake XSLT 2 December 14th, 2006 09:32 AM
Nested tags with different values sunrain XSLT 4 November 10th, 2006 04:30 PM
Applying an XSLT to an XML document (II) Thodoris XML 1 April 28th, 2004 09:10 AM
Applying an XSLT to an XML document dimondwoof XML 1 June 26th, 2003 01:22 PM





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