Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 8th, 2004, 11:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
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!
Reply With Quote
  #2 (permalink)  
Old September 10th, 2004, 03:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
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>
Reply With Quote
  #3 (permalink)  
Old December 31st, 2006, 10:04 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old January 1st, 2007, 06:13 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
  #5 (permalink)  
Old January 1st, 2007, 07:02 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:31 PM.


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