The Ten & Two XSLT Processor plugin brings the power of PHP’s XSL Extension to WordPress. Once enabled, the plugin creates three (3) powerful WordPress Shortcodes which can be used separately or in tandem to enrich your site with content from XML sources.
Files stored on your server can be used as a local sources. URLs can specify remote sources, such as feeds and API services. And, after enabling the plugin’s two Custom Post Types – XSL Stylesheets
and XML Documents
– you can also manage stylesheets and data directly in WordPress.
Getting Started
- Installation – Download and install.
- Settings – Configure options.
Shortcodes
[xslt_transform_xml/]
– Process XML using XSL stylesheets.[xslt_select_xml/]
– Filter XML using XPath select statements.[xslt_select_csv/]
– Convert CSV to XML for display or XSL processing.- WP-CLI – Command-line equivalents
Stylesheets
The XSLT Processor plugin includes a number of useful XSL templates that you can use in your own projects. They are grouped into five (5) XSL files.
- date.xsl –
date-format
,date-microtime
- file.xsl –
file-exists-local
,file-exists-remote
,file-listing-local
- 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-hash-data
,util-print-nodes
,util-print-node-names
,util-super-global
- wp.xsl –
wp-post-item
,wp-post-meta
,wp-sanitize-title
,wp-select-csv
,wp-select-xml
,wp-size-format
How To
The emphasis in the following examples is on function rather than design. The assumption is that you’ll want to customize and polish the layout. So, HTML in the stylesheets is kept to a minimum.
- 101 – XSL Stylesheets – Data and stylesheet basics.
- 102 – XML Namespaces – Working with namespaces.
- Atom Feeds – Format and display Atom data.
- BeerXML – Display your favorite brewing recipes.
- Google Sheets (.html) – Access <table> data in webpages.
- JSON – Format XML as JSON and pass data to Javascript.
- PHP Callbacks – Add PHP functions to your stylesheets.
- RSS Feeds – Format and display RSS data.
Further Reading
Go deep.
- XML – eXtensible Markup Language – is a standard for storing and transferring structured data in a format that is readable by both humans and machines.
- XSL – eXtensible Stylesheet Language – is a language for transforming XML documents into new documents. Common result formats include XML, HTML, TEXT, JSON, and XSL-FO.
- XPath , – XML Path Language – defines a compact method of selecting or referencing nodes within an XML document. It is built into XSL and used extensively within stylesheets.
- XSLT – XSL Transformations – then, is the combined process: parsing the XML, applying the XSL stylesheet, and generating a document in the specified format.
- XML Schemas are descriptions of XML documents. Documents following popular schemas are often freely available.