Author:
TwistedInteractive
Version:
1.00
Release Date:
7 Oct 2010
Category:
Output

Description

Sometimes you want to split the content provided by the author into 2 blocks.

This utility allows you to show content before a horizontal rule and after a horizontal rule individualy.

Example usage:

<xsl:apply-templates select="page-content/entry/content" mode="before-hr" />
<xsl:apply-templates select="page-content/entry/content" mode="after-hr" />

Note: This utility does not show anything if there is no horizontal rule. To detect something like that using a <choose>:

<choose>
  <xsl:when test="count(page-content/entry/content/hr) = 1">
    <xsl:apply-templates select="page-content/entry/content" mode="before-hr" />
    <xsl:apply-templates select="page-content/entry/content" mode="after-hr" />
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="page-content/entry/content/*" />
  </xsl:otherwise>
</choose>

XSLT

View Raw
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<!--
		Horizontal rule splitter
		========================================================================
		version:	1.00
		author:		Twisted
		website:	www.twisted.nl
		========================================================================
		This utility allows you to show content before a horizontal rule and
		after a horizontal rule individualy.
		
		Example usage:
		
		<xsl:apply-templates select="page-content/entry/content" mode="before-hr" />
		<xsl:apply-templates select="page-content/entry/content" mode="after-hr" />
		
		Note: This utility does not show anything if there is no horizontal rule.
		To detect something like that using a <choose>:
		
		<choose>
			<xsl:when test="count(page-content/entry/content/hr) = 1">
				<xsl:apply-templates select="page-content/entry/content" mode="before-hr" />
				<xsl:apply-templates select="page-content/entry/content" mode="after-hr" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy-of select="page-content/entry/content/*" />
			</xsl:otherwise>
		</choose>
	-->
	
	<!-- Fetch the content before the horizontal rule: -->
	<xsl:template match="*" mode="before-hr">
		<xsl:copy-of select="./*[following-sibling::hr]" />
	</xsl:template>
	
	<!-- Fetch the content after the horizontal rule: -->
	<xsl:template match="*" mode="after-hr">
		<xsl:copy-of select="./*[preceding-sibling::hr]" />
	</xsl:template>
</xsl:stylesheet>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details