OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application Design



On Thu, 9 Aug 2001 fpgomez@rockwellcollins.com 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