WordPress Xslt Processor plugin – follow up

So, a user of the plugin asked me on how to make the plugin also have parameters for the xsl file. And I ended up coding it because it seemed simpler that way.

This this post servers as much as a test bed as a presentation of the different kind of options one can use:

So lets start with the most basic way to use this plugin:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example]

Result

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example]

or:

[XmlProcessor xml=”wp-content/plugins/CPT_XslProcessor/example.xml” xslt=”wp-content/plugins/CPT_XslProcessor/example.xsl”]

Result:

[XmlProcessor xml="wp-content/plugins/CPT_XslProcessor/example.xml" xslt="wp-content/plugins/CPT_XslProcessor/example.xsl"]

Now, lets say you want to add options to the xsl file:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example params=”default_param=this is the replaced default parameter”]

Result:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example params="default_param=this is the replaced default parameter"]

or:

[XmlProcessor xml=”xml_filepath” xslt=”xslt_filepath” params=”default_param=this is the replaced default parameter”]

Result:

[XmlProcessor xml="wp-content/plugins/CPT_XslProcessor/example.xml" xslt="wp-content/plugins/CPT_XslProcessor/example.xsl" params="default_param=this is the replaced default parameter"]

And that should actually be working now :)

Tags: , ,

2 Responses to “WordPress Xslt Processor plugin – follow up”

  1. jdbrew says:

    Great plugin! One question – is there any way of passing in XML files that do not reside on the same server? eg: http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml

  2. Chryzo says:

    Hello,
    Sorry for the late reply, was out of the net for a while :)

    Yes it is possible if you modify the code of the processor. At the moment the path is hardcoded on line 126, it can be made so that if the http:// string is present in the xml / xsl file path then said path is not modified.
    It would go something like this:
    If http:// is present in $xml then do nothing, otherwise, $xml = $path.$xml
    if http:// is present in $xsl then do nothing, otherwise, $xsl = $path.$xsl

    The modification necessary should be around line 126/127

    Hope it helps,

Leave a Reply

You must be logged in to post a comment.