[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Application Design

  • From: Al Snell <alaric@a...>
  • To: fpgomez@r...
  • Date: Fri, 10 Aug 2001 01:52:53 +0100 (BST)

php application design
On Thu, 9 Aug 2001 fpgomez@r... wrote:

> I am looking at using XML for this.

> 3) Does anybody see any potential problems with this approach?

Yes... I'm not sure it's worth using XML here. What will it gain you as
opposed to a set of PHP pages that talk directly to the database? Unless
you have particular programming experience with XSLT and not
PHP/ASP/CGIs/whatever, I find it easier to set up PHP under Apache than to
set up an XSLT engine and put things in place to make a web server invoke
it against XML pulled from an SQL database.

<table>
<tr>
	<th>Name</th>
	<th>Description</th>
</tr>
<?

	mysql_connect(...);
	$q = mysql_query(
		"SELECT * FROM Documents WHERE name LIKE '" .
		addslashes($HTTP_GET_VARS["id"]) .
		"'");

	while($row = mysql_fetch_row($q)) {
		?>
		<tr>
			<td><a href="/documents/<?= $row["filename"] ?>"><?= $row["name"] ?></a></td>
			<td><?= $row["description"] ?></td>
		</tr>
		<?
	}
?>
</table>

One neat feature of PHP/ASP/whatever over XSLT is that:

1) It's a real programming language. It can access databases, the
filesystem, various networking APIs, .dbm files, etc

2) It's imperative, which means that it can not only format data into an
output, but it can update the database too.

If you're planning on writing PHP/ASP/whatever that outputs XML elements
and then transforms them with XSLT to produce HTML, that's a bit more
sensible, but a lot more work than just emitting HTML in the first place.
Seperate content from formatting by putting all the SQL calls in a PHP
function library in a seperate file, and have .php files in the web space
directory that are just HTML templates with holes cut in them to call the
database functions.

This is a lot simpler to set up (only one language is needed, you don't
need to install an XML parser and an XSLT engine, and all the data flow
from back end to front end is done via function call interfaces rather
than an XML document with a DTD/schema/informal prose description). And
the resulting programming model is just the difference between:

<html><head><title>
 <xsl:value-of select="/page/title" />
</title>...
<xsl:for-each select="/page/results">
	<tr>...</tr>
</xsl:for-each>

and:

<? include "../backend.inc" ?>
<title><?= $title ?></title>...
<? while($row=nextResult()) { ?>
	<tr>...</tr>
<? } ?>

...there's no real difference between the two, you just use different
sequences of magic symbols.

> Fred Gomez

ABS

-- 
                               Alaric B. Snell
 http://www.alaric-snell.com/  http://RFC.net/  http://www.warhead.org.uk/
   Any sufficiently advanced technology can be emulated in software


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.