icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » viewing xsl formatted xml as xhtml

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old October 2nd, 2004, 2:41 PM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
25 posts
Gave thanks: 0
Thanked 0 times
viewing xsl formatted xml as xhtml

I created a page that is xml formatted with xsl, and have it looking the way that I want it to in IE6. Now I would like it to convert this page to various other formats...xhtml, pdf, etc. Does anyone know how this can be accomplished?

The following PHP code will do the conversion to XML
<?php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->load('example.xml');

$xsl = new DomDocument;
$xsl->load('example.xsl');

/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?>
But I am recieving an error:

Warning: domdocument() expects at least 1 parameter

Fatal error: Call to undefined function: load()

What is the missing parameter? I got the code of php.net, so it should be complete.

I have found that Apache Xalan will do these transformations, but I am unfamiliar with it. Does anyone have any wise words for me?

Last edited by whitee; October 2nd, 2004 at 2:47 PM..
whitee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 2nd, 2004, 3:09 PM   #2 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
25 posts
Gave thanks: 0
Thanked 0 times
fix error?

My Wyatts says the answer to the problem when he had it was to disable the domxml extension in his php.ini file. Am I able to do this?
whitee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 2nd, 2004, 6:27 PM   #3 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
25 posts
Gave thanks: 0
Thanked 0 times
XHTML Problem Solved

I had been using PHP5 code....the following works for PHP 4.3. It creates a DOM XML document, applies the xslt stylesheet to transform the data, and then converts it to xhtml and outputs it to the browser.

<?php
$xmlpath = dirname("full_file_path") . "//";
$xmldoc = domxml_open_file( $xmlpath . "file.xml");
$xsldoc = domxml_xslt_stylesheet_file ( $xmlpath . "file.xsl");
$result = $xsldoc->process($xmldoc);
print $result->dump_mem();
?>

I still need to figure out how to output to a PDF file.
whitee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 29th, 2005, 4:56 AM   #4 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2005
2 posts
Gave thanks: 0
Thanked 0 times
any luck with changing this ini file?
i think I am running into a similar prob.
new to xml and am trying to get my first example up.
let me know how you made out.
alex01 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 29th, 2005, 9:26 AM   #5 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
25 posts
Gave thanks: 0
Thanked 0 times
Alex,

Whether or not you can edit your php.ini file depends on your setup. My site is hosted on Surpass servers, so I couldn't make the necessary changes to use the features that I wanted. I just decided to wait until I was hosting my own site (which didn't happen as I had planned).
whitee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 29th, 2005, 3:40 PM   #6 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2005
2 posts
Gave thanks: 0
Thanked 0 times
Whitee

hummm...did you ask support in this matter?
I am just trying ot display an rss feed from another
site in my site. i think it can be done, but am still learning
here. I am using php in combo with wordpress. just trying
to get the server to translate the XSLT fragment. well
thanks for the reply. good luck there with you site.
alex01 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On