Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2007, 01:26 PM
Registered User
 
Join Date: Jul 2007
Location: Palm Bay, FL, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to pauljr8
Default Pass link values as xsl:parameter to php5 then xsl

Hello,
I am stuck. The following asp accepts and passes xsl parameters from a web page which then transforms my xsl, but for the life of me I can't get php to do the same. I want to be strictly LAMP, no $MS stuff.

selectmenu.asp
---------------------------------------
<%
Dim xslDoc, xmlDoc
Dim name
sname=Request.QueryString("name")

set xmlDoc = server.CreateObject("Msxml2.FreeThreadedDOMDocumen t.3.0")
set xslDoc = server.CreateObject("Msxml2.FreeThreadedDOMDocumen t.3.0")

xmlDoc.async = False
xslDoc.async = False

xmlDoc.load server.mapPath("index.xml")
xslDoc.load server.mapPath("index.xsl")

Set template = Server.CreateObject("MSXML2.XSLTemplate.3.0")
Set template.stylesheet = xslDoc

Set proc = template.createProcessor
proc.input = xmlDoc

proc.addParameter "name", sname
proc.transform

Response.Write proc.output
%>


index.xsl
---------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml"
doctype-public="-//W3C//DTD XHTML 1.1//EN" indent="yes" encoding="utf-8" />

<xsl:param name="name" select="'Home'" />
<xsl:param name="Ncols" select="'2'" />

<xsl:template match="/">
<html>
<head>
<meta name="description" content="Praise Cathedral - Church of God, Palm Bay Florida" />
<meta name="keywords" content="praise cathedral, church of God, palm bay, brevard county, christian fellowship" />
<title><xsl:value-of select="title" /></title>
<link href="praise.css" type="text/css" rel="stylesheet" />
</head>

<body>

<div class="header" align="center" valign="top"><img src="images/praiselogo.gif" alt="Praise Cathedral - Church of God, Palm Bay Florida" /></div>

<div class="lsidebar" align="left">
<br /><br />
<ul align="left"><xsl:for-each select="site/menus/menu">
<li align="left"><strong><a><xsl:attribute name="href">selectmenu.php?name=<xsl:value-of select="@name" /></xsl:attribute>
<xsl:value-of select="@name" /></a></strong><br /><br />
</li>
</xsl:for-each>
</ul>
</div>

<div class="main" align="center"><xsl:apply-templates select="site/menus/menu[@name=$name]" /><br />

<div class="footer" align="center">Site created and maintained by <a href="http://sunshinearcade.christianpatriot.us" target="blank">Sunshine Arcade</a><br /> Copyright© 2000</div></div>

</body>
</html>
</xsl:template>

<xsl:template match="announcement"><br />
<div>
<xsl:for-each select="."><h3 align="center"><xsl:value-of select="./@name" /></h3>
<p align="left"><xsl:apply-templates />
</p>

</xsl:for-each>
</div>
</xsl:template>

...

</xsl:stylesheet>

selectmenu.php
---------------------------------------
<?
$name=$_GET['name'];
//$name = $_REQUEST['name'];
$xp = new XsltProcessor();

// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument;
$xsl->load('index.xsl');
// import the XSL styelsheet into the XSLT process
$xp->importStylesheet($xsl);

// create a DOM document and load the XML data
$xml_doc = new DomDocument;
$xml_doc->load('index.xml');
$xp->setParameter('', 'name', $name));
if ($html = $xp->transformToXML($xml_doc)) {
echo $html;
} else {
trigger_error('XSL transformation failed.', E_USER_ERROR);
}
?>

index.php calls the xml and xsl files and renders them correctly. The links it creates reflect that the link urls are (for example) selectmenu.php?name=Services but this doesn't seem to get passed into selectmenu.php or passed back to the xsl to display the relevant page. Instead the "Home" page (the default xslarameter) is displayed. Putting $ in place of @ in the xsl causes a blank page to be rendered and a myriad of other tries also don't produce the right results. The preceeding code might not make sense as I gave up exasperated to write this.

Please help as I don't want to revert back to asp and all that that encompasses.

Fedora Core 5

PHP 5.2.0
./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-gd' '--with-gettext' '--with-xsl=/usr/lib' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-regex=system' '--with-zlib' '--with-curl' '--with-openssl' '--enable-mbstring'

Apache 2.2.3

I do think I've tried everything, even to the point of being ridiculous. Sorry for the smilies in the code; not my fault.

TIA
Paul


Paul Hickey
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2007, 10:32 PM
Registered User
 
Join Date: Jul 2007
Location: Palm Bay, FL, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to pauljr8
Default

Just needed a couple days away from the problem.
This works like a champ except I want to get rid of my urls appearing as; for example
www.example.com/selectmenu.php?name=events
instead of www.example.com

<?
$name=$_GET['name'];
//$name = $_REQUEST['name'];
$xp = new XsltProcessor();

// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument;
$xsl->load('index.xsl');
// import the XSL styelsheet into the XSLT process
$xp->importStylesheet($xsl);

// create a DOM document and load the XML data
$xml_doc = new DomDocument;
$xml_doc->load('index.xml');
//$xp->setParameter('','name', $name);
//$proc->transform;
$xp->setParameter('', 'name', $name);
if ($html = $xp->transformToXML($xml_doc)) {
      echo $html;
  } else {
      trigger_error('XSL transformation failed.', E_USER_ERROR);
}


Paul Hickey
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass xsl:param to xsl:if bonekrusher XSLT 5 September 6th, 2007 04:37 PM
Pass a parameter from java servlet to xsl anithapeeris XSLT 3 June 20th, 2007 01:57 AM
pass DOM to XSL as parameter asap XSLT 3 March 30th, 2006 05:22 PM
Pass multiple values to XSL? myhtpc XSLT 5 March 17th, 2006 11:16 AM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 03:15 AM



All times are GMT -4. The time now is 11:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.