plainblack.com
Username Password
search
Bookmark and Share

XMLTemplate (Wobject)

The XMLTemplate Wobject is a beta project which I wrote for the purpose of giving myself a WebGUI interface for displaying simple XML as HTML.  Basically, it allows you to upload an XML document, or point to one on the web and then display the data inside an HTML Template that you can define.

My original plan was to link an XML document to an XSLT spreadsheet, however I could not find a good XSLT parser written in PERL.

Thus the XMLTempate wobject was born.

This Wobject is far from finished, however I am posting it here for 2 reasons:
First and foremost, it does work with simple xml documents providing and easy solution for displaying xml data in html format

Second, I'd really like to complete the project, however I don't have the time right now.  Considering that, as it stands, it meets my needs I probably never will.  My hope is that someone will pick up where I left off and finish or add to it.

Some Ideas that I have that I don't have time to implement:
- get nested loops working.
- Implementing <IF>/<ELSEIF>/<ELSE> statements (started)
- Allowing the inclusion of XSLT stylesheets instead of an HTML template.
- Possibly implementing a better XML parser
- WebGUI macro processing for more powerful templates
- Possible integration with the current WebGUI Template engine.
- Adding xml file filtering and HTML Template validation to make it more error proof.
- anything else you can think of!

Anything you'd like to contribute to this project would be great!  I think this Wobject has real potential, and can be extremely useful.  I realize that this is far from completed,
and not really practical for use with business level xml data, but
I hope that it is of use to some and fun to tinker with for others.

Please send me any contribution you make and I'll update the downloads section.
As of now, the work is not internally documented.  If you have questions, feel free to send me an email.

*************************************************************************************************
Installation:
- You will first need to install the XML-Simple Perl Module (this is included in the ActiveState ActivePerl 5.8.0 distribution)
- Unzip into your /WebGUIRoot directory.
- Navigate to /WebGUIRoot/docs and run the sql script create-XMLTemplate-0.1.0.sql
- You should now be able to create a new XMLTemplate.
- Have fun!

*************************************************************************************************
How to use the XMLTemplate:
- Create a new XMLTemplate wobject as you would any other wobject.
- In the "XML Data Source" field, either choose an xml file from your system, or type in the URL of the xml document you'd like to use.
- In the "HTML Template for XML Data" Area, create your html.  To use the date from your XML file, follow the following simple xml tags I have defined:

(The xml document root is always ignored)

Access an XML Element:
<xml>element_tag</xml>

Access an Element Attribute
<xml>element,attribute</xml>

Process a Loop
<loop element="elementToLoopOver">
  <xml>elementInsideLoop</xml>
</loop>


Here's an example.  Please note that this is a made up XML document:

<?xml version="1.0" ?>
<sales>
  <information summary="Purchases made outside the retail store"/>
  <client name="Sue" surname="Summers" phone="555-2345" title="Vice President" email="ssummers@mycompany.com">
     <purchase type="Cash" id="163750" total="$45.00"/>
     <salesman>Brian Johnson</Salesman>
  </client>
  <client name="Joe" surname="Jackson" phone="555-2878" title="Purchasing Agent" email="jjackson@yourcompany.com">
     <purchase type="PO" id="25462321" total="$300.00"/>
     <salesman>Brian Johnson</Salesman>
  </client>
</sales>


Template to display this data:
<table>
   <tr><th><xml>information,summary</xml></th></tr>
   <tr>
      <td>Client Name</td>
      <td>Client Phone Number</td>
      <td>Client Email Address</td>
      <td>Total</td>
      <td>Salesman</td>     
   </tr>
   <loop element="client">  
      <tr>
         <td><xml>name</xml> <xml>surname</xml></td>
         <td><xml>phone</xml></td>
         <td><xml>email</xml></td>
         <td><xml>purchase,total</xml></td>
         <td><xml>salesman</xml></td>
      </tr>
   </loop>
</table>

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
Comments
4ehab: "
IS this compatible with 5.1.2, i tried it and it gives error in the log file  meaning it can not create the new object when i try to create an xml wobject after i enter the data.

 

Ehab Heikal

www.valuecms.com

Quote: An eye for an Eye only helps make the whole world blind

Ghandi

 
"
4ehab: "
The object worked perfectly my installation was flawed, there are a lot of dependancies for XML::Simple take care.

Ehab Heikal

www.valuecms.com

Quote: An eye for an Eye only helps make the whole world blind

Ghandi

 
"
DownloadXMLTemplate_v0.1.0.zip XMLTemplate_v0.1.0.zip
LinksNo Support Offered
Statistics Downloads: 382
Views: 4808
Rating: 4
Updated: 8/12/2005
Keywords Assets Templates
NavigationBack to the Bazaar
© 2017 Plain Black Corporation | All Rights Reserved