XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 8th, 2002, 02:40 PM
bwurster bwurster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 17 bwurster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 42 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old December 8th, 2002, 06:46 PM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 11 m 27 sec
Reputation Power: 27
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.
__________________
- Andreas Koepke

I have photos for sale at RedBubble


Reply With Quote
  #3  
Old December 9th, 2002, 10:04 AM
bwurster bwurster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 17 bwurster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 42 sec
Reputation Power: 0
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?

Reply With Quote
  #4  
Old December 9th, 2002, 02:37 PM
lola891 lola891 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 10 lola891 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:

<xslutput method="html" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>

Reply With Quote
  #5  
Old December 9th, 2002, 02:47 PM
bwurster bwurster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 17 bwurster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 42 sec
Reputation Power: 0
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).

Reply With Quote
  #6  
Old December 9th, 2002, 06:18 PM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 11 m 27 sec
Reputation Power: 27
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:
function show($xmlFile,$xslFile$arguments
 {
  
$xh xslt_create();
  
$result xslt_process($xh$xmlFile'$xslFile'NULL$arguments);
  print 
$result;
  
xslt_free($xh);
 } 


That will process them and display the HTML.

Last edited by a.koepke : December 9th, 2002 at 06:21 PM.

Reply With Quote
  #7  
Old December 15th, 2002, 05:08 AM
Zitan Zitan is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2001
Location: New Zealand
Posts: 638 Zitan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 10 sec
Reputation Power: 8
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

Reply With Quote
  #8  
Old December 19th, 2002, 03:33 AM
Shocka's Avatar
Shocka Shocka is offline
dont click here
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 409 Shocka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 35 m
Reputation Power: 7
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.

Reply With Quote
  #9  
Old March 15th, 2003, 03:20 PM
acostin acostin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bucharest
Posts: 1 acostin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to acostin
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

Reply With Quote
  #10  
Old March 21st, 2003, 02:14 PM
acidbox acidbox is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 10 acidbox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m
Reputation Power: 0
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.

Reply With Quote
  #11  
Old March 23rd, 2003, 02:46 AM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 11 m 27 sec
Reputation Power: 27
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.

Reply With Quote
  #12  
Old March 23rd, 2003, 03:54 PM
acidbox acidbox is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 10 acidbox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m
Reputation Power: 0
Quote:
Originally posted by a.koepke
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.


what is the arguments variable for? Do I have to assign arguments?

Reply With Quote
  #13  
Old March 23rd, 2003, 08:29 PM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 11 m 27 sec
Reputation Power: 27
Look in the manual for xslt_process

Quote:
PHP Code:
 $arguments = array(
     
'/_xml' => $xml,
     
'/_xsl' => $xsl
);

// Allocate a new XSLT processor
$xh xslt_create();

// Process the document
$result xslt_process($xh'arg:/_xml''arg:/_xsl'NULL$arguments); 


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Why use XML?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: »