472,378 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

xslt transformation with php

Hi,
I use the xslt functions provided by php. I am running in my computer
the package xampp(www.apachefriends.org) which includes php/apache/mysql
.. In this package the php includes the sablotron extension responsible
for the xslt functions. The problem i have is that the obtained
transformation is not the waited one. I try to proccess the same XML
file with XSL file with a program called XMLspy and i obtained the
desire and waited results.

The transformation is made in the next way:

/* Create an XSLT processor */
$xsltHandle = xslt_create();
/* Perform the transformation */
$html = xslt_process($xsltHandle, 'tmp_new.xml','treeview.xsl');
/* Detect errors */
if (!$html) die('XSLT processing error: '.xslt_error($xsltHandle));
/* Destroy the XSLT processor */
xslt_free($xsltHandle);

This is the XML file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE tree SYSTEM "node.dtd">
<?xml-stylesheet type="text/xsl" href="treeview.xsl"?>
<tree>
<node>
<type>text</type>
<description>
<title>Problems</title>
<url>./text/p2655.html</url>
<author>Sergio</author>
<date>
<day>7 </day>
<month>2</month>
<year>2004</year>
</date>
<time>
<hours>14</hours>
<minutes>0:</minutes>
</time>
</description>
</node>
</tree>

This is the XHTML file after proccesing with XMLspy(logic transformation):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
<head>
<title>XHTML Treeview</title>
<link rel="stylesheet" type="text/css" href="format.css"/>
<script src="functions.js" type="text/javascript">
if (document.images);
</script>
</head>
<body>
<div class="node">
<img src="./buttons/text_close.png" alt="icon" height="16" width="16"
class="icon-text"/>
<a class="subject"
href="javascript:id_message('./text/p2655.html');">Problems</a>
<br/>
<span class="composer">Sergio 7 /2/2004 14:0:</span>
</div>
</body>
</html>

This is the XHTML file obtained after a php transformation:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>XHTML Treeview</title>
<link rel="stylesheet" type="text/css" href="format.css"/>
<script src="functions.js" type="text/javascript">
if (document.images);
</script>
</head>
<body>
<div class="node">
<img src="./buttons/text_close.png" alt="icon" height="16" width="16"
class="icon-text"/>
<a class="subject"
href="javascript:id_message('./text/p2655.html');">Problems</a>
<br/>
<span class="composer">Sergio 7 /2/2004 14:0:</span>




</div>
</body>
</html>

Does somebody knows why it is like that? How can i solve the problem?
Is there a way to control the indention, and whitespace with php in
order to provide a regular structure(later i work with this file and i
need a legible and regular code) once you have a caos file like i have
after the transformation.
Here i include the xsl file. I use the indent="yes in the output
declaration but it does not work with php.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
method="xml" encoding="UTF-8" omit-xml-declaration = "yes" indent =
"yes" />
<xsl:template match="/">
<html>
<head>
<title>XHTML Treeview</title>
<link rel="stylesheet" type="text/css" href="format.css"/>
<script src="functions.js" type="text/javascript">
if (document.images);
</script>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!--Match the nodes with a tree parent-->
<xsl:template match="tree//node">
<div>
<xsl:attribute name="class">node</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<!--Match the nodes with a node parent-->
<xsl:template match="node//node">
<div>
<xsl:attribute name="class">child</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<!--In the type template the different result depends of the type. If it
is text the transformtion will be an image if it is node the
transformation will be a javascript linked image.-->
<xsl:template match="type">
<xsl:variable name="value" select="." />
<xsl:variable name="kind">node</xsl:variable>
<xsl:variable name="entry">arrow</xsl:variable>
<xsl:variable name="identification"><xsl:value-of
select="generate-id(.)"/></xsl:variable>
<xsl:choose>
<xsl:when test="$value = $kind or $value = $entry">
<a>
<xsl:attribute name="href">javascript:visualize_tree('<xsl:value-of
select="$identification"/>');</xsl:attribute>
<img>
<xsl:attribute name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribute name="height">16</xsl:attribute>
<xsl:attribute name="width">16</xsl:attribute>
<xsl:attribute name="alt">icon</xsl:attribute>
<xsl:attribute name="class">icon-<xsl:value-of
select="."/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of
select="$identification"/></xsl:attribute>
</img>
</a>
</xsl:when>
<xsl:otherwise>
<img>
<xsl:attribute name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribute name="alt">icon</xsl:attribute>
<xsl:attribute name="height">16</xsl:attribute>
<xsl:attribute name="width">16</xsl:attribute>
<xsl:attribute name="class">icon-<xsl:value-of
select="."/></xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="url">
<a>
<xsl:attribute name="class">subject</xsl:attribute>
<xsl:attribute name="href">javascript:id_message('<xsl:value-of
select="."/>');</xsl:attribute>
<xsl:value-of select="../title"/>
</a><br/>
</xsl:template>
<xsl:template match="author">
<span>
<xsl:attribute name="class">composer</xsl:attribute>
<xsl:value-of select="../author"/><xsl:text> </xsl:text><xsl:value-of
select="../date/day"/>/<xsl:value-of
select="../date/month"/>/<xsl:value-of select="../date/year"/><xsl:text>
</xsl:text><xsl:value-of select="../time/hours"/>:<xsl:value-of
select="../time/minutes"/>
</span>
</xsl:template>
<xsl:template match="title">
</xsl:template>
<xsl:template match="day">
</xsl:template>
<xsl:template match="month">
</xsl:template>
<xsl:template match="year">
</xsl:template>
<xsl:template match="hours">
</xsl:template>
<xsl:template match="minutes">
</xsl:template>
</xsl:stylesheet>

Jul 17 '05 #1
0 2538

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
5
by: shauldar | last post by:
Is there a way (tool, hack...) to create an XSL:FO from an XSLT + XML files? My motivation is that we want to use a tool to design reports, and from that "design" generate both HTML (via XSLT)...
6
by: JJBean | last post by:
Hi Oleg and All, Is this correct? Can I do this? <code> XmlDocument doc=new XmlDocument(); XPathNavigator nav = doc.CreateNavigator(); //Load the xml file. Change path if needed...
4
by: simon.a.hulbert | last post by:
Hi, I'm trying to view the following xslt transformation using firefox <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output method = "xml" indent =...
2
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.