Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:49:15+00:00 2026-05-29T08:49:15+00:00

I have a Plone site, themed with plone.app.theming. The problem I have is that

  • 0

I have a Plone site, themed with plone.app.theming. The problem I have is that the design is quite strict and doesn’t assume any empty <p> elements or any other nonsense TinyMCE outputs. Such elements break the intended design. So I want to strip the empty elements from the content. I have tried inline xslt (that, according to http://diazo.org/advanced.html#inline-xsl-directives should be supported) like:

<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[not(*) and not(text()[normalize-space()])]"/>

But it didn’t do the trick. In fact it made something weird. The empty p tags that I wanted to get rid of stayed intact but some other elements like

<a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a>

turned into

<a href="mylink"></a>

with the image being striped out. Replacing match="*[… in the second template to match="p[… didn’t strip out the images, but those nasty <p> were still in the output.

Any hints on how to get rid of the empty elements using Diazo rules?

UPDATE January 31, 2012
Here is the content from which I need the empty p tags to be stripped off:

<div id="parent-fieldname-text">
<p></p>
<p> </p>
<p> </p>
<p><section id="what-we-do">
<p class="visualClear summary">Not empty Paragraph</p>
<ul class="thumbsList">
    <li><a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a></li>
    <li><a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a></li>
</ul>
</section></p>
</div>

The Diazo transformation rules:

<?xml version="1.0" encoding="UTF-8"?>
<rules
    xmlns="http://namespaces.plone.org/diazo"
    xmlns:css="http://namespaces.plone.org/diazo/css"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="p[not(*) and not(normalize-space())]"/>

    <!-- The default theme, used for standard Plone web pages -->
    <theme href="index.html" css:if-content="#visual-portal-wrapper" />

    <replace css:theme-children="div.contentWrapper" css:content-children="#content" />            
</rules>

The output I get after applying the transformations to the Plone site is absolutely identical to the input while I would expect to get those 3 empty <p> tags after opening <div> to go away.

If I change the second template to match all elements like match="*… then the images get stripped out, but the empty <p> tags are still there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:49:15+00:00Added an answer on May 29, 2026 at 8:49 am

    Works for me. I’ve added an example of using Dimitre’s xpath in a drop content rule at https://github.com/plone/diazo/commit/94ddff7117d25d3a8a89457eeb272b5500ec21c5 but it also works as the equivalent xsl:template. The example is pared down to the basics but it works using the complete example content in the question too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site which has a public url displayed through a plone.app.theming /
We have a Plone site that is primarily in English but has some content
I have a Plone site (Plone version 3.1.2) that I need to install a
I have a Plone site that is upgraded from Plone 3.3.5 to 4.0.7. From
I have a site that processes orders taken by phone into a SQL database.
We have an old Plone site with Data.fs and blobstorage which has probably been
I have a Plone 4.1 site using the OpenId module. When a user clicks
I have been running zope / plone site for about a year now -
I have already a page template for the default view of a Plone site
I have been asked to convert an entire site that is currently using wordpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.