473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating customised quote with terms and conditions using XSLT

178 100+
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
Oct 9 '08 #1
11 1653
jkmyoung
2,057 Expert 2GB
? produce a quote?

Not sure what you're trying to do.
Oct 9 '08 #2
Dormilich
8,658 Expert Mod 8TB
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.
Oct 9 '08 #3
cleary1981
178 100+
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?
Oct 10 '08 #4
Dormilich
8,658 Expert Mod 8TB
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
Oct 10 '08 #5
cleary1981
178 100+
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.
Oct 10 '08 #6
Dormilich
8,658 Expert Mod 8TB
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
Oct 10 '08 #7
cleary1981
178 100+
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
Oct 10 '08 #8
Dormilich
8,658 Expert Mod 8TB
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
Oct 10 '08 #9
cleary1981
178 100+
I am working away at generating my xml now. will post what I have when im done
Oct 10 '08 #10
cleary1981
178 100+
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?
Oct 13 '08 #11
Dormilich
8,658 Expert Mod 8TB
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
Oct 13 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: TP | last post by:
Hi, I have reached a situation where I have to create small pieces of xml (around 8k characters) within my java app. Right now I am using stringbuffer to create the xml which does not go against...
2
by: Ginu | last post by:
Hi, the task is to identify semantically identical elements where some additional attributes do not match. The XSL-transformation should find a node NAME which @id attribute matches to another...
1
by: dan_williams | last post by:
I am attempting to create a ASP.NET report whereby users can specify which columns they wish to be able to view depending on the options they select from a CheckBoxList. I have 4 tables,...
4
by: simonmarkjones | last post by:
Hi all, I have 2 ComboBoxes The first has 3 choices Planning Building Control Planning & Building Control
3
by: sham | last post by:
Hi to all, I am using XALAN processor and xslt 2.0 and I have managed to take an XML file and split it into multiple documents. This is done via the Oxygen editor. I now need to write a C#...
6
by: Rob | last post by:
Hi all, I would like to have a textarea control on my web page that is complete with terms and conditions, in addition, I would like a radio button beneath this to indicate the acceptance of...
13
by: camphor | last post by:
hi, would anyone know if there is a php script to Accept the Terms & Conditions. The customer must check the Terms & Conditions box before he/she is able to go to the next page. Not really sure...
9
by: VK | last post by:
<OT>I am finishing TransModal 0.1 so planning to move it from alpha to beta stage.<OT> Besides that I am planning to write an introductory to inheritance schema currently used in Javascript...
13
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I am not accustomed to creating xml files programmatically. The big picture is this: This will be in VB/VS 2005/ winforms. I have a DTD, a sample XML, and an outside data source I will use to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.