Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
For the longest time, I had a problem with the bloat that XML had in comparison to other text data formats (CSV, etc.) so I had a difficult time understanding how XML could be a benefit. More reading uncovered some really cool stuff that XML can do that is a benefit to the web world.

The ability to template web content (content management systems) is becoming a huge business. The concept is to separate your content (in this case XML) from the style (CSS) and from your design (a template.) Now the template concept can be with HTML::Template using XML::Parser or XML::Simple to extract, but I found a quicker way, and it was built into XML.

The template that you create is utilizing XSL (Extensible Stylesheet Language) which is a natural parser for XML and applying HTML to it's content based upon your XSL template. For any of you who have created TMPL files with HTML::Template, the XSL is almost identical to it, but you don't have to parse the XML and THEN walk the data through the template!!!

Although that discovery was neat, it didn't help much, since you still just viewed the XML in a browser window that supported XML, and then it automatically applied the XSL to it for the display. If by chance you didn't have a browser to view the XML, then you were out of luck. It was at this time that I thought about going back to HTML::Template, but then I discovered another of XML's tools... SAX (Simple API for XML). Actually if you do a search for SAXON, it is a small program that is an interface to the SAX. Essentially you:
saxon -o myhtml.html myxml.xml myxsl.xsl
Which can be run from a system command from Perl, so there is no issue. You can throw an output (-o filename.html) to make a html file then hand the program the XML and XSL files.

The benefit is that now everything is seperate and I've preserved my original data. I no longer have to walk back through my HTML trying to find my XML, and I didn't have to parse the XML myself. The XSL simply is a faster process than parsing and doing the HTML::Template.

For more information on the basics of XSL go here: http://www.w3schools.com/xsl/default.asp.
For more information on SAXON go here: http://saxon.sourceforge.net/

BTW: XSL is markup, but you will see mention of XSLT as well... it's simply the XSL Translation which is essentially processing the files. (Just to clear up any confusion.)

- Mission

In reply to Re: XML for databases?!?! YES!!! With XML, XSL, and SAXON! by Mission
in thread XML for databases?!?! Is it just me or is the rest of the world nutz? by S_Shrum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found