473,387 Members | 1,510 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,387 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 2670

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...

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.