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>