Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic xml - htm, transformation

Status
Not open for further replies.

hame22

Programmer
Apr 25, 2005
9
GB
Hi all,

I have a question, I am producing an xml page dynamically using php and mysql database. This successfully produces a standard xml document.

I now want to stylise this document so that it appears to be a standard html page. I have applied a xsl stylesheet and it looks html until i check the source code from the browser. It is also still be spidered by search engines as an xml file rather than html.

I have looked into the php function xslt_create() and xslt_process() as a way of spitting this xml html but the functions ask for a xml file while my xml is dynamically generated by a php file.

Does anyone have any ideas how I can solve this problem as it is very important i do so!!

Thanks in advance

alex
 
Here a sample I found :

<?php

// XML string
$xml = '<?xml version="1.0"?>
<para>
change me
</para>';

// XSL string
$xsl = '
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html" encoding="ISO-8859-1" indent="no"
omit-xml-declaration="yes" media-type="text/html"/>
<xsl:param name="myvar"/>
<xsl:param name="mynode"/>
<xsl:template match="/">
My PHP variable : <xsl:value-of select="$myvar"/><br />
My node set : <xsl:value-of select="$mynode"/>
</xsl:template>
</xsl:stylesheet>';


$xh = xslt_create();

// the second parameter will be interpreted as a string
$parameters = array (
'myvar' => 'test',
'mynode' => '<foo>bar</foo>'
);

$arguments = array (
'/_xml' => $xml,
'/_xsl' => $xsl
);

echo xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments, $parameters);

?>

Best regards,

A.Brillant
EditiX - XML Editor and XSLT Debugger
 

thanks I shall try that now,

another question I hope you can sort out for me is this..


is there any benefit for me dynamically generating this XML page then converting into HTML?

these pages are used as product pages for learning objects within a catalogue and its important each object should be described using the Learning object metadata.

Is this the right way to do this or should I have individual XML files for each product??

Thanks again

alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top