# Convert stripNS to addNS for profiling stylesheets
s|(<xslo?:variable[^>]*name="profiled-content").*?mode="profile".*?(</xslo?:variable>)|<xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"> <xslo:choose> <xslo:when test="namespace-uri(*[1]) != 'http://docbook.org/ns/docbook'"> <xsl:message>Adding DocBook namespace to version 4 DocBook document</xsl:message> <xsl:variable name="addns"> <xsl:apply-templates mode="addNS" select="/"/> </xsl:variable> <xsl:apply-templates select="exsl:node-set(\$addns)" mode="profile"/> </xslo:when> <xslo:otherwise> <xslo:apply-templates select="/" mode="profile"/> </xslo:otherwise> </xslo:choose> </xslo:variable>|sg;
- s|(\s*\n*)(\s*)(<xslo?:when)\s+test\s*=\s*"[^"]*?self::db:[^"]*?">.*?(</xslo?:when>)|$1$2$3 test="namespace-uri\(\*\[1\]\) != 'http://docbook.org/ns/docbook'">\n$2 <xsl:call-template name="log.message">\n$2 <xsl:with-param name="level">Note</xsl:with-param>\n$2 <xsl:with-param name="source" select="\$doc.title"/>\n$2 <xsl:with-param name="context-desc">\n$2 <xsl:text>namesp. add</xsl:text>\n$2 </xsl:with-param>\n$2 <xsl:with-param name="message">\n$2 <xsl:text>added namespace before processing</xsl:text>\n$2 </xsl:with-param>\n$2 </xsl:call-template>\n$2 <xsl:variable name="addns">\n$2 <xsl:apply-templates mode="addNS"/>\n$2 </xsl:variable>\n$2 <xsl:apply-templates select="exsl:node-set\(\$addns\)"/>\n$2$4|sg;
+ s|(\s*\n*)(\s*)(<xslo?:when)\s+test\s*=\s*"[^"]*?self::db:[^"]*?">.*?(</xslo?:when>)|$1$2$3 test="namespace-uri\(\*\[1\]\) != 'http://docbook.org/ns/docbook'">\n$2 <xsl:call-template name="log.message">\n$2 <xsl:with-param name="level">Note</xsl:with-param>\n$2 <xsl:with-param name="source"><xsl:call-template name="get.doc.title"/></xsl:param>\n$2 <xsl:with-param name="context-desc">\n$2 <xsl:text>namesp. add</xsl:text>\n$2 </xsl:with-param>\n$2 <xsl:with-param name="message">\n$2 <xsl:text>added namespace before processing</xsl:text>\n$2 </xsl:with-param>\n$2 </xsl:call-template>\n$2 <xsl:variable name="addns">\n$2 <xsl:apply-templates mode="addNS"/>\n$2 </xsl:variable>\n$2 <xsl:apply-templates select="exsl:node-set\(\$addns\)"/>\n$2$4|sg;
# Remove the "Hack!" message -->
s|<!-- Hack! If someone hands us a.*?-->||sg;