Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 9th, 2008, 01:58 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default Creating customised quote with terms and conditions using XSLT

Hi,

I used XSLT in an assignment in unuversity a few years back. I have developed an application that produces a drawing in SVG. What I want to do is to produce a quote using data held in my mysql db that can include these svg drawings. Am I right in thinking I can achieve this with XSLT and can anyone point me in the direction of a good working example of what I am trying to do?
Already know about W3C and Tizag tutorials
Reply
  #2  
Old October 9th, 2008, 02:54 PM
Moderator
 
Join Date: Mar 2006
Posts: 898
Default

? produce a quote?

Not sure what you're trying to do.
Reply
  #3  
Old October 9th, 2008, 03:01 PM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 676
Default

What should the output be, (X)HTML?

You need at least one script language that will get you the DB data.

And to answer your question–yes (except if you want to do something crazy)

regards

PS if you have an idea what the final result will look like, I can tell you if my answer was right.
Reply
  #4  
Old October 10th, 2008, 08:23 AM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default

OK what I said before wasn't quite clear. I have all the information I need in my db and I want to produce a standard document with a load of pages of information that are always the same. I will be using the data in the database to fill in specific information in the document, like the companies name, the price they have been quoted, etc. What I also want to do if possible is to include an SVG drawing in the document. The drawing will be different in each document but again I have all the co-ordinates and info in my db.

What I am after is a good tutorial or a working example where someone else has done something similar. Can anyone help?
Reply
  #5  
Old October 10th, 2008, 08:36 AM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 676
Default

Quote:
Originally Posted by cleary1981
What I am after is a good tutorial or a working example where someone else has done something similar. Can anyone help?
So if I understand you right, you can already build the pages without the svg. So basically you need something in your script that takes the coordinates (...) from the db, calls the xsl, does the transformation and puts it onto the page, right?

regards
Reply
  #6  
Old October 10th, 2008, 08:57 AM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default

Sorry, I haven't done any of ths XSLT stuff yet. I have created the database of all the co-ordinates and customer information. I want to get some idea of the end result before I start learning XML, XSLT, DTD's etc.
Reply
  #7  
Old October 10th, 2008, 09:49 AM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 676
Default

Quote:
Originally Posted by cleary1981
Sorry, I haven't done any of ths XSLT stuff yet. I have created the database of all the co-ordinates and customer information. I want to get some idea of the end result before I start learning XML, XSLT, DTD's etc.
problem: IE doesn't natively support SVG (you have to use addons for that) but since I do not have IE, I hardly know all obstacles

problem2: you should be more concerned, what your final result shall be. once you have that, we can help you getting there.

If you want to have a look what a page looks like, that uses XSLT to produce output, have a look at my home page (see member info) most of the code comes from xml files (all the navigation related stuff). you'll see that it's undistinguishable from pure html code. (example xsl file).

regards
Reply
  #8  
Old October 10th, 2008, 10:06 AM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default

I have used svg with IE already. You just need the adobe SVG plugin. I have been doing a bit of googling to get a better insight. What I want to do is use php to extract my info from mysql into an xml document. From here I want to use XSLT to format the document and draw the SVG image. The end result I want to achieve is a pdf document.

A bit longwinded so there must be a better alternative
Reply
  #9  
Old October 10th, 2008, 10:43 AM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 676
Default

you could store the svg coordinates already as xml in the db. if that's not an option, I need to have a look at the desired svg and its coordinates (...) to make any judge, but that shouldn't be the problem.

which way do you (want to) make the pdf?

regards
Reply
  #10  
Old October 10th, 2008, 12:00 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default

I am working away at generating my xml now. will post what I have when im done
Reply
  #11  
Old October 13th, 2008, 01:58 PM
Familiar Sight
 
Join Date: Jun 2008
Posts: 135
Default

Ok, heres what I have so far, but I don't know how it all fits together.

