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 September 8th, 2004, 11:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default a bold word in a selected sentence

Wonder if I can do this with xsl-fo:

If I pull this element from my xml-source:
    <para>How do <b>you</b> do</para>

using a
..select="para"

from my xsl, then how do I format the single word 'you' into bold, italic or whatever?

Could anyone explain the procedure to achieve this?

Thanks in advance!

//Forgot to mention, I transform to pdf with FOP!
 
Old September 10th, 2004, 03:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ask and ye shall find.

Easy, if you know how to. For anyone interested:

    <xsl:template match="b">
        <fo:inline font-weight='bold'><xsl:apply-templates/></fo:inline>
    </xsl:template>
 
Old December 31st, 2006, 10:04 PM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I searched and found this old post, which directly answers my question... except I cannot get it to work. I know I am making a fundamental mistake, but I just don't know where.

In the XML code below, how do I print out the contents defined by the element "concept" while italicizing the equation delimited by the identifier "math"? What would the XSLT file look like?

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="lessonplan.xsl"?>

<standard number="2.12.7">
 <concept>
   Consider the equation <math>x + y = 3</math>.
 </concept>
</standard>

Here is the lessonplan.xsl file I wrote, without the attempt to italicize the equation:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
  <html>
  <body>
    <h2>Lesson Plan</h2>
    <xsl:value-of select="//concept"/>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


Thanks.

 
Old January 1st, 2007, 06:13 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Use template rules:

<xsl:template match="/">
  <html>
  <body>
    <h2>Lesson Plan</h2>
    <xsl:apply-templates/>
  </body>
  </html>
</xsl:template>

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

<xsl:template match="math">
<i><xsl:apply-templates/></i>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 1st, 2007, 07:02 PM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, it works. Strange how I found so little information on inline formatting on the Web. It seems as that would be a very common formatting technique.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy whole sentence that contains "Alarm" mona_upm84 Excel VBA 3 September 10th, 2008 01:03 PM
search a text and return the sentence sankar2chat SQL Server 2000 9 July 17th, 2008 02:27 PM
How a Specific word in JTextArea can be selected mrafaqi Java GUI 1 February 2nd, 2005 10:08 PM
Pick a sentence out of a memo field stryker43 Crystal Reports 1 October 14th, 2004 05:23 PM
How a particular word in JTextArea is selected mrafaqi Java GUI 1 April 11th, 2004 09:14 AM





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