render / rpms / libvirt

Forked from rpms/libvirt 4 months ago
Clone
7b17cc
From 54814c87f3706cc8eb894634ebef0f9cf7dabae6 Mon Sep 17 00:00:00 2001
7b17cc
From: Martin Kletzander <mkletzan@redhat.com>
7b17cc
Date: Mon, 21 Feb 2022 09:26:13 +0100
7b17cc
Subject: [PATCH] docs: Fix template matching in page.xsl
7b17cc
7b17cc
Our last default template had a match of "node()" which incidentally matched
7b17cc
everything, including text nodes.  Since this has the same priority according to
7b17cc
the XSLT spec, section 5.5:
7b17cc
7b17cc
  https://www.w3.org/TR/1999/REC-xslt-19991116#conflict
7b17cc
7b17cc
this is an error.  Also according to the same spec section, the XSLT processor
7b17cc
may signal the error or pick the last rule.
7b17cc
7b17cc
This was uncovered with libxslt 1.1.35 which contains the following commit:
7b17cc
7b17cc
  https://gitlab.gnome.org/GNOME/libxslt/-/commit/b0074eeca3c6b21b4da14fdf712b853900c51635
7b17cc
7b17cc
which makes the build fail with:
7b17cc
7b17cc
  runtime error: file ../docs/page.xsl line 223 element element
7b17cc
  xsl:element: The effective name '' is not a valid QName.
7b17cc
7b17cc
because our last rule also matches text nodes and we are trying to extract the
7b17cc
node name out of them.
7b17cc
7b17cc
To fix this we change the match to "*" which only matches elements and not all
7b17cc
the nodes, and to avoid any possible errors with different XSLT processors we
7b17cc
also bump the priority of the match="text()" rule a little higher, just in case
7b17cc
someone needs to use an XSLT processor that chooses signalling the error instead
7b17cc
of the optional recovery.
7b17cc
7b17cc
https://bugs.gentoo.org/833586
7b17cc
7b17cc
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7b17cc
---
7b17cc
 docs/page.xsl | 4 ++--
7b17cc
 1 file changed, 2 insertions(+), 2 deletions(-)
7b17cc
7b17cc
diff --git a/docs/page.xsl b/docs/page.xsl
7b17cc
index fd67918d3b..72a6fa0842 100644
7b17cc
--- a/docs/page.xsl
7b17cc
+++ b/docs/page.xsl
7b17cc
@@ -215,11 +215,11 @@
7b17cc
     </xsl:element>
7b17cc
   </xsl:template>
7b17cc
 
7b17cc
-  <xsl:template match="text()" mode="copy">
7b17cc
+  <xsl:template match="text()" mode="copy" priority="0">
7b17cc
     <xsl:value-of select="."/>
7b17cc
   </xsl:template>
7b17cc
 
7b17cc
-  <xsl:template match="node()" mode="copy">
7b17cc
+  <xsl:template match="*" mode="copy">
7b17cc
     <xsl:element name="{name()}">
7b17cc
       <xsl:copy-of select="./@*"/>
7b17cc
       <xsl:apply-templates mode="copy" />
7b17cc
-- 
7b17cc
2.35.1
7b17cc