Pass querystring to XSL through module I'm trying to do some fancy navigational work within a large XML sheet, and am generating links with querystrings in my transformation.

What I would like to do is parse the querystring within my .module file, and then pass it somehow to the XSL processor.

Essentially, right now I have (without any error handling at present):

/* generate hook */
function _xml_import_generate()
{
  $p = $_GET['p'];

  $path = drupal_get_path('module', 'xml_import');

  $xsl = new DOMDocument();
  $xsl-&gt;load("{$path}/xml_import.xsl");

  $xslt = new XSLTProcessor();
  $xslt-&gt;importStyleSheet($xsl);

  $xml = new DOMDocument();
  $xml-&gt;load("feed.xml");

  return (string) $xslt-&gt;transformToXML($xml);
}


I can't seem to find any documentation regarding this...but how do I pass $p into my XSL transformation?
I think you just need to parse out the query string, and then use XSLTProcessor::setParameter:

/* generate hook */
function _xml_import_generate()
{
  $p = $_GET['p'];

  $path = drupal_get_path('module', 'xml_import');

  $xsl = new DOMDocument();
  $xsl-&gt;load("{$path}/xml_import.xsl");

  $xslt = new XSLTProcessor();
  $xslt-&gt;importStyleSheet($xsl);

  $xslt-&gt;setParameter("", "p", $p);

  $xml = new DOMDocument();
  $xml-&gt;load("feed.xml");

  return (string) $xslt-&gt;transformToXML($xml);
}


Your parameter should then appears as a &lt;xsl:param /&gt; in your XSLT.