homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Create a doc with <?php .?> before DOCTYPE declaration
Claes100

5+ Year Member



 
Msg#: 3867583 posted 11:10 pm on Mar 10, 2009 (gmt 0)

Hi,
I've been using Saxon for creating a website's html and php files from our XML source files.
In our next project I need to be able to output some php code at the very top of each document, before the doctype declaration and <html> tag.
The big Q is... how do I do that?

This is what I use today:

<xsl:transform version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" encoding="UTF-8"/>
:
:
<xsl:template mode="newpage" match="*">
<xsl:param name="filename">
:
</xsl:param>
<xsl:document href="{normalize-space($filename)}">
<html>
<xsl:apply-templates select="." mode="skel.header">
:
:

but I cannot figure out how to include some php code at the very top.

My generated php files come out as:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
:
:

but I would like:

<?php include 'authorizeUser.php' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
:
:

Is that possible...?
Thanks!
/Claes

[edited by: eelixduppy at 11:20 pm (utc) on Mar. 11, 2009]
[edit reason] disabled smileys [/edit]

 

httpwebwitch

WebmasterWorld Administrator httpwebwitch us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3867583 posted 3:56 pm on Mar 11, 2009 (gmt 0)

you're using Saxon to generate PHP? That's rather unorthodox... but if you can make it work, could be quite a powerful technique! Just curious, is this being done in preprocessing, or at runtime?

remove the <xsl:output> element, or change its method attribute. When you start injecting <?stuff?>, You're not outputting HTML any more :)

try putting this in your XSLT

<xsl:text>
<![CDATA[
<?php print("test"); ?>
]]>
</xsl:text>

when you do output the php, you'll need to ensure that the output is being parsed by the PHP engine. depending on when/how the XML->XSLT->output is being done, you might just end up with PHP code rendered on the page. Do please report back here if you get it working!

Claes100

5+ Year Member



 
Msg#: 3867583 posted 8:19 am on Mar 12, 2009 (gmt 0)

Thanks httpwebwitch,
I'll try to get it working tonight/tomorrow.
We are preprocessing the php files and then uploading to server.
/Claes

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved