kvnmck18 Posted July 3, 2006 Share Posted July 3, 2006 If I use dom in a php can I use a php Get form to Request data in XSL that is embedded in the XML?Orginal XSL for-each line:<xsl:for-each select="//pic[@category]">to:<xsl:for-each select=" <?php echo $_REQUEST['name']; ?>">So it can change from:select="//pic[@category]" ---to---> select="//pic[@category=kitchen]"It's kindof like a "Search" XML but the Search is limited to just Search Results of: "All (being the default)" (<xsl:for-each select="//pic[@category]">), "Kitchen"(<xsl:for-each select="//pic[@category=kitchen]">), "Bath" (<xsl:for-each select="//pic[@category=bath]">), "Home"(<xsl:for-each select="//pic[@category=home]">).PM me if you want me to send you the zip files of the XML and the XSLIs this possible or is there some other way than PHP to do this? I've tried Javascript in an XSL but that didn't work. Link to comment Share on other sites More sharing options...
ThePsion5 Posted July 3, 2006 Share Posted July 3, 2006 To be honest, I don't know alot about XSL, but I suppose it's possible to use PHP code to write SXL. However, make sure your web server knows to interpret SXL for PHP code or else it won't work. Link to comment Share on other sites More sharing options...
kvnmck18 Posted July 3, 2006 Author Share Posted July 3, 2006 My server does. Link to comment Share on other sites More sharing options...
ThePsion5 Posted July 3, 2006 Share Posted July 3, 2006 If so, then you should be able to do this without any problem. Say your file is xmlstyle.xslt. To modify the stylesheet based on a php request, you would have to do something like the following in the stylesheet itself: <xsl:for-each select="<?phpif($_GET['name'] == null) print '//pic[@category]">';else print $_GET['name'];?>"> The only problem here is that you have to propogate your change from your web page, to your xml file, to your xslt file. When you call your web page that contains the XML script that you want to modify, you would need to reference the file like this: xmlfile.xml?name='something' Make sure that your web server will look in .xml files for PHP code too, of course.Now, inside of your XML file, you would insert PHP code into the part of the file that references the XSL file: <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl<?PHPif($_GET['name'] != null) print '$_GET["name"]' . $_GET['name'];?>"?> I hope this isn't too confusing, lol. Link to comment Share on other sites More sharing options...
boen_robot Posted July 4, 2006 Share Posted July 4, 2006 Sounds cool, but wait. Aren't files that are supposed to be processed by PHP always use the PHP extension? I mean, shouldn't we have an XML file called for example cdcat.php which is actually XML file and in it have a reference such as this <?xml-stylesheet type="text/xsl" href="cdcatalog.php?<?PHPif($_GET['name'] != null) print '$_GET["name"]' . $_GET['name'];?>"?> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 4, 2006 Share Posted July 4, 2006 It's probably better for the sake of portability to do that, you can have PHP output a header to specify any mime-type you want, but you can also set up the server to send any file extension to PHP. You can send all .html files to PHP if you want, but those .html files probably won't execute on some other server without changing it also, and there will also be a little bit of overhead since PHP always gets called whether it needs to or not. Link to comment Share on other sites More sharing options...
ThePsion5 Posted July 5, 2006 Share Posted July 5, 2006 Sounds cool, but wait. Aren't files that are supposed to be processed by PHP always use the PHP extension? I mean, shouldn't we have an XML file called for example cdcat.php which is actually XML file and in it have a reference such as this<?xml-stylesheet type="text/xsl" href="cdcatalog.php?<?PHPif($_GET['name'] != null) print '$_GET["name"]' . $_GET['name'];?>"?> <{POST_SNAPBACK}> You're probably right, but I'd rather set the server to parse XML and XSL files for PHP rather than parsing all files as such, simply for the sake of consistency (and security too) - telling the server to parse XML and XLS files should be relatively easy, at least it is for my Apache server. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now