October 17th, 2001, 04:19 AM
XML in a real life situation
I read the books, I read the tutorials, I read several devshed articles on this subject, but I still find it difficult to get the pieces togheter and figure out a real life use of XML.
I have a website running with Mac OS 9.2, WebTen, FileMaker and Lasso, but in the future I will have Mac OS X, Apache, MySQL and PHP. In this site I have a section with +250 files of text. These files share the same structure (ie can share the very same DTD) and contain an extensive description of items (one file, one item). Let's say the files are like small books with same structure.
Each file is more than 75 k of text and to spare bandwith I split them in 20 sections (ie chapters), serving the right one on user request (I use Lasso includes to do this).
I also distribute these files to customers, but they don't want HMTL formatting, or better they want to use their HTML formatting. And they don't want split files.
I managed to prepare a DTD a to make a XML version of a test file (which proved well formed and valid), but now I am stuck. What do I have to do to publish my XML file on my site? I think I should use XSL, but what wizardry do I have to use to get HTML out from XML and to publish just the only section the user requests to see?
Thank you a lot for your time and help.
October 17th, 2001, 03:58 PM
Yust a little example to set you on the way:
<?xml:stylesheet type="text/xsl" href="mailinglist.xsl"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><HTML><BODY><TABLE BORDER="2"><TR STYLE="font-size:8pt; font-family:Verdana; color:white; text-decoration:underline"><TD STYLE="background-colorurple">mail</TD></TR><xsl:for-each select="Data/Record"><TR STYLE="font-family:Verdana; font-size:8pt; color:black; padding:0px 6px"><TD><xsl:value-of select="mail"/></TD></TR></xsl:for-each></TABLE></BODY></HTML></xsl:template></xsl:stylesheet>
Take a look at how it transforms the xml file.
You can find good tutorials at www.ibm.com/developerworks
Hope this helps!
October 17th, 2001, 06:06 PM
Thank you for your help, but I tried and I could see just an empty square...
The real problem, however, is I dont' think relying on the user's browser to parse and 'convert' xml is a good solution. We are talking about a commercial site and I don't want to loose customer just because they don't have the most updated browser. I think I would think the same also for a 'non commercial' site.
I was asking wether it is possible to convert XML to HTML on the server side (in real time or not) serving normal HTML to clients.
Again, thanks a lot for your time.
October 17th, 2001, 06:16 PM
I use PHP's XML parser to create HTML server-side from XML
It's great because PHP tags in XML don't have to output HTML, they can perform any PHP function whatsoever as well.
Guess where I learnt to do it as well? Yes... PHP with XML on DevShed
October 18th, 2001, 01:49 AM
Hi, I'm sorry but I made a mistake (XSL not made for this XML file, look at "value-of select="mail"/" where there is no "mail" in XML).
You can apply transformations srver side via Apache Cocoon, look for it at www.phpbuilder.com.
October 18th, 2001, 08:28 AM
I got one...
Well I was asked today to work with docushare I have to learn XML because this the language used in the template system. I also have to create my own pages using the database...
That is one real life situation I have come by recently.
Still don't know how to do a "Hello World"?