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 November 22nd, 2010, 04:43 AM
Registered User
 
Join Date: Nov 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Question How can I display xml element tags as it is in HTML

Hi,

I have some XML Stuff & I want to trasform that XML file into HTML page( This HTML Page contains one html table and it consist of input XML file data)
Whats my require ment is my HTML table contains some data should like below
" <name>Gopi</name><age>24</age> "
while implementing this scenario with "xsl:copy-of " element it working but it displays like below

"Gopi24" instead of above one

Please find the example XML Code Below

XML Code:
Code:
<class>
  <name>Gopi</name>
  <age>24</age>
</class>
XSLT Code:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body><table border="1"><tr bgcolor="#9acd32"><th>Class Data</th></tr>
<tr><td><xsl:copy-of select="class"/></td></tr></table></body></html>
</xsl:template>
</xsl:stylesheet>

I Wonna result in HTML Page like it self "<name>Gopi</name><age>24</age>"
but if appears like "Gopi24"

Hope you understand my issue.

Thanks in Advance for ur valuable assistance.....
 
Old November 22nd, 2010, 05:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you want the browser to display

Code:
<data>content</data>
then you need the serialized HTML to contain

Code:
&lt;data&gt;content&lt;/data&gt;
(that is, you need to serialize the XML and insert this as a text node into the HTML). There are several ways you could do this serialization:

(a) in Saxon, the saxon:serialize() extension function

(b) write it by hand in XSLT (I believe there's a solution off-the-shelf from David Carlisle, you'll have to google for it)

Alternatively, try the <xmp> tag. This is obsolete and deprecated, but as far as I'm aware it still works, and it's often very handy. Try

Code:
<xmp><xsl:copy-of select="..."/></xmp>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old November 22nd, 2010, 07:42 AM
Registered User
 
Join Date: Nov 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Wow u saved my time & my life also.

Thank you very much..
I really learned lot of things from this forum..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying XML element in HTML attribute using XSLT bribon XSLT 3 June 16th, 2009 12:30 PM
HTML code from XML to display using XSL koenige XSLT 6 October 27th, 2008 08:11 AM
Question regarding the display of <a> tags in xml tajjyarden XSLT 1 March 21st, 2007 11:54 AM
VBA Formatting cells with Html tags read from XML hemagiri Excel VBA 0 November 22nd, 2006 02:41 AM
XSLT help : Interpretting HTML tags from XML kunal_kishan XSLT 1 June 26th, 2006 05:37 AM





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