Jump to content

Creating transformed XML using XSLT


dark_ixion

Recommended Posts

Hi,

 

I need to create newly transformed XML given input XML and XSLT.  The problem is, all the examples I've seen require that inputs and outputs point to files, like the function xslt_process.  The reason I don't want a file for input or output is that I will already have my XML in a string and just want to return a transformed XML doc to the user without the overhead of outputting the XML to a file, then tranforming it, loading the file and returning it to the user.

 

So basically, I need something like this to work...

 

$xml = '<myxml myattrib="monkey"><test>a test</test></myxml>';
$xslt = "can be a document or a string, I don't mind";
$outputxml = xmlTransform($xml, $xslt);

// $outputxml is now a string which contains a transformed xml document

 

Does anyone know how I could do this?

Link to comment
https://forums.phpfreaks.com/topic/114642-creating-transformed-xml-using-xslt/
Share on other sites

It's part of PHP5, just not enabled by default:

http://us3.php.net/manual/en/xslt.installation.php

 

Oh, I see.

 

Unfortunately it looks like it's not enabled on my copy, which I can't change because it's part of a production environment at work.  Are there alternatives which I could use, such as a php library I can add as part of my project?  Looks like a lot of libraries have been disabled.

What about the php5 XSL library?

http://us2.php.net/xsl

This extension should be included by default, just not enabled.

 

Also if you possibly have the JavaBridge for php installed, I've read some comments in the manual in regards to using it to call the SAXON

library.

http://us.php.net/manual/en/book.xsl.php#78436

 

Although I can't speak to the performance gain/loss of this approach.

What about the php5 XSL library?

http://us2.php.net/xsl

This extension should be included by default, just not enabled.

 

Also if you possibly have the JavaBridge for php installed, I've read some comments in the manual in regards to using it to call the SAXON

library.

http://us.php.net/manual/en/book.xsl.php#78436

 

Although I can't speak to the performance gain/loss of this approach.

 

I've just checked and xsl is marked as "without", so I can't use that either :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.