Skip to content

Commit

Permalink
Document xsl:keys handling better in ext/xsl
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdos committed Feb 24, 2024
1 parent ec778c0 commit ad29afd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/xsl/xsltprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ PHP_METHOD(XSLTProcessor, importStylesheet)
clone_docu = zend_is_true(cloneDocu);
zend_string_release_ex(member, 0);
if (clone_docu == 0) {
/* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */
/* Check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation.
* xsl:key elements may only occur at the top level. Furthermore, all elements at the top level must be in a
* namespace (if not, then the stylesheet is not well-formed and this function will have returned false earlier). */
nodep = xmlDocGetRootElement(sheetp->doc);
if (nodep && (nodep = nodep->children)) {
while (nodep) {
ZEND_ASSERT(nodep->ns != NULL);
if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
intern->hasKeys = true;
break;
Expand Down

0 comments on commit ad29afd

Please sign in to comment.