Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old January 11th, 2002, 06:45 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
:(

and so? what shall we study??

Reply With Quote
  #17  
Old January 14th, 2002, 10:48 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: :(

Study the new XSLT extention. I don't know if anyone has written any articles on it but php.net has updated the manual.

Cheers Sam

Reply With Quote
  #18  
Old January 16th, 2002, 12:00 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: pdf transformation

these are actually two files: one generates an xml document from a database, the other a PDF from the same. i had a session object in memory so i did it that way, but the functions are almost exactly the same, so you should be able to go from XML to PDF relatively easy.

XML
======
$doc = new_xmldoc("1.0");
$root = $doc->add_root("quote");
$root->set_attribute("id",$_SESSION["quote"]->qotid);
$cust = $root->new_child("customer","");
$cust->set_attribute("id",$_SESSION["quote"]->cusid);
$cfg = $root->new_child("config", "");

$result = mysql_query("select * from engines");
$chars_rev = preg_split('//', $_SESSION["compare"]->engine, -1, PREG_SPLIT_NO_EMPTY);
$chars = array_reverse($chars_rev);
$thread = bindec($_SESSION["compare"]->thread);
$thread == -1 ? $thread = "st1" : $thread = "mt".$thread;

while($row = mysql_fetch_array($result))
{

if (isset($chars[$row["engid"]]) && $chars[$row["engid"]] == 1)
{
$engine = $cfg->new_child("engine",$row["descr"]);
$engine->set_attribute("thread",$thread);
$engine->set_attribute("price",$row[$thread]);
}

}

var2xmlchild($_SESSION["compare"],$cfg,"subscription","subid","subscription");
var2xmlchild($_SESSION["compare"],$cfg,"support","supid","support");
$adapts = $cfg->new_child("adaptors", "");
array2xmlchild($_SESSION["compare"],$adapts,"adaptors","adpid","adaptor");
$maps = $cfg->new_child("maps", "");
array2xmlchild($_SESSION["compare"],$maps,"maps","mapid","map");



echo $doc->dumpmem();
?>

<?php
function array2xmlchild(&$compare,&$child,$dbtablename,$dbcolname,$childname)
{

$chars_rev = preg_split('//', $compare->$dbtablename, -1, PREG_SPLIT_NO_EMPTY);
$chars = array_reverse($chars_rev);
$result = mysql_query("select * from $dbtablename");
while($row = mysql_fetch_array($result))
{
if (isset($chars[$row[$dbcolname]]) && $chars[$row[$dbcolname]] == 1)
{

$childchild = $child->new_child("$childname", $row["descr"]);
$childchild->set_attribute("price",$row["price"]);
}
}
}
function var2xmlchild(&$compare,&$child,$dbtablename,$dbcolname,$childname)
{

$chars_rev = preg_split('//', $compare->$dbtablename, -1, PREG_SPLIT_NO_EMPTY);
$chars = array_reverse($chars_rev);
$result = mysql_query("select * from $dbtablename");
while($row = mysql_fetch_array($result))
{
if (isset($chars[$row[$dbcolname]]) && $chars[$row[$dbcolname]] == 1)
{

$childchild = $child->new_child("$childname", $row["descr"]);
//$childchild->set_attribute("price",$row["price"]);
}
}
}

PDF file
=========
$result = mysql_query("select * from engines");
$chars_rev = preg_split('//', $_SESSION["compare"]->engine, -1, PREG_SPLIT_NO_EMPTY);
$chars = array_reverse($chars_rev);
$thread = bindec($_SESSION["compare"]->thread);
$thread == -1 ? $thread = "st1" : $thread = "mt".$thread;

while($row = mysql_fetch_array($result))
{

if (isset($chars[$row["engid"]]) && $chars[$row["engid"]] == 1)
{
pdf_set_font($pdf, "Verdana", 12, "host");
pdf_set_value($pdf, "textrendering", 2);
pdf_show_xy($pdf, "Engine: $row[descr], $thread", 50, 700);
pdf_set_font($pdf, "Verdana", 12, "host");
pdf_set_value($pdf, "textrendering", 2);
pdf_show_xy($pdf, "$row[$thread]", 400, 700);

}

}
pdf_set_font($pdf, "Verdana", 12, "host");
pdf_set_value($pdf, "textrendering", 2);
pdf_show_xy($pdf, "Subscription", 50, 680);
var2pdf($_SESSION["compare"],"subscription","subid",$col,660);
pdf_show_xy($pdf, "Support", 50, 640);
var2pdf($_SESSION["compare"],"support","supid",$col,620);

pdf_show_xy($pdf, "Adaptors", 50, 600);
pdf_set_font($pdf, "Verdana", 10, "host");
pdf_set_value($pdf, "textrendering", 2);
pdf_show_xy($pdf, "Maps", 50, 320);
array2pdf($_SESSION["compare"],"adaptors","adpid",$col,580);
array2pdf($_SESSION["compare"],"maps","mapid",$col,300);
pdf_end_page($pdf);
pdf_close($pdf);

//$data = pdf_get_buffer($pdf);

//header("Content-type: application/pdf");
//header("Content-disposition: inline; filename=test.pdf");
//header("Content-length: " . strlen($data));

if i could get the XSLT support working like it is supposed to, i could show you a code snippet that uses XSL to do the same thing. wih a little luck, maybe soon.

HTH-
grant

Reply With Quote
  #19  
Old January 16th, 2002, 12:02 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Re: pdf transformation

BLEAH!

the formatting is UNREADABLE!

if you need this code email me privately at gbabb@datajunction.com.

:).
grant.

Reply With Quote
  #20  
Old January 27th, 2002, 03:59 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #21  
Old January 27th, 2002, 03:59 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #22  
Old January 27th, 2002, 03:59 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #23  
Old January 27th, 2002, 04:00 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #24  
Old January 27th, 2002, 04:00 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #25  
Old January 27th, 2002, 04:01 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #26  
Old January 27th, 2002, 04:01 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #27  
Old January 27th, 2002, 04:02 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #28  
Old January 28th, 2002, 05:50 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #29  
Old February 4th, 2002, 02:17 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
AxKit: Better way to do XSLT (without php)

There is an open-source package called AxKit that essentially is an apache mod that handles the XML/XSL transformations on the fly without the use of a scripting language. http://axkit.org/

Reply With Quote
  #30  
Old June 10th, 2002, 08:44 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
xslt_process changed

Nice article! but somewhat out of date ...
the function xslt_process changed and is now the main function you use for xslt transformations.

http://www.php.net/manual/en/function.xslt-process.php

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > XSL Transformation With PHP And Sablotron

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap