summaryrefslogtreecommitdiff
path: root/profiling
diff options
context:
space:
mode:
Diffstat (limited to 'profiling')
-rw-r--r--profiling/profile-mode.xsl245
-rw-r--r--profiling/profile.xsl56
-rw-r--r--profiling/strip-attributes.xsl27
-rw-r--r--profiling/xsl2profile.xsl159
4 files changed, 487 insertions, 0 deletions
diff --git a/profiling/profile-mode.xsl b/profiling/profile-mode.xsl
new file mode 100644
index 0000000..1c8660b
--- /dev/null
+++ b/profiling/profile-mode.xsl
@@ -0,0 +1,245 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:saxon="http://icl.com/saxon"
+ exclude-result-prefixes="saxon"
+ version="1.0">
+
+<!-- Should be base URI for imagedata and so on fixed? -->
+<xsl:param name="profile.baseuri.fixup" select="true()"/>
+
+<!-- Copy all non-element nodes -->
+<xsl:template match="@*|text()|comment()|processing-instruction()" mode="profile">
+ <xsl:copy/>
+</xsl:template>
+
+<!-- Profile elements based on input parameters -->
+<xsl:template match="*" mode="profile">
+
+ <xsl:variable name="arch.content">
+ <xsl:if test="@arch">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.arch"/>
+ <xsl:with-param name="b" select="@arch"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="arch.ok" select="not(@arch) or not($profile.arch) or
+ $arch.content != '' or @arch = ''"/>
+
+ <xsl:variable name="audience.content">
+ <xsl:if test="@audience">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.audience"/>
+ <xsl:with-param name="b" select="@audience"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="audience.ok"
+ select="not(@audience) or not($profile.audience) or
+ $audience.content != '' or @audience = ''"/>
+
+ <xsl:variable name="condition.content">
+ <xsl:if test="@condition">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.condition"/>
+ <xsl:with-param name="b" select="@condition"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="condition.ok" select="not(@condition) or not($profile.condition) or
+ $condition.content != '' or @condition = ''"/>
+
+ <xsl:variable name="conformance.content">
+ <xsl:if test="@conformance">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.conformance"/>
+ <xsl:with-param name="b" select="@conformance"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="conformance.ok" select="not(@conformance) or not($profile.conformance) or
+ $conformance.content != '' or @conformance = ''"/>
+
+ <xsl:variable name="lang.content">
+ <xsl:if test="@lang | @xml:lang">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.lang"/>
+ <xsl:with-param name="b" select="(@lang | @xml:lang)[1]"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="lang.ok" select="not(@lang | @xml:lang) or not($profile.lang) or
+ $lang.content != '' or @lang = '' or @xml:lang = ''"/>
+
+ <xsl:variable name="os.content">
+ <xsl:if test="@os">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.os"/>
+ <xsl:with-param name="b" select="@os"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="os.ok" select="not(@os) or not($profile.os) or
+ $os.content != '' or @os = ''"/>
+
+ <xsl:variable name="revision.content">
+ <xsl:if test="@revision">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.revision"/>
+ <xsl:with-param name="b" select="@revision"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="revision.ok" select="not(@revision) or not($profile.revision) or
+ $revision.content != '' or @revision = ''"/>
+
+ <xsl:variable name="revisionflag.content">
+ <xsl:if test="@revisionflag">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.revisionflag"/>
+ <xsl:with-param name="b" select="@revisionflag"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="revisionflag.ok" select="not(@revisionflag) or not($profile.revisionflag) or
+ $revisionflag.content != '' or @revisionflag = ''"/>
+
+ <xsl:variable name="role.content">
+ <xsl:if test="@role">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.role"/>
+ <xsl:with-param name="b" select="@role"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="role.ok" select="not(@role) or not($profile.role) or
+ $role.content != '' or @role = ''"/>
+
+ <xsl:variable name="security.content">
+ <xsl:if test="@security">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.security"/>
+ <xsl:with-param name="b" select="@security"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="security.ok" select="not(@security) or not($profile.security) or
+ $security.content != '' or @security = ''"/>
+
+ <xsl:variable name="status.content">
+ <xsl:if test="@status">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.status"/>
+ <xsl:with-param name="b" select="@status"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="status.ok" select="not(@status) or not($profile.status) or
+ $status.content != '' or @status = ''"/>
+
+ <xsl:variable name="userlevel.content">
+ <xsl:if test="@userlevel">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.userlevel"/>
+ <xsl:with-param name="b" select="@userlevel"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="userlevel.ok" select="not(@userlevel) or not($profile.userlevel) or
+ $userlevel.content != '' or @userlevel = ''"/>
+
+ <xsl:variable name="vendor.content">
+ <xsl:if test="@vendor">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.vendor"/>
+ <xsl:with-param name="b" select="@vendor"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="vendor.ok" select="not(@vendor) or not($profile.vendor) or
+ $vendor.content != '' or @vendor = ''"/>
+
+ <xsl:variable name="wordsize.content">
+ <xsl:if test="@wordsize">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.wordsize"/>
+ <xsl:with-param name="b" select="@wordsize"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="wordsize.ok"
+ select="not(@wordsize) or not($profile.wordsize) or
+ $wordsize.content != '' or @wordsize = ''"/>
+
+ <xsl:variable name="attribute.content">
+ <xsl:if test="@*[local-name()=$profile.attribute]">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$profile.value"/>
+ <xsl:with-param name="b" select="@*[local-name()=$profile.attribute]"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="attribute.ok"
+ select="not(@*[local-name()=$profile.attribute]) or
+ not($profile.value) or $attribute.content != '' or
+ @*[local-name()=$profile.attribute] = '' or
+ not($profile.attribute)"/>
+
+ <xsl:if test="$arch.ok and
+ $audience.ok and
+ $condition.ok and
+ $conformance.ok and
+ $lang.ok and
+ $os.ok and
+ $revision.ok and
+ $revisionflag.ok and
+ $role.ok and
+ $security.ok and
+ $status.ok and
+ $userlevel.ok and
+ $vendor.ok and
+ $wordsize.ok and
+ $attribute.ok">
+ <xsl:copy>
+ <xsl:apply-templates mode="profile" select="@*"/>
+
+ <!-- Entity references must be replaced with filereferences for temporary tree -->
+ <xsl:if test="@entityref and $profile.baseuri.fixup">
+ <xsl:attribute name="fileref">
+ <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <!-- xml:base is eventually added to the root element -->
+ <xsl:if test="not(../..) and $profile.baseuri.fixup">
+ <xsl:call-template name="add-xml-base"/>
+ </xsl:if>
+
+ <xsl:apply-templates select="node()" mode="profile"/>
+ </xsl:copy>
+ </xsl:if>
+</xsl:template>
+
+<!-- Returns non-empty string if list in $b contains one ore more values from list $a -->
+<xsl:template name="cross.compare">
+ <xsl:param name="a"/>
+ <xsl:param name="b"/>
+ <xsl:param name="sep" select="$profile.separator"/>
+ <xsl:variable name="head" select="substring-before(concat($a, $sep), $sep)"/>
+ <xsl:variable name="tail" select="substring-after($a, $sep)"/>
+<!-- <xsl:message> -->
+<!-- a="<xsl:value-of select="$a"/>" -->
+<!-- a="<xsl:value-of select="normalize-space($a)"/>" -->
+<!-- head="<xsl:value-of select="$head"/>" -->
+<!-- tail="<xsl:value-of select="$tail"/>" -->
+<!-- </xsl:message> -->
+ <xsl:if test="contains(concat($sep, $b, $sep), concat($sep, $head, $sep)) or normalize-space($a) = '' ">1</xsl:if>
+ <xsl:if test="$tail">
+ <xsl:call-template name="cross.compare">
+ <xsl:with-param name="a" select="$tail"/>
+ <xsl:with-param name="b" select="$b"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/profiling/profile.xsl b/profiling/profile.xsl
new file mode 100644
index 0000000..b188fbb
--- /dev/null
+++ b/profiling/profile.xsl
@@ -0,0 +1,56 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<!-- Include common profiling stylesheet -->
+<xsl:import href="profile-mode.xsl"/>
+
+<!-- This file must be included, because profile-mode is using templates from it -->
+<xsl:import href="../common/stripns.xsl"/>
+
+<!-- In the two pass processing there is no need for base URI fixup -->
+<xsl:param name="profile.baseuri.fixup" select="false()"/>
+
+<!-- If you need to validate profiled content against DTD,
+ create customization that will import this stylesheet and
+ will use xsl:output (see example bellow) to output reference
+ to the desired DTD version. -->
+<!-- Generate DocBook instance with correct DOCTYPE -->
+<!--
+<xsl:output method="xml"
+ doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
+ doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
+-->
+
+<!-- Profiling parameters -->
+<xsl:param name="profile.arch" select="''"/>
+<xsl:param name="profile.audience" select="''"/>
+<xsl:param name="profile.condition" select="''"/>
+<xsl:param name="profile.conformance" select="''"/>
+<xsl:param name="profile.lang" select="''"/>
+<xsl:param name="profile.os" select="''"/>
+<xsl:param name="profile.revision" select="''"/>
+<xsl:param name="profile.revisionflag" select="''"/>
+<xsl:param name="profile.role" select="''"/>
+<xsl:param name="profile.security" select="''"/>
+<xsl:param name="profile.status" select="''"/>
+<xsl:param name="profile.userlevel" select="''"/>
+<xsl:param name="profile.vendor" select="''"/>
+<xsl:param name="profile.wordsize" select="''"/>
+<xsl:param name="profile.attribute" select="''"/>
+<xsl:param name="profile.value" select="''"/>
+<xsl:param name="profile.separator" select="';'"/>
+
+<xsl:param name="exsl.node.set.available">
+ <xsl:choose>
+ <xsl:when xmlns:exsl="http://exslt.org/common" exsl:foo="" test="function-available('exsl:node-set') or contains(system-property('xsl:vendor'), 'Apache Software Foundation')">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+</xsl:param>
+
+<!-- Call common profiling mode -->
+<xsl:template match="/">
+ <xsl:apply-templates select="." mode="profile"/>
+</xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/profiling/strip-attributes.xsl b/profiling/strip-attributes.xsl
new file mode 100644
index 0000000..d6f55fb
--- /dev/null
+++ b/profiling/strip-attributes.xsl
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output method="xml"/>
+
+<xsl:param name="attributes" select="''"/>
+
+<xsl:variable name="strip-attributes"
+ select="concat(' ', normalize-space($attributes), ' ')"/>
+
+<xsl:template match="@*|text()|comment()|processing-instruction()">
+ <xsl:copy/>
+</xsl:template>
+
+<xsl:template match="*">
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:if test="not(contains($strip-attributes, concat(' ',name(.),' ')))">
+ <xsl:copy-of select="."/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:apply-templates select="node()"/>
+ </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/profiling/xsl2profile.xsl b/profiling/xsl2profile.xsl
new file mode 100644
index 0000000..b6648aa
--- /dev/null
+++ b/profiling/xsl2profile.xsl
@@ -0,0 +1,159 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xslo="http://www.w3.org/1999/XSL/TransformAlias"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ exclude-result-prefixes="fo"
+ version="1.0">
+
+<xsl:include href="../lib/lib.xsl"/>
+
+<xsl:output method="xml" encoding="US-ASCII"/>
+
+<xsl:namespace-alias stylesheet-prefix="xslo" result-prefix="xsl"/>
+
+<xsl:preserve-space elements="*"/>
+
+<xsl:template match="/">
+ <xsl:comment>This file was created automatically by xsl2profile</xsl:comment>
+ <xsl:comment>from the DocBook XSL stylesheets.</xsl:comment>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- Make sure we override some templates and parameters appropriately for XHTML -->
+<xsl:template match="xsl:stylesheet">
+ <xsl:copy>
+ <xsl:attribute name="exslt:dummy" xmlns:exslt="http://exslt.org/common">dummy</xsl:attribute>
+ <xsl:attribute name="ng:dummy" xmlns:ng="http://docbook.org/docbook-ng">dummy</xsl:attribute>
+ <xsl:attribute name="db:dummy" xmlns:db="http://docbook.org/ns/docbook">dummy</xsl:attribute>
+ <xsl:if test="not(@extension-element-prefixes)">
+ <xsl:attribute name="extension-element-prefixes">exslt</xsl:attribute>
+ </xsl:if>
+ <xsl:if test="not(@exclude-result-prefixes)">
+ <xsl:attribute name="exclude-result-prefixes">exslt</xsl:attribute>
+ </xsl:if>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'extension-element-prefixes' or
+ local-name(.) = 'exclude-result-prefixes'">
+ <xsl:attribute name="{local-name(.)}"><xsl:value-of select="concat(., ' exslt')"/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="comment()|processing-instruction()|text()">
+ <xsl:copy/>
+</xsl:template>
+
+<xsl:template match="xsl:template[@match='/']">
+ <xslo:include href="../profiling/profile-mode.xsl"/>
+ <xslo:variable name="profiled-content">
+ <xslo:choose>
+ <xslo:when test="*/self::ng:* or */self::db:*">
+ <xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message>
+ <xslo:variable name="stripped-content">
+ <xslo:apply-templates select="/" mode="stripNS"/>
+ </xslo:variable>
+ <xslo:message>Note: namesp. cut : processing stripped document</xslo:message>
+ <xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/>
+ </xslo:when>
+ <xslo:otherwise>
+ <xslo:apply-templates select="/" mode="profile"/>
+ </xslo:otherwise>
+ </xslo:choose>
+ </xslo:variable>
+ <xslo:variable name="profiled-nodes" select="exslt:node-set($profiled-content)"/>
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="xsl:template[@name='hhc-main' or @name='hhp-main' or @name='hhk' or @name='hh-map' or @name='hh-alias' or @name='etoc'] | xsl:variable[@name='raw.help.title']">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*[starts-with(@select, '/')]" mode="correct">
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'select' and string(.) = '/'">
+ <xsl:attribute name="{local-name(.)}">$profiled-nodes</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="local-name(.) = 'select' and starts-with(., '/')">
+ <xsl:attribute name="{local-name(.)}">$profiled-nodes<xsl:value-of select="."/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match='*[contains(@*, "key(&apos;id&apos;,$rootid)")]' mode="correct" priority="2">
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test='contains(., "key(&apos;id&apos;,$rootid)")'>
+ <xsl:attribute name="{local-name(.)}">
+ <xsl:call-template name="string.subst">
+ <xsl:with-param name="string" select="."/>
+ <xsl:with-param name="target">key('id',$rootid)</xsl:with-param>
+ <xsl:with-param name="replacement">$profiled-nodes//*[@id=$rootid]</xsl:with-param>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<!-- FO stylesheet has apply-templates without select, we must detect it by context -->
+<xsl:template match="fo:root//xsl:apply-templates" mode="correct">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:attribute name="select">$profiled-nodes/node()</xsl:attribute>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<!-- DB5 namespace stripping is already done -->
+<xsl:template match="xsl:when[contains(@test, 'self::db')]" mode="correct">
+ <xsl:copy>
+ <xsl:attribute name="test">false()</xsl:attribute>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*" mode="correct">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="correct"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="comment()|processing-instruction()|text()" mode="correct">
+ <xsl:copy/>
+</xsl:template>
+
+</xsl:stylesheet>