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($x sltHandle, 'tmp_new.xml',' treeview.xsl');
/* Detect errors */
if (!$html) die('XSLT processing error: '.xslt_error($x sltHandle));
/* Destroy the XSLT processor */
xslt_free($xslt Handle);
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>Sergi o</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"><ht ml>
<head>
<title>XHTML Treeview</title>
<link rel="stylesheet " type="text/css" href="format.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</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="javascrip t: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.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</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="javascrip t: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:styleshe et 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.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</script>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!--Match the nodes with a tree parent-->
<xsl:template match="tree//node">
<div>
<xsl:attribut e name="class">no de</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<!--Match the nodes with a node parent-->
<xsl:template match="node//node">
<div>
<xsl:attribut e name="class">ch ild</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">nod e</xsl:variable>
<xsl:variable name="entry">ar row</xsl:variable>
<xsl:variable name="identific ation"><xsl:val ue-of
select="generat e-id(.)"/></xsl:variable>
<xsl:choose>
<xsl:when test="$value = $kind or $value = $entry">
<a>
<xsl:attribut e name="href">jav ascript:visuali ze_tree('<xsl:v alue-of
select="$identi fication"/>');</xsl:attribute>
<img>
<xsl:attribut e name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribut e name="height">1 6</xsl:attribute>
<xsl:attribut e name="width">16 </xsl:attribute>
<xsl:attribut e name="alt">icon </xsl:attribute>
<xsl:attribut e name="class">ic on-<xsl:value-of
select="."/></xsl:attribute>
<xsl:attribut e name="id"><xsl: value-of
select="$identi fication"/></xsl:attribute>
</img>
</a>
</xsl:when>
<xsl:otherwis e>
<img>
<xsl:attribut e name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribut e name="alt">icon </xsl:attribute>
<xsl:attribut e name="height">1 6</xsl:attribute>
<xsl:attribut e name="width">16 </xsl:attribute>
<xsl:attribut e name="class">ic on-<xsl:value-of
select="."/></xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="url">
<a>
<xsl:attribut e name="class">su bject</xsl:attribute>
<xsl:attribut e name="href">jav ascript:id_mess age('<xsl:value-of
select="."/>');</xsl:attribute>
<xsl:value-of select="../title"/>
</a><br/>
</xsl:template>
<xsl:template match="author">
<span>
<xsl:attribut e name="class">co mposer</xsl:attribute>
<xsl:value-of select="../author"/><xsl:text> </xsl:text><xsl:v alue-of
select="../date/day"/>/<xsl:value-of
select="../date/month"/>/<xsl:value-of select="../date/year"/><xsl:text>
</xsl:text><xsl:v alue-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>
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($x sltHandle, 'tmp_new.xml',' treeview.xsl');
/* Detect errors */
if (!$html) die('XSLT processing error: '.xslt_error($x sltHandle));
/* Destroy the XSLT processor */
xslt_free($xslt Handle);
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>Sergi o</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"><ht ml>
<head>
<title>XHTML Treeview</title>
<link rel="stylesheet " type="text/css" href="format.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</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="javascrip t: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.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</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="javascrip t: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:styleshe et 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.cs s"/>
<script src="functions. js" type="text/javascript">
if (document.image s);
</script>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!--Match the nodes with a tree parent-->
<xsl:template match="tree//node">
<div>
<xsl:attribut e name="class">no de</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<!--Match the nodes with a node parent-->
<xsl:template match="node//node">
<div>
<xsl:attribut e name="class">ch ild</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">nod e</xsl:variable>
<xsl:variable name="entry">ar row</xsl:variable>
<xsl:variable name="identific ation"><xsl:val ue-of
select="generat e-id(.)"/></xsl:variable>
<xsl:choose>
<xsl:when test="$value = $kind or $value = $entry">
<a>
<xsl:attribut e name="href">jav ascript:visuali ze_tree('<xsl:v alue-of
select="$identi fication"/>');</xsl:attribute>
<img>
<xsl:attribut e name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribut e name="height">1 6</xsl:attribute>
<xsl:attribut e name="width">16 </xsl:attribute>
<xsl:attribut e name="alt">icon </xsl:attribute>
<xsl:attribut e name="class">ic on-<xsl:value-of
select="."/></xsl:attribute>
<xsl:attribut e name="id"><xsl: value-of
select="$identi fication"/></xsl:attribute>
</img>
</a>
</xsl:when>
<xsl:otherwis e>
<img>
<xsl:attribut e name="src">./buttons/<xsl:value-of
select="."/>_close.png</xsl:attribute>
<xsl:attribut e name="alt">icon </xsl:attribute>
<xsl:attribut e name="height">1 6</xsl:attribute>
<xsl:attribut e name="width">16 </xsl:attribute>
<xsl:attribut e name="class">ic on-<xsl:value-of
select="."/></xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="url">
<a>
<xsl:attribut e name="class">su bject</xsl:attribute>
<xsl:attribut e name="href">jav ascript:id_mess age('<xsl:value-of
select="."/>');</xsl:attribute>
<xsl:value-of select="../title"/>
</a><br/>
</xsl:template>
<xsl:template match="author">
<span>
<xsl:attribut e name="class">co mposer</xsl:attribute>
<xsl:value-of select="../author"/><xsl:text> </xsl:text><xsl:v alue-of
select="../date/day"/>/<xsl:value-of
select="../date/month"/>/<xsl:value-of select="../date/year"/><xsl:text>
</xsl:text><xsl:v alue-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>