473,587 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL generate-id problems

I used the xslt functions with php4... now i've moved to php5, and, as
the xslt functions are no longer bundled, i'm moving the code to the
XSLTProcessor class.

I've found a problem with the generate-id() XSL function... with the old
functions, generate-id() gave me the same id for the same section of my
XML document every time i processed it. Now, with the XSLTProcessor
class, every time it gives me a new id.

This is not how it's supposed to work, as it is impossible to make
references to sections of the document.

Am i doing something wrong or the new classes are a bit buggy?

thanks.
alex.
Jul 17 '05 #1
1 2035
En/na alex bazan ha escrit:
I used the xslt functions with php4... now i've moved to php5, and, as
the xslt functions are no longer bundled, i'm moving the code to the
XSLTProcessor class.


I've done a bit of code for anyone who wants to test this one. I also
will be opening a bug report in php.net...

Execute the script and refresh. The ids are change each time the page is
refreshed, when they should stay the same for each node.

<?php

$xmlDoc=<<<END_ XML
<?xml version='1.0'?>
<mydoc>
<name>Alex</name>
<name>Gilad</name>
<name>Abdul</name>
<name>Diego</name>
</mydoc>
END_XML;

$xslDoc=<<<END_ XSL
<?xml version='1.0'?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns="http://www.w3.org/TR/xhtml1/transitional"
exclude-result-prefixes="#defa ult">

<xsl:output method="html" encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>

<xsl:template match="mydoc">
<table border="0">
<xsl:apply-templates select="*"/>
</table>
</xsl:template>

<xsl:template match="name">
<xsl:variable name="uniqueid" ><xsl:value-of
select="generat e-id(.)"/></xsl:variable>
<tr>
<td><xsl:valu e-of select="."/> (generated id=<xsl:value-of
select="\$uniqu eid"/>)</td>
</tr>
</xsl:template>

</xsl:stylesheet>
END_XSL;

$xml=new DOMDocument();
$xml->loadXML($xmlDo c);

$xsl=new XSLTProcessor() ;
$xsl->importStyleshe et(DOMDocument: :loadXML($xslDo c));
echo $xsl->transformToDoc ($xml)->saveXML()

?>
Jul 17 '05 #2

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

Similar topics

0
2407
by: Almoni | last post by:
Hi, I have a few .xsd files that include each other in the following way: <!-- lets call the main schema file AA.xsd and it includes BB.xsd inside it --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
3
2171
by: Garry Dawkins | last post by:
Hey Frank, I'm a novice with this taking over someone elses application. I'm attempting to add a dataset to a page. I have the query to populate the page and I have the walkthrough instructions. Visual Studios does not want to cooperate. This is what I'm following: To generate a dataset From the Data menu, choose Generate DataSet. Tip ...
9
1811
by: Henk Verhoeven | last post by:
We are not alone! "Where other MDA tools are generating programmingcode, Codeless chooses not to generate code at all". OK, phpPeanuts is not an MDA tool (it has no fancy modeling GUI). But it does generate application behavior straight from the metamodel, without generating code. And we did not need "a decade of know-how in maintaining...
4
2071
by: Stephen | last post by:
I need to generate input XML for another application by serialising classes defined in an XSD document. The code below will generate the XML I require but I need to generate this in memory rather than creating a file. I assume I should be using System.IO.MemoryStream but can't get this to work. ' XML will be serialized to file.xml, in...
1
2318
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for Page." After a lot of googling, all i can find that this applies to is when trying to use enum-type datatypes as bit-vector flags, or when use...
5
3692
by: pete | last post by:
Help, I can not find this data wizard in my toolbox under data. To generate a dataset 1.. From the Data menu, choose Generate DataSet. Tip If you do not see the Data menu, click in the form; the form must have focus for the menu to appear. The Generate Dataset dialog box is displayed.
5
1842
by: Chameleon | last post by:
I totally messed up with this: We have -------------------------------------- generate(v.begin(), v.end(), my_func); -------------------------------------- and my_func: ----------- int my_func();
6
3067
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional) file path to store image resource object contents * @see actual_path */
2
7377
by: bthubbard | last post by:
This may not be the best group in which to post this. If there is a better location please direct me there. I have been experimenting with Sandcastle to generate CHM help file documentation for some of our projects. I can configure a project(s) to generate the required XML Documentation file by editing the project properties via VS or I...
3
2400
by: Bill Woessner | last post by:
I'm trying to replace a loop with a call to std::generate and I'm about at wits end. Here's the working code: std::vector<double>::iterator it; std::vector<doubledata(100); RandomGenerator<doubleg; for(it = data.begin(); it != data.end(); ++it) { *it = g.GetGaussian();
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8220
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...
0
6626
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...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
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...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
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...

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.