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 October 10th, 2005, 03:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT and styling

I am trying to make an XML file, which I want to show using an XSLT document. However, I want to make some words in e.g. a description found in the XML file bold, like in the following...
Code:
<description>This is a <b>demo</b> description.</description>
But it does not seem to be carried over to the XSLT document? Why? How to solve this?

I am aware that the XSLT document is the style sheet, why the style should be placed in this, however I will allow this simple styling from my XML document anyways.

Thanks, Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old October 11th, 2005, 02:02 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It would help if you showed a sample of what you are trying to create. Is it an HTML document?

--

Joe (Microsoft MVP - XML)
 
Old October 11th, 2005, 03:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, sorry. I simply want to do simple markup in the XML file and then have this markup (e.g. the boldface) appear in the HTML document generated using the XSLT document; i.e. when extracting the description value from the XML document I would like the word demo to appear as bold in the browser.

When I try to do this now it seems like the bold tags are disappearing.

The test XML document...
Code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<test>
    <description>This is a <b>demo</b> description.</description>
</test>
The XSLT document named test.xsl...
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes"/>
    <xsl:template match="test">
        <html>
            <head></head>
            <body><xsl:value-of select="description" /></body>        
        </html>
    </xsl:template>
</xsl:stylesheet>
Thanks, Jacob.
 
Old October 11th, 2005, 04:03 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

xsl:value-of extracts the text of an element and loses any internal mark-up. Use xsl:copy-of.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 13th, 2005, 02:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot. Works beautifully. Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Controls and Styling robzyc ASP.NET 2.0 Basics 4 July 8th, 2008 05:39 AM
PHP Styling adaniels11 PHP How-To 1 April 10th, 2007 05:10 AM
Styling pie charts in SSRS 2005 Dangermouse BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 February 20th, 2007 07:28 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
Nav Bar Styling VictorVictor BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 May 16th, 2006 06:02 PM





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