hello,
I have a main php file which outputs xhtml but i have an include php file that dynamically generates xml which imports fragment xsl stylesheet
im trying to use the ob_start() functions to display this page but i dont seem to be getting it
can you give me some advice on how i can get this displayed?
Kendall
Outputting XML in PHP/HTML
Moderator: General Moderators
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Ok this is the process...
the main page
the file that outputs the xml
xsl stylesheet
the xml output
the main page
Code: Select all
<?php
some include stuff, databases connections
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CMS Home Page</title>
<script language="javascript" src="/cms/includes/cms.js" type="text/javascript"></script>
<link href="/cms/includes/cms_css.css" type="text/css" rel="stylesheet" />
</head>
<body>
<p><?php print "Hello ".$_SESSION['User']->name." Id Number#: ".$_SESSION['User']->userID; ?>
You have:
<?php
if(isset($_SESSION['Grant']))
print 'Grant Privileges<br/>';
if(isset($_SESSION['Edit']))
print 'Add Privileges<br/>';
?>
</p>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="25%">// ouputs the xml content
<?php include('taskmenuoptions.php'); ?><? ob_end_clean(); ?></td>
<td width="75%"> </td>
</tr>
</table>
</body>
</html>Code: Select all
<?php
php includes and connection stuff
?>
header("Content-type: text/xml");
print "<?xml version=\"1.0\"?>\n";
print "<?xml-stylesheet type=\"text/xsl\" href=\"/cms/menus/list_menu.xsl\"?>\n";
print "<menus>\n";
$section = NULL;
while($menus = $sqlConn->fetchObject()){
if($section != $menus->MenuGroup){
if(isset($close_tag)){
print "\t</section>\n";
unset($close_tag);
}
$close_tag = true;
$section = $menus->MenuGroup;
printf("\t<section name=\"%s\">\n",$menus->MenuGroup);
}
// get menu items for each section
printf("\t\t\t<menu id=\"%d\" name=\"%s\" link=\"%s\" contentid=\"%s\" parentid=\"%s\" order=\"%d\" site=\"%d\">\n",$menus->MenuID
,$menus->MenuName
,$menus->MenuLink
,$menus->ContentID
,$menus->MenuParent
,$menus->NavOrder
,$menus->Status
);
GetSubMenus($menus->MenuID);
}
print "\t</section>\n</menus>";Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- DWXMLSource="menus.xml" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:template match="menus">
<div>
<xsl:call-template name="section"/>
</div>
</xsl:template>
<xsl:template name="name" match="@name">
<li><xsl:value-of select="@name"/></li>
</xsl:template>
<!-- <xsl:template name="MENU">
<xsl:for-each select="MENU">
<xsl:sort select="@NavOrder" data-type="number" order="ascending"/>
<xsl:call-template name="MenuName"/>
<xsl:if test="count(child::*) > 0">
<xsl:call-template name="MENU"/>
</xsl:if>
</xsl:for-each>
</xsl:template>-->
<xsl:template name="menu" match="menu">
<xsl:for-each select="menu">
<xsl:sort select="@order" data-type="number" order="ascending"/>
<xsl:call-template name="name"/>
<xsl:if test="count(child::*) > 0">
<ul><xsl:call-template name="menu"/></ul>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="section" match="section">
<ul>
<xsl:for-each select="section">
<xsl:call-template name="menu">
</xsl:call-template>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>Code: Select all
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/cms/menus/list_menu.xsl"?>
<menus>
<section name="pendings">
<menu id="1111" name="View Pending Documents" link="index.php" contentid="" parentid="0" order="1" site="1">
<menu id="232321" name="Add a Pending Document" link="index.php?action=add" contentid="" parentid="1111" order="2" status="1">
</menu>
</menu>
</section>
<section name="menus">
<menu id="2222" name="Explore Website Menus" link="index.php" contentid="" parentid="0" order="3" site="1">
<menu id="222213" name="Add Menu Item" link="index.php?action=add" contentid="" parentid="2222" order="4" status="1">
</menu>
<menu id="37736" name="View Document Library" link="docs/index.php" contentid="" parentid="2222" order="5" status="1">
<menu id="624213" name="Add New Document" link="docs/index.php?action=add" contentid="" parentid="37736" order="6" status="1">
</menu>
</menu>
</menu>
</section>
<section name="users">
<menu id="3334" name="View CMS Users" link="index.php" contentid="" parentid="0" order="7" site="1">
<menu id="3341" name="Add New User" link="index.php?action=add" contentid="" parentid="3334" order="8" status="1">
</menu>
<menu id="3330" name="Vew User Docs" link="userdocs/index.php" contentid="" parentid="3334" order="9" status="1">
<menu id="333412" name="Add Item to User" link="userdocs/index.php?action=add" contentid="" parentid="3330" order="10" status="1">
</menu>
</menu>
</menu>
</section>
</menus>- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
This is what im getting when i execute the process
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CMS Home Page</title>
<script language="javascript" src="/cms/includes/cms.js" type="text/javascript"></script>
<link href="/cms/includes/cms_css.css" type="text/css" rel="stylesheet" />
</head>
<body>
<p>Hello Main Administrator Id Number#: TEST123 You have:
Grant Privileges<br/>Add Privileges<br/></p>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="25%"><?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/cms/menus/list_menu.xsl"?>
<menus>
<section name="pendings">
<menu id="1111" name="View Pending Documents" link="index.php" contentid="" parentid="0" order="1" site="1">
<menu id="232321" name="Add a Pending Document" link="index.php?action=add" contentid="" parentid="1111" order="2" status="1">
</menu>
</menu>
</section>
<section name="menus">
<menu id="2222" name="Explore Website Menus" link="index.php" contentid="" parentid="0" order="3" site="1">
<menu id="222213" name="Add Menu Item" link="index.php?action=add" contentid="" parentid="2222" order="4" status="1">
</menu>
<menu id="37736" name="View Document Library" link="docs/index.php" contentid="" parentid="2222" order="5" status="1">
<menu id="624213" name="Add New Document" link="docs/index.php?action=add" contentid="" parentid="37736" order="6" status="1">
</menu>
</menu>
</menu>
</section>
<section name="users">
<menu id="3334" name="View CMS Users" link="index.php" contentid="" parentid="0" order="7" site="1">
<menu id="3341" name="Add New User" link="index.php?action=add" contentid="" parentid="3334" order="8" status="1">
</menu>
<menu id="3330" name="Vew User Docs" link="userdocs/index.php" contentid="" parentid="3334" order="9" status="1">
<menu id="333412" name="Add Item to User" link="userdocs/index.php?action=add" contentid="" parentid="3330" order="10" status="1">
</menu>
</menu>
</menu>
</section>
</menus></td>
<td width="75%">ff</td>
</tr>
</table>
</body>
</html>A couple of articles on XSL transformations:
http://www.tonymarston.net/php-mysql/cl ... -xslt.html
http://www.tonymarston.net/php-mysql/xsl.html
http://www.tonymarston.net/php-mysql/sablotron.html
http://www.tonymarston.net/php-mysql/cl ... -xslt.html
http://www.tonymarston.net/php-mysql/xsl.html
http://www.tonymarston.net/php-mysql/sablotron.html