The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Other
> Development Articles
|
Page 2 -
XSL Transformation With PHP And Sablotron
Page 2 - Discuss XSL Transformation With PHP And Sablotron in the Development Articles forum on Dev Shed. XSL Transformation With PHP And Sablotron Development Articles forum discussing articles and tutorials located at http://www.devshed.com. See what our authors have created for your viewing pleasure.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 11th, 2002, 06:45 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
:(
and so? what shall we study??
|

January 14th, 2002, 10:48 AM
|
|
Guest
|
|
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
|

January 16th, 2002, 12:00 PM
|
|
Guest
|
|
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
|

January 16th, 2002, 12:02 PM
|
|
Guest
|
|
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.
|

January 27th, 2002, 03:59 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 03:59 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 03:59 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 04:00 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 04:00 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 04:01 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 04:01 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 27th, 2002, 04:02 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

January 28th, 2002, 05:50 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|

February 4th, 2002, 02:17 PM
|
|
Guest
|
|
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/
|

June 10th, 2002, 08:44 AM
|
|
Guest
|
|
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
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
|
|
|
|
|