I have generated my xml with information extracted from my db using php. Heres the code.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. header("Content-type: text/xml"); 
  4.  
  5. require "config.php";
  6.  
  7. $proj = 'j8888'; //$_REQUEST['proj'];
  8.  
  9. $q1 = mysql_query("SELECT * FROM company, project WHERE company.company_name = project.company_name AND proj_id = '$proj'") or die(mysql_error);
  10. $r1 = mysql_fetch_assoc($q1);
  11. $acc_no = $r1['acc_no'];
  12. $company_name = $r1['company_name'];
  13. $contact = $r1['contact'];
  14. $add1 = $r1['add1'];
  15. $add2 = $r1['add2'];
  16. $town = $r1['town'];
  17. $county = $r1['county'];
  18. $pcode = $r1['pcode'];
  19. $tel = $r1['tel'];
  20. $proj_id = $r1['proj_id'];
  21. $project_name = $r1['project_name'];
  22. $form = $r1['form'];
  23. $access = $r1['access'];
  24. $cable_entry = $r1['cable_entry'];
  25. $ip_rating = $r1['ip_rating'];
  26. $fault_rating = $r1['fault_rating'];
  27. $proj_manager = $r1['proj_manager'];
  28. $deadline = $r1['deadline'];
  29.  
  30. $q2 = mysql_query("SELECT * FROM object, module WHERE object.module_name = module.module_name AND proj_id = '$proj'");
  31.  
  32.  
  33. //start of xml document
  34. $xml_output = "<?xml version=\"1.0\"?>\n"; 
  35. $xml_output = "<?xml-stylesheet type='text/xsl' href='quote.xsl'?>\n";
  36. $xml_output .= "<quote>\n"; 
  37.     $xml_output .= "\t<company>\n";
  38.         $xml_output .= "\t\t<comp_name>" . $company_name . "</comp_name>\n";
  39.         $xml_output .= "\t\t<contact>" . $contact . "</contact>\n";  
  40.         $xml_output .= "\t<address>\n";
  41.             $xml_output .= "\t\t<add1>" . $add1 . "</add1>\n";  
  42.             $xml_output .= "\t\t<add2>" . $add2 . "</add2>\n";
  43.             $xml_output .= "\t\t<town>" . $town . "</town>\n";  
  44.             $xml_output .= "\t\t<county>" . $county . "</county>\n";  
  45.             $xml_output .= "\t\t<pcode>" . $pcode . "</pcode>\n";  
  46.         $xml_output .= "\t</address>\n";
  47.         $xml_output .= "\t\t<tel>" . $tel . "</tel>\n";  
  48.     $xml_output .= "\t</company>\n";
  49.     $xml_output .= "\t<details>\n";
  50.         $xml_output .= "\t\t<proj_id>" . $proj_id . "</proj_id>\n";
  51.         $xml_output .= "\t\t<proj_name>" . $project_name . "</proj_name>\n";  
  52.         $xml_output .= "\t\t<form>" . $form . "</form>\n";  
  53.         $xml_output .= "\t\t<access>" . $access . "</access>\n";  
  54.         $xml_output .= "\t\t<cable_entry>" . $cable_entry . "</cable_entry>\n";  
  55.         $xml_output .= "\t\t<ip>" . $ip_rating . "</ip>\n";  
  56.         $xml_output .= "\t\t<fault>" . $fault_rating . "</fault>\n";  
  57.         $xml_output .= "\t\t<proj_manager>" . $proj_manager . "</proj_manager>\n";  
  58.         $xml_output .= "\t\t<deadline>" . $deadline . "</deadline>\n";  
  59.     $xml_output .= "\t</details>\n";
  60.  
  61.     $xml_output .= "<objects>\n";
  62.         for($x = 0 ; $x < mysql_num_rows($q2) ; $x++){
  63.             $r2 = mysql_fetch_assoc($q2); 
  64.             $obj_id = $r2['object_id'];
  65.             $xml_output .= "\t<obj id='$obj_id'>\n";
  66.                 $xml_output .= "\t\t<object_name>" . $r2['object_name'] . "</object_name>\n"; 
  67.                 $xml_output .= "\t\t<module_name>" . $r2['module_name'] . "</module_name>\n"; 
  68.                 $xml_output .= "\t\t<mod_desc>" . $r2['mod_desc'] . "</mod_desc>\n"; 
  69.                 $xml_output .= "\t\t<obj_desc>" . $r2['objDesc'] . "</obj_desc>\n"; 
  70.                 $xml_output .= "\t\t<xpos>" . $r2['xpos'] . "</xpos>\n"; 
  71.                 $xml_output .= "\t\t<ypos>" . $r2['ypos'] . "</ypos>\n"; 
  72.                 $xml_output .= "\t\t<height>" . $r2['height'] . "</height>\n"; 
  73.                 $xml_output .= "\t\t<width>" . $r2['width'] . "</width>\n"; 
  74.                 $xml_output .= "\t\t<depth>" . $r2['depth'] . "</depth>\n"; 
  75.             $xml_output .= "\t</obj>\n"; 
  76.         }
  77.     $xml_output .= "</objects>"; 
  78.  
  79. $xml_output .= "\t</quote>\n";
  80.  
  81. echo $xml_output; 
  82.  
  83. ?> 
  84.  
I have installed Apache FO on my machine and have got the example file on the site to work in command line using the following instruction

Expand|Select|Wrap|Line Numbers
  1. fop -xml name.xml -xsl name2fo.xsl -pdf name.pdf
I get the idea of how this works but I want php to do this part for me. Is this possible? Can anyone show me how?
Reply
  #12  
Old October 13th, 2008, 06:12 PM
Dormilich's Avatar
Expert
 
Join Date: Aug 2008
Location: Leipzig, Germany
Age: 31
Posts: 676
Default

Quote:
Originally Posted by cleary1981
I get the idea of how this works but I want php to do this part for me. Is this possible? Can anyone show me how?
php4:
[PHP]$handle = xslt_create();
$result = xslt_process($handle, $xmlfile, $xslfile);
xslt_free($handle);[/PHP]
php5: (use the XSLTProcessor class class)
[PHP]$xml = new DOMDocument;
$xml->load('file.xml');

$xsl = new DOMDocument;
$xsl->load('file.xsl');

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
$result = $proc->transformToXML($xml);[/PHP]

regards
Reply
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles