Any way to easily have a node which just simply displays an XML file as processed by an XSL parser?

Comments

dries’s picture

AFAIK no one has done this before so it is not possible out of the box, or using a particular module. Then again, it should be a straightforward hack if you're familiar with XML and XSLT.

tlarrow’s picture

Maybe I'll get around to hacking it someday, but as my data is semi-static (changes weekly) I just copied/pasted the data as it was displayed in FireFox, and pasted it into Dreamweaver, which generated the HTML which matched the layout. I then copied the HTML and dumped it into a Drupal Node.

I'll poke around and see if I can get it to do it right, but for now, this sort of works.

seaneffel’s picture

This worked for me, using PHP 4 with XSLT enabled on the shared server. Created a new drupal node, paste in this PHP code, select PHP code input format, and change the two variables to point to your XML and XSL files. This is specialized to pull the XML file from a remote web site. Hope it helps, I looked for this answer for forever, some nice drupalers helped me out.

function HTTPRequest($url){ 
      $ch = curl_init(); 
      curl_setopt($ch,CURLOPT_URL,$url); 
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
      curl_setopt($ch,CURLOPT_MUTE,1); 
      curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER["HTTP_USER_AGENT"]); 
      curl_setopt($ch, CURLOPT_TIMEOUT, 10); //times out after 10 
      curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); 
      $data = curl_exec ($ch); 
      curl_close ($ch); 
      return $data; 
  }
$xmlDATA = HTTPRequest("enteryourremotexmlfilehere.xml");
$arguments = array('/_xml' => $xmlDATA);
  $xsltproc = xslt_create();
  xslt_set_encoding($xsltproc, 'ISO-8859-1');
$html =
      xslt_process($xsltproc, 'arg:/_xml', "enteryourxslsheethere.xsl", NULL, $arguments);

  if (empty($html)) {
      die('XSLT processing error: '. xslt_error($xsltproc));
  }
  xslt_free($xsltproc);
print($html);