WordPress plugin intelligence profile

Ten&Two XSLT Processor

Transform and display XML from local and remote sources using PHP's XSL extension.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 7.1
Current version1.0.9
WordPress coverageTested up to WordPress 7.1
Minimum stackWP 5.2 · PHP 7.4
Directory statusactive
Last directory update16 Oct 202617d ago
Active installations10Adoption metric — not a quality score
WordPress.org ratingNo WordPress.org ratings yet
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Ten&Two XSLT Processor version 1.0.9 as active, updated 17d ago and tested up to WordPress 7.1.

Overview

About this plugin

The Ten&Two XSLT Processor plugin brings the power of PHP’s XSL extension to WordPress. Once enabled, the plugin creates three (3) shortcodes – [xslt_transform_xml/], [xslt_select_xml/], and [xslt_select_csv/] – which can be used separately or in tandem to enrich your site with content from XML and CSV sources. The plugin also enables two (2) custom post types – XSL Stylesheets and XML Documents – for managing and validating sources within WP Admin.

com/

Custom Post Types

The XSLT Processor plugin provides two (2) custom post types for managing sources within WordPress – XSL Stylesheets and XML Documents. Both types include basic syntax validation. XML Documents can be validated further using DTD, XSD, or RNG.

Both types are enabled in Settings > XSLT Processor Settings > Activate Content Types.

Shortcode: [xslt_transform_xml/]

[xslt_transform_xml/] is the plugin's primary function. This shortcode processes XML data using an XSL stylesheet, and then outputs the result as HTML, more XML, or as simple TEXT.

  • [xslt_transform_xml xsl="{file|url|id|slug}" xml="{file|url|id|slug}" /]
  • [xslt_transform_xml xsl="{file|url|id|slug}"]<DATA>...</DATA>[/xslt_transform_xml]

If either the xsl or xml parameter is left unspecified, defaults are used. The default XML value is <NODATA/>. The default XSL stylesheet prints all of the incoming data as HTML.

If extra attributes are specified in the shortcode – eg, mykey="myval" – those keys/values are passed along as parameters to the stylesheet – <xsl:param name="mykey"/>.

Shortcode: [xslt_select_xml/]

[xslt_select_xml/] is a helper function. It reads XML and returns a selection of the data, based on a supplied XPath expression. There are two (2) options for specifying the XPath.

First, using the `select` attribute or, second, using the body of the shortcode. Complex select statements with quotes, square brackets or other special syntax, should use the second pattern:

  • [xslt_select_xml xml="{file|url|id|slug}" select="{XPath}" /]
  • [xslt_select_xml xml="{file|url|id|slug}"]{XPath}[/xslt_select_xml]

If the XPath select parameter is left unspecified, the default / is used, which returns the entire document. The default output is format="xml". If format="json" is specified, the result is encoded as a JSON string.

Shortcode: [xslt_select_csv/]

[xslt_select_csv/] is a helper function for converting CSV file data to XML. The result can be output directly as an HTML `<table>`, or the result can be passed to `[xslt_transform_xml/]` for further processing.

  • [xslt_select_csv csv="{file|url}" /]
  • [xslt_select_csv]{csv,data}[/xslt_select_csv]

Three (3) parameters – separator, enclosure, escape – control reading the input. See PHP’s fgetcsv() function for details.

  • [xslt_select_csv separator="," enclosure="\"" escape="\\" /]

Two (2) parameters – key_row, col – control writing columns to the output. The key_row attribute is optional, but allows labels from that row to be used in col and key_col.

  • [xslt_select_csv key_row="{num}" col="{num|letter|label}+" /]

Three (3) parameters – row, key_col, key – control writing rows to the output.

  • [xslt_select_csv row="{num}+" /]
  • [xslt_select_csv key_col="{num|letter|label}" key="{val}+" /]

Nested Shortcodes

Combine [xslt_transform_xml] with [xslt_select_xml]:

  • [xslt_transform_xml][xslt_select_xml/][/xslt_transform_xml]

Combine [xslt_transform_xml] with [xslt_select_csv]:

  • [xslt_transform_xml][xslt_select_csv/][/xslt_transform_xml]

Combine [xslt_transform_xml] with itself using [/xslt_transform_alias] (WP does not support nested shortcodes with identical names):

  • [xslt_transform_alias][xslt_transform_xml/][/xslt_transform_alias]

