 | 
October 9th, 2008, 01:58 PM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| | 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
| 
October 9th, 2008, 02:54 PM
| | Moderator | | Join Date: Mar 2006
Posts: 898
| |
? produce a quote?
Not sure what you're trying to do.
| 
October 9th, 2008, 03:01 PM
|  | Expert | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 676
| |
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.
| 
October 10th, 2008, 08:23 AM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| |
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?
| 
October 10th, 2008, 08:36 AM
|  | Expert | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 676
| | 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
| 
October 10th, 2008, 08:57 AM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| |
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.
| 
October 10th, 2008, 09:49 AM
|  | Expert | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 676
| | 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
| 
October 10th, 2008, 10:06 AM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| |
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
| 
October 10th, 2008, 10:43 AM
|  | Expert | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 676
| |
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
| 
October 10th, 2008, 12:00 PM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| |
I am working away at generating my xml now. will post what I have when im done
| 
October 13th, 2008, 01:58 PM
| | Familiar Sight | | Join Date: Jun 2008
Posts: 135
| |
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. - <?php
-
-
header("Content-type: text/xml");
-
-
require "config.php";
-
-
$proj = 'j8888'; //$_REQUEST['proj'];
-
-
$q1 = mysql_query("SELECT * FROM company, project WHERE company.company_name = project.company_name AND proj_id = '$proj'") or die(mysql_error);
-
$r1 = mysql_fetch_assoc($q1);
-
$acc_no = $r1['acc_no'];
-
$company_name = $r1['company_name'];
-
$contact = $r1['contact'];
-
$add1 = $r1['add1'];
-
$add2 = $r1['add2'];
-
$town = $r1['town'];
-
$county = $r1['county'];
-
$pcode = $r1['pcode'];
-
$tel = $r1['tel'];
-
$proj_id = $r1['proj_id'];
-
$project_name = $r1['project_name'];
-
$form = $r1['form'];
-
$access = $r1['access'];
-
$cable_entry = $r1['cable_entry'];
-
$ip_rating = $r1['ip_rating'];
-
$fault_rating = $r1['fault_rating'];
-
$proj_manager = $r1['proj_manager'];
-
$deadline = $r1['deadline'];
-
-
$q2 = mysql_query("SELECT * FROM object, module WHERE object.module_name = module.module_name AND proj_id = '$proj'");
-
-
-
//start of xml document
-
$xml_output = "<?xml version=\"1.0\"?>\n";
-
$xml_output = "<?xml-stylesheet type='text/xsl' href='quote.xsl'?>\n";
-
$xml_output .= "<quote>\n";
-
$xml_output .= "\t<company>\n";
-
$xml_output .= "\t\t<comp_name>" . $company_name . "</comp_name>\n";
-
$xml_output .= "\t\t<contact>" . $contact . "</contact>\n";
-
$xml_output .= "\t<address>\n";
-
$xml_output .= "\t\t<add1>" . $add1 . "</add1>\n";
-
$xml_output .= "\t\t<add2>" . $add2 . "</add2>\n";
-
$xml_output .= "\t\t<town>" . $town . "</town>\n";
-
$xml_output .= "\t\t<county>" . $county . "</county>\n";
-
$xml_output .= "\t\t<pcode>" . $pcode . "</pcode>\n";
-
$xml_output .= "\t</address>\n";
-
$xml_output .= "\t\t<tel>" . $tel . "</tel>\n";
-
$xml_output .= "\t</company>\n";
-
$xml_output .= "\t<details>\n";
-
$xml_output .= "\t\t<proj_id>" . $proj_id . "</proj_id>\n";
-
$xml_output .= "\t\t<proj_name>" . $project_name . "</proj_name>\n";
-
$xml_output .= "\t\t<form>" . $form . "</form>\n";
-
$xml_output .= "\t\t<access>" . $access . "</access>\n";
-
$xml_output .= "\t\t<cable_entry>" . $cable_entry . "</cable_entry>\n";
-
$xml_output .= "\t\t<ip>" . $ip_rating . "</ip>\n";
-
$xml_output .= "\t\t<fault>" . $fault_rating . "</fault>\n";
-
$xml_output .= "\t\t<proj_manager>" . $proj_manager . "</proj_manager>\n";
-
$xml_output .= "\t\t<deadline>" . $deadline . "</deadline>\n";
-
$xml_output .= "\t</details>\n";
-
-
$xml_output .= "<objects>\n";
-
for($x = 0 ; $x < mysql_num_rows($q2) ; $x++){
-
$r2 = mysql_fetch_assoc($q2);
-
$obj_id = $r2['object_id'];
-
$xml_output .= "\t<obj id='$obj_id'>\n";
-
$xml_output .= "\t\t<object_name>" . $r2['object_name'] . "</object_name>\n";
-
$xml_output .= "\t\t<module_name>" . $r2['module_name'] . "</module_name>\n";
-
$xml_output .= "\t\t<mod_desc>" . $r2['mod_desc'] . "</mod_desc>\n";
-
$xml_output .= "\t\t<obj_desc>" . $r2['objDesc'] . "</obj_desc>\n";
-
$xml_output .= "\t\t<xpos>" . $r2['xpos'] . "</xpos>\n";
-
$xml_output .= "\t\t<ypos>" . $r2['ypos'] . "</ypos>\n";
-
$xml_output .= "\t\t<height>" . $r2['height'] . "</height>\n";
-
$xml_output .= "\t\t<width>" . $r2['width'] . "</width>\n";
-
$xml_output .= "\t\t<depth>" . $r2['depth'] . "</depth>\n";
-
$xml_output .= "\t</obj>\n";
-
}
-
$xml_output .= "</objects>";
-
-
$xml_output .= "\t</quote>\n";
-
-
echo $xml_output;
-
-
?>
-
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 - 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?
| 
October 13th, 2008, 06:12 PM
|  | Expert | | Join Date: Aug 2008 Location: Leipzig, Germany Age: 31
Posts: 676
| | 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
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | 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.
|