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 February 15th, 2005, 05:22 PM
Authorized User
 
Join Date: Jan 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default how do you prevent <b/> or <b></b>?

Sometimes our authors create empty emphasis elements which when transformed thru xalan creates tags such as <b/> or <i/>. what is a good way to exclude these empty elements in the rendering? everything i seem to do is messing up especially in cases where there is actual content, e.g., <i><b>hello, world</b></i>.

 
Old February 16th, 2005, 04:15 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't use Xalan but if your transform is using html as its output method then it shoul not render
Code:
<b></b>
as
Code:
<b/>
. You'll have to show more of the transform and source.

--

Joe (Microsoft MVP - XML)
 
Old February 16th, 2005, 10:37 PM
Authorized User
 
Join Date: Jan 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The output method is as follows:
Code:
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"/>
This ia some a snapshot of the "offending" template. (Note: The "live" XSLT has these "choices" broken out into individual templates; however, both versions produce the same problem as described.)
Code:
    <xsl:template match="EmphasizedText | Superscript | Subscript">
        <xsl:choose>
            <xsl:when test="local-name() = 'Superscript'">
                <sup>
                    <xsl:apply-templates/>
                </sup>
            </xsl:when>
            <xsl:when test="local-name() = 'Subscript'">
                <sub>
                    <xsl:apply-templates/>
                </sub>
            </xsl:when>
            <xsl:when test="@emphasisType = 'i'">
                <em>
                    <xsl:apply-templates/>
                </em>
            </xsl:when>
            <xsl:when test="@emphasisType = 'u'">
                [u]
                    <xsl:apply-templates/>
                </u>
            </xsl:when>
            <xsl:when test="@emphasisType = 'b'">
                <strong>
                    <xsl:apply-templates/>
                </strong>
            </xsl:when>
            <xsl:when test="not(@emphasisType) and name() = 'EmphasizedText'">
                <strong>
                    <xsl:apply-templates/>
                </strong>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
Even if I altered the output method--e.g., say HTML vice XML--both
Code:
<b></b>
and
Code:
<b/>
we would prefer and desire not to render at all.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 05:22 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 10:29 AM





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