Combine multiple shortcodes/sources to create a single XML Document (see Custom Post Types above):

  • <DATA><PART1>[xslt_select_xml xml="f1.xml" /]</PART1><PART2>[xslt_select_xml xml="f2.xml" /]</PART2></DATA>

Cache Parameters

When a shortcode specifies a remote file – xml="{url}" or csv="{url}" – that source is cached locally using WP Transients. The default cache duration is set in the XSLT Processor Settings. To override the default, add cache="{minutes}" to the shortcode.

  • [xslt_transform_xml xml="{url}" cache="{minutes}" /]
  • [xslt_select_xml xml="{url}" cache="{minutes}" /]
  • [xslt_select_csv csv="{url}" cache="{minutes}" /]

Namespace Parameters

Within [xslt_select_xml/] the plugin provides two (2) methods for handling XML containing namespaces. The first is to add strip-namespaces to the shortcode. The second method is to add the needed prefixes and namespace URIs using xslns.

  • [xslt_select_xml xml="{file}" strip-namespaces="yes" select="//node" /]
  • [xslt_select_xml xml="{file}" xmlns="ns1" ns1="{namespace-uri-1}" select="//ns1:node" /]
  • [xslt_select_xml xml="{file}" xmlns="ns1 ns2" ns1="{namespace-uri-1}" ns2="{namespace-uri-2}" select="//ns1:node/ns2:node" /]

WP-CLI

All three (3) shortcodes have command-line equivalents. They can be used, for instance, to run quick tests. Or they can be used, by piping the outputs into files, to pre-generate results.

- wp xslt transform_xml --xsl='{file|url|id|slug}' --xml='{file|url|id|slug}' --cache='{minutes, if xsl|xml={url}}' --tidy='{yes|html}' or tidy or --tidy='xml' --{myparam}='{myvalue}' --outfile='{filepath}' --htmlentities or --htmlentities='yes'

- wp xslt select_xml --xml='{file|url|id|slug}' --cache='{minutes, if xml={url}}' --select='{xpath}' --root='{nodename|empty}' --tidy='{yes|html}' or tidy or --tidy='xml' --strip-namespaces='yes' or strip-namespaces --strip-declaration='no' --format='{xml|json}' --htmlentities or --htmlentities='yes'

- wp xslt select_csv --csv='{file|url}' --cache='{minutes, if csv={url}}' --separator=',' --enclosure='\"' --escape='\\' --key_row='{row number for column labels}' --col='{return column number(s), letter(s), or label(s)}' --key_col='{col number, letter, or label for key matching}' --key='{value(s) for key_col matching}' --row='{return row number(s)}' --class='{css classname(s) for result table}' --htmlentities or --htmlentities='yes'

XSL Stylesheets

The XSLT Processor plugin includes a number of useful XSL templates that you can include and use in your own projects. They are grouped into five files.

  • date.xsl: date-format, date-microtime
  • file.xsl: file-exists-local, file-exists-remote
  • string.xsl: string-replace, string-upper, string-lower, string-title-case, string-trim, string-rtrim, string-ltrim, string-maxlength, string-maxwords, string-add-slashes, string-urlencode, string-strip-tags, string-nl2br, string-entity-decode, string-to-nodeset
  • util.xsl: util-bytsize, util-hash-data, util-print-nodes, util-print-node-names, util-super-global
  • wp.xsl: wp-select-xml, wp-select-csv, wp-post-item, wp-post-meta, wp-sanitize-title, wp-size-format

Requirements

The Ten&Two XSLT Processor plugin relies upon PHP’s XSL extension. If the extension is installed, the XSLT Processor Settings screen will display a message similar to the first message below. If LIBXSLT_VERSION is undefined, all plugin options are disabled automatically and the second message is displayed.

  • PHP's XSL extension is available: XSLT v1.1.32, EXSLT v1.1.32, LIBXML v2.9.4
  • PHP's XSL extension is NOT available

php

>

“This extension requires the libxml PHP extension. This means passing the –with-libxml,

4 the –enable-libxml, configuration flag, although this is implicitly

accomplished because libxml is enabled by default.

org/XSLT/. libxslt

”

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • csv
  • shortcode
  • xml
  • xsl
  • xslt
Compatibility & maintenance

Compatibility & maintenance

Tested with WP 7.1

Marked as tested with the current WordPress 7.1 release.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to7.1
Minimum requirementsWordPress 5.2 · PHP 7.4
Update activity16 Oct 202617d ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

Version1.0.81.0.9
Version1.0.71.0.8
WordPress compatibility6.5.107.1.3
Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.