Ten&Two XSLT Processor

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.

Detailed documentation and sample code can be found at https://plugins.tenandtwo.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 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 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 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=""\"" /]
0

评论0

 
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
显示验证码
没有账号?注册  忘记密码?

社交账号快速登录