473,396 Members | 1,599 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,396 software developers and data experts.

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 2027
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:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns="http://www.w3.org/TR/xhtml1/transitional"
exclude-result-prefixes="#default">

<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="generate-id(.)"/></xsl:variable>
<tr>
<td><xsl:value-of select="."/> (generated id=<xsl:value-of
select="\$uniqueid"/>)</td>
</tr>
</xsl:template>

</xsl:stylesheet>
END_XSL;

$xml=new DOMDocument();
$xml->loadXML($xmlDoc);

$xsl=new XSLTProcessor();
$xsl->importStylesheet(DOMDocument::loadXML($xslDoc)) ;
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
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...
3
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. ...
9
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...
4
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...
1
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...
5
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...
5
by: Chameleon | last post by:
I totally messed up with this: We have -------------------------------------- generate(v.begin(), v.end(), my_func); -------------------------------------- and my_func: ----------- int...
6
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)...
2
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...
3
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);...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.