Jump to content

johndwells

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by johndwells

  1. Yep, hours after I posted my initial inquiry, I had finally figured that out. . . so I continued testing with xslt_process, and have still encountered problems...and again I think it's the problem of where everyone in the www is copy-and-pasting the same script. So I can only find the methods I'm unsuccessfully using, and neither Sablotron or PHP.net have any hints... Ah, but I finally figured everything out just now! Agh! In case any other TCHers are curious, here's what finally worked for me: <?php // Initiate the Sablotron XSLT handler $hXSLT = xslt_create(); // Pass XML and XSL data as strings into an array $aArguments = array( 'sXML' => file_get_contents("transform.xml"), 'sXSL' => file_get_contents("transform.xsl")); // Pass xslt_process the transform handler, the xml and xsl strings (as arguments), // the $sTransformResult container string, and the $aArguments array $sTransformResult = xslt_process($hXSLT, 'arg:sXML', 'arg:sXSL', NULL, $aArguments); // Print out the transformed data echo $sTransformResult; // Free up the XSLT handler resource xslt_free($hXSLT); ?> On http://www.php.net/manual/en/function.xslt-process.php they list 4 examples, but with current versions of PHP only examples 3 and 4 are correct. xslt_process can no longer accept the filenames of your xml and xslt files as arguments; you first have to set them to strings. AND you can't merely pass the strings to the function; you must set them into arrays, and pass both the array ($aArguments) and it's pair indices ('arg:sXML' and 'arg:sXSL'). The NULL is where $sTransformResult COULD go if you were to just call the function without passing the results to a string, but this doesn't work either. Boy that was a struggle to get to the solution! But the benefits are great -- instead of echoing the results to the screen, I can save them down as a static (X)HTML file. Thanks for the warm welcome to the family! You guys are the best. . . -John
  2. I'm trying to learn and practice php's abilities to transform xml via xslt, and so I've downloaded a simple set of files to begin my journey (http://www.linuxwebdevnews.com/articles/php-xslt-param/). Yet when I load them up on my site and request the *.php page, this is the response I get: Fatal error: Call to undefined function: xslt_run() in /home/.../transform.php on line 12 When I run phpinfo() I see that php is configured to run the Sablotron extension, so I'm assuming everything would work. . . Of course I'm fishing blind here since I have no experience with it yet. Any help would be greatly appreciated! TIA, John test url: http://dev.johndwells.com/transform.php
×
×
  • Create New...