|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Why use XML?
I have been reading a book on XML and am beginning to see the potential of XML to abstract the content out of web pages similar to how CSS abstracts out the design portion. However, I am failing to see how this can improve my web development projects right now. Accessing XML files directly, formatted by CSS, you are going to run into older browser incompatibilities. I mostly use PHP/MySQL to build my dynamic sites and I can't seem to see how XML can be incorporated to make a significant improvement. I've read that "using XML in conjunction with a relational database allows you to harness the power of both" but I just don't see the advantage of using them together. I am very interested in learning more about XML, but why should I continue if I can't find an advantage over my proven/reliable relational database? Does anyone have any advice, examples, or ideas as to how to take advantage of both?
|
|
#2
|
||||
|
||||
|
I have just finished creating a cd based php program. I used Xitami to act as a webserver and link in PHP. I needed some sort of datasource that was based on the cd and trying to run a full db server was not an option so i used xml. it was easy to search and sort when used with xsl and very easy to display as html.
Another use is sharing information between sites. What would you do if you provide some content to others from your database. You want enable other people to access that content so they can use their own code to display it. Are you going to give out your database username and password.. i HOPE not. What you do is setup an XML feed on your site. From there they can link in with xsl and php or java, asp, perl and heaps of other languages to display the xml as html. Also due to using a server side language to dynamcially generate the XML the information is updated live. In relation to the example you specified with normal webpages it makes content management easier. You can have one template HTML page (written in XSLT form) and then have xml pages with all the data. The XML page is loaded and merged with the XSL page to produce the HTML. You can have any drongo update the site since XML is so easy to edit and understand. Also changing design or links isnt that hard since there is only 1 file to edit. |
|
#3
|
|||
|
|||
|
Thanks for the reply. Using XML for data sharing and when you don't have database access are very valid uses, but neither are a very common situation for me. The content managment example is closer to what I am looking for, but are there any advantages to combining this with a relational database? I am pretty new to this, but would you have to manually apply an XSLT stylesheet to the XML files via the command line or design a script to do it? Is there a way to define a stylesheet for your XML data and have it converted to HTML on the fly when requested by a visitor? Can you point me to any good tutorials?
|
|
#4
|
|||
|
|||
|
I am no XML developer but it seems that all the info out there about XML is just teoretical examples with no practical application .. It took me a while to find my way and hopefully this would save you some work.
Yes , you can have an XML document and an XSL stylesheet and have the browser convert the xml into HTML when the user request your xml page. Given that the user is uaing a browser that can read xml. ( IE 5.5 and Netscape 7 work fine for me). For this to happen you don't need to do anything . Just build your xml doc - with data - and the stylsheet . Just have your xml doc point to your stylesheet - so the browser knows what stylesheet to use - Enter this line on the xml document to tell the browser what stysheet to use: <?xml-stylesheet type="text/xsl" href="stylesheet_name.xml"?> And in the stylesheet it seems that netscape needs this to do the conversion to HTML: <xsl utput method="html" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> |
|
#5
|
|||
|
|||
|
That works well, but doesn't offer much backward compatibility with older browsers. I think this article XSL Transformation With PHP And Sablotron shows a good way to transform the XML for older browsers (though I haven't tried it yet).
|
|
#6
|
||||
|
||||
|
I personally dont like the idea of relying on the browser to do it.... i prefer to send the resulting HTML to the browser, this also means the person doesnt have to download the whole xml file. If you do a search on a 4mb XML file or are using filters then only the results are passed meaning the user doesnt have to wait that long. If the user has a slow connection they may have to wait several minutes for the page to load.
The command i use for xsl parsing is PHP Code:
That will process them and display the HTML. Last edited by a.koepke : December 9th, 2002 at 06:21 PM. |
|
#7
|
|||
|
|||
|
Totally do your XML to HTML conversiton with XSL server-side and then send the finished product to the browser
![]() XML will become the standard document format in the future. Open office already supports native XML sweet. What would rather store in your db, XML or DOC ![]() |
|
#8
|
||||
|
||||
|
Real World Use of XML: Amazon.com
They send out XML files with information about books. You simply parse the XML file and u can display the information. Advantage of XML allows for usage of differnt devices such as cell phones, PDA and such. Use of XHTML futher separates styling from data, and allows for a full parsable Document. Try to parse a regular HTML document and find items wrapped between a paragraph tag. Allows to create a sort of standard for HTML design. Hope that brings to life the use of XML. |
|
#9
|
|||
|
|||
|
Mature platform for XML/XSL publishing
Hello,
If you would like to do real XML/XSL publishing in PHP, you should look at Krysalis - http://www.interakt.ro/products/Krysalis/ Not only you'll be gived a fast and tested platform for content publishing (GPL), but you'll also be able to define the way requests are served for an webapplication in a MVC approach. And you'll also have the chance of using DOMXML/DOMXSL instead of Sablotron - 5 times faster/more memory allocated. Alexandru |
|
#10
|
|||
|
|||
|
hey a.koepke, could u post an attachment of a sample of what your XSL document looks like? I'm interested in using your code.
|
|
#11
|
||||
|
||||
|
XSL is formatting that works on a specific XML document. If your document doesnt have the same formatting then it wont use the same XSL. That code i posted will parse any XML and XSL combination.
|
|
#12
|
|||
|
|||
|
Quote:
what is the arguments variable for? Do I have to assign arguments? |
|
#13
|
||||
|
||||
|
Look in the manual for xslt_process
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Why use XML? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|