convert JSP xslt transform to PHP

I

inetquestion

I have the following jsp file and which takes an xml file as a query
parameter. It then transforms the xml into html with an xsl file with
the same base name as the xml file.

I need to convert this to a php page, but dont understand where the
taglibs come into play...

any suggestions?



----render.jsp----
<%@page contentType="text/html"%>
<%@ taglib uri="/x" prefix="x" %>
<%@ taglib uri="/c" prefix="c" %>

<c:import url="/stylesheets/${param.xml}.xsl" var="style"/>
<c:import url="${param.xml}.xml" var="doc"/>

<x:transform xml="${doc}" xslt="${style}"/>
 
A

Arne Vajhøj

inetquestion said:
I have the following jsp file and which takes an xml file as a query
parameter. It then transforms the xml into html with an xsl file with
the same base name as the xml file.

I need to convert this to a php page, but dont understand where the
taglibs come into play...

any suggestions?

----render.jsp----
<%@page contentType="text/html"%>
<%@ taglib uri="/x" prefix="x" %>
<%@ taglib uri="/c" prefix="c" %>

<c:import url="/stylesheets/${param.xml}.xsl" var="style"/>
<c:import url="${param.xml}.xml" var="doc"/>

<x:transform xml="${doc}" xslt="${style}"/>

You want to to the same PHP?

I guess you should use:
http://www.php.net/manual/en/book.xsl.php

Untested:

<?php
$xml = new DOMDocument();
$xml->load($_GET['xml'] . '.xml');
$xsl = new DOMDocument();
$xsl->load($_GET['xml'] . '.xsl');
$t = new XSLTProcessor();
$t->importStylesheet($xsl);
echo $t->transformToXML($xml);
?>

Arne
 
I

inetquestion

inetquestionwrote:
I have the following jsp file and which takes an xml file as a query
parameter.  It then transforms the xml into html with an xsl file with
the same base name as the xml file.
I need to convert this to a php page, but dont understand where the
taglibs come into play...
any suggestions?
----render.jsp----
<%@page contentType="text/html"%>
<%@ taglib uri="/x" prefix="x" %>
<%@ taglib uri="/c" prefix="c" %>
<c:import url="/stylesheets/${param.xml}.xsl" var="style"/>
<c:import url="${param.xml}.xml" var="doc"/>
<x:transform xml="${doc}" xslt="${style}"/>

You want to to the same PHP?

I guess you should use:
   http://www.php.net/manual/en/book.xsl.php

Untested:

<?php
$xml = new DOMDocument();
$xml->load($_GET['xml'] . '.xml');
$xsl = new DOMDocument();
$xsl->load($_GET['xml'] . '.xsl');
$t = new XSLTProcessor();
$t->importStylesheet($xsl);
echo $t->transformToXML($xml);
?>

Arne



That works...many thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top