diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 06:53:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 06:53:20 +0000 |
commit | e5a812082ae033afb1eed82c0f2df3d0f6bdc93f (patch) | |
tree | a6716c9275b4b413f6c9194798b34b91affb3cc7 /xml/context-of.xsl | |
parent | Initial commit. (diff) | |
download | pacemaker-e5a812082ae033afb1eed82c0f2df3d0f6bdc93f.tar.xz pacemaker-e5a812082ae033afb1eed82c0f2df3d0f6bdc93f.zip |
Adding upstream version 2.1.6.upstream/2.1.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xml/context-of.xsl')
-rw-r--r-- | xml/context-of.xsl | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/xml/context-of.xsl b/xml/context-of.xsl new file mode 100644 index 0000000..96b8c17 --- /dev/null +++ b/xml/context-of.xsl @@ -0,0 +1,83 @@ +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="text"/> +<xsl:param name="goal-name" select="'id'"/> +<xsl:param name="goal-value" select="'GOAL'"/> +<xsl:param name="style" select="'rng'"/> +<xsl:param name="skip" select="0"/> + +<xsl:template match="/"> + <xsl:choose> + <xsl:when test="not(.//@*[ + name() = $goal-name + and + . = $goal-value + ])"> + <xsl:message terminate="yes">NOTFOUND</xsl:message> + </xsl:when> + <xsl:when test="$style = 'xml'"> + <xsl:call-template name="xpath-xml-elem"> + <xsl:with-param name="terminal-elem" + select=".//@*[ + name() = $goal-name + and + . = $goal-value + ]/.."/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$style = 'rng'"> + <xsl:call-template name="xpath-rng-elem"> + <xsl:with-param name="terminal-elem" + select=".//@*[ + name() = $goal-name + and + . = $goal-value + ]/.."/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes">BADSTYLE</xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="xpath-xml-elem"> + <xsl:param name="terminal-elem"/> + <xsl:variable name="TotalCount" + select="count($terminal-elem/ancestor-or-self::*)"/> + <xsl:for-each select="$terminal-elem/ancestor-or-self::*"> + <xsl:if test="$TotalCount - position() >= $skip"> + <xsl:value-of select="concat('/', name())"/> + </xsl:if> + </xsl:for-each> + <xsl:value-of select="'
'"/> +</xsl:template> + +<xsl:template name="xpath-rng-elem"> + <xsl:param name="terminal-elem"/> + <xsl:variable name="TotalCount" + select="count($terminal-elem/ancestor-or-self::*)"/> + <xsl:for-each select="$terminal-elem/ancestor-or-self::*"> + <xsl:if test="$TotalCount - position() >= $skip"> + <xsl:choose> + <xsl:when test="name() = 'attribute'"> + <xsl:value-of select="concat('/@', @name)"/> + </xsl:when> + <xsl:when test="name() = 'define'"> + <xsl:value-of select="concat('/<', @name, '>')"/> + </xsl:when> + <xsl:when test="name() = 'element'"> + <xsl:value-of select="concat('/', @name)"/> + </xsl:when> + <xsl:when test="name() = 'grammar'"> + <xsl:if test="$TotalCount < 3"> + <xsl:value-of select="concat('<', name(), '>')"/> + </xsl:if> + </xsl:when> + </xsl:choose> + </xsl:if> + </xsl:for-each> + <xsl:value-of select="'
'"/> +</xsl:template> + +</xsl:stylesheet> |