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 April 14th, 2006, 08:55 AM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default format issues with UL and OL Tags.

Hi,

    I have a xml file with the following format:
  <test>
    <p>TestMe</p>
    <p>[list]Testme1</ul></p>
    <p><ol>testme2</ol></p>
    <p>Testme3</p>
    <p>Testme4</p>
  </test>
  In my xslt:
      <xsl:for-each select "test/*">
       <xsl:apply-templates select"."/>
      </xsl:for-each>

I want to avoid p tag for ul and ol if it comes after paragraph(otherwise there will be lot of space between the paragraph and UL or OL Items). Can anybody help me how can i do that one?

Thanks,
pendyala


 
Old April 14th, 2006, 03:23 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, this:

<xsl:for-each select "test/*">
<xsl:apply-templates select"."/>
</xsl:for-each>

is a rather longwinded way of saying

<xsl:apply-templates select"test/*"/>

Try this template rule:

<xsl:template match="p[ul|ol]">
  <xsl:apply-templates select="*"/>
</xsl:template>

This will remove the p element around any ul or ol, which I suspect is what you really want. However, if you prefer to do this only after another p element, you can:

<xsl:template match="p[ul|ol][preceding-sibling::*[1][self::p]]">

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 18th, 2006, 01:39 PM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much.

Quote:
quote:Originally posted by mhkay
 Firstly, this:

<xsl:for-each select "test/*">
<xsl:apply-templates select"."/>
</xsl:for-each>

is a rather longwinded way of saying

<xsl:apply-templates select"test/*"/>

Try this template rule:

<xsl:template match="p[ul|ol]">
<xsl:apply-templates select="*"/>
</xsl:template>

This will remove the p element around any ul or ol, which I suspect is what you really want. However, if you prefer to do this only after another p element, you can:

<xsl:template match="p[ul|ol][preceding-sibling::*[1][self::p]]">

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering an UL element within DIV keithc BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 April 4th, 2013 04:13 PM
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
How to reverse the <OL> </OL list? larry HTML Code Clinic 2 June 27th, 2007 03:04 PM
Something about li and ul sfs00784 CSS Cascading Style Sheets 1 July 31st, 2005 02:03 AM
TREE USING UL/LI pallone Javascript How-To 11 February 16th, 2005 04:03 PM





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