[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Formatting bold and italics within a paragraph

Subject: Formatting bold and italics within a paragraph
From: "Gagan Bhalla" <gbhalla@xxxxxxxxxxxxxx>
Date: Thu, 23 Aug 2001 15:37:37 -0500
fo italics
Hello,
I am trying to write a stylesheet that converts paragraphs into fo:blocks
and while doing so, it retains the formatting inside the para, for example
the bold and italic tags embedded inside the <p> and </p> tags? How do I get
text embedded within a pargraph to get recognized and output in the order it
is encountered?

For example, If I have XML like :
<html xml:lang="en" lang="en">
<body>
<p>This is normal text. This is<b>something in bold </b>Text after bold.
This is <i>In Italics.</i> Text after Italics.</p>
</body>
</html>

Currently, I have a template in my stylesheet that tries to detect the child
tags, <b> and <i> once it reaches a para and output them inline. But it
does'nt get me the text that is within the para but outside the embedded
tags. For example, the output of the above XML upon running thru the XSL
given is missing the "Text after bold. This is" and "Text after Italics." in
it's output.

<fo:block>This is normal text. This is<fo:inline font-style="bold" font-size
="20pt" > something in bold </fo:inline><fo:inline font-style="italic"
font-size ="20pt" > In Italics.</fo:inline><fo:inline font-style="normal"
font-size ="10pt" > This is normal text. This is</fo:inline></fo:block>

Thanks,
Gagan


The stylesheet code fragment looks like this:

<xsl:template match="html/body/p">
	<xsl:text disable-output-escaping="yes">&lt;fo:block&gt;</xsl:text>

	<xsl:value-of select="text()" />

	<xsl:for-each select="child::*">
		<xsl:choose>
		<xsl:when test="name()='b'">
			<!-- this creates a FO with bold tag -->
	        	<xsl:text disable-output-escaping="yes">&lt;fo:inline
font-style="bold" font-size ="20pt" &gt;</xsl:text><xsl:text>
</xsl:text><xsl:value-of select="." />
	        	<xsl:text
disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>

		</xsl:when>
		<xsl:when test="name()='i'">
			<!-- this creates a FO with italicized text -->
	        	<xsl:text disable-output-escaping="yes">&lt;fo:inline
font-style="italic" font-size ="20pt" &gt;</xsl:text>			<xsl:text>
</xsl:text><xsl:value-of select="." />
	        	<xsl:text
disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>

		</xsl:when>
		<xsl:otherwise>
			<!-- this creates a FO with normal text -->
	        	<xsl:text disable-output-escaping="yes">&lt;fo:inline
font-style="normal" font-size ="10pt" &gt;</xsl:text>			<xsl:text>
</xsl:text><xsl:value-of select="." />
	        	<xsl:text
disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:for-each>

	<!-- remainder of the para after reading all embedded tags -->
	 <xsl:text disable-output-escaping="yes">&lt;fo:inline font-style="normal"
font-size ="10pt" &gt;</xsl:text><xsl:text> 	</xsl:text><xsl:value-of
select="text()" /><xsl:text
disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
	<xsl:text disable-output-escaping="yes">&lt;/fo:block&gt;</xsl:text>
</xsl:template>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.