473,605 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($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>

Jul 17 '05 #1
0 2695

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

Similar topics

6
2736
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 straight XML file http://www.discovertravelandtours.com/test/templates/test.xml?Location=Germany To another XML file http://www.discovertravelandtours.com/test/templates/test2.xml?Location=Germany
6
2903
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 this, and came across a problem that I haven't been able to solve elegantly. The problem is to find "linker" vertexes that a pair of verteces from a pre-defined set. For example, if the graph verteces represent cities and edges represent flights...
12
3213
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 (xml->html) doen't happen! I have XSLT files for this, they work, I mean when I put the output of the app as an XML file on some server, and make it use the XSLT files to transform into HTML, it works, I get a HTML page.
1
3100
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 Transformer convert that via XSLT to valid XSL-FO. So I define a SAXReader which fires the SAX Events for the Java Object. This works fine and the Transformation to PDF is ok. However, I have one object which contains an XHTML String and the tags
4
5234
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 = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) {
5
4407
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) and PDF (via XSL:FO). The only tool we have seen is Altova's StyleVision, which is very unfriendly (and uses a proprietary representation, SPS, from which it generates the various XSLs). We have considered instead using InfoPath, which is WYSIWYG,...
6
5685
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 doc.Load(@"..\..\..\books.xml");
4
2139
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 = "yes" /> <xsl:attribute-set name = "set1" > <xsl:attribute name = "a" >1</xsl:attribute> <xsl:attribute name = "b" >2</xsl:attribute> </xsl:attribute-set> <xsl:attribute-set name = "set2" >
2
3094
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 my IE code - <html> <head> <title>CEL Learning</title>
0
8415
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8286
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6742
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3912
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1270
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.