#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    Italy
    Posts
    2
    Rep Power
    0

    XML in a real life situation


    Hello!

    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.
  2. #2
  3. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    538
    Yust a little example to set you on the way:

    DATA.XML

    <?xml version="1.0"?>
    <?xml:stylesheet type="text/xsl" href="mailinglist.xsl"?>
    <xda>
    <field>
    <campo>name</campo>
    <campo>surname</campo>
    </field>
    <Data>
    <Record>
    <nome>john</nome>
    <cognome>smithi</cognome>
    </Record>
    </Data>
    </xda>

    DATA.XSL

    <?xml version="1.0"?>
    <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!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    Italy
    Posts
    2
    Rep Power
    0
    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.
  6. #4
  7. No Profile Picture
    Motown Junker
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    14
    Rep Power
    0
    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
  8. #5
  9. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    538
    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.
    Good luck!
  10. #6
  11. No Profile Picture
    Devshed Gringo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Toronto, Ontario
    Posts
    448
    Rep Power
    61

    Exclamation


    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.

    SG
    Still don't know how to do a "Hello World"?

IMN logo majestic logo threadwatch logo seochat tools logo