これはSOで何度も渡されてきた古い質問ですが、クエリ文字列が付加されたURLをXSLT 1.0を介して削除し、後でパラメーターとして使用できるかどうかを誰かが拡張できるかどうか疑問に思っていました。 XSLT変換の使用。
たとえば、http://www.mydomain.com/mypage.htm?param1 = a&param2=bのURLがあります
XSLTを介して、次のような結果を探しています。
<xsl:param name="param1">a</xsl:param>
と<xsl:param name="param2">b</xsl:param>
ここで、パラメーター名(param1、param2)とその値(a、b)の両方がクエリ文字列から抽出されており$param1
、$param2
後でif条件で使用できるようになっています。
たとえば<xsl:if test="$param1 = 'a'>
、真になりますが、使用<xsl:if test="$param1 = 'b'>
すると偽になります。
私はここで同様の質問を見ました:テンプレートを使用するXSLTでページURLパラメーターまたはページURLを取得しますstr-split-to-words
が、(おそらく私が間違った方法で実装したために)それを機能させることができませんでした練習は非常に有益です。
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common">
<xsl:import href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/strSplit-to-Words.xsl"/>
<xsl:output indent="yes" method="html"/>
<xsl:template match="/">
<xsl:variable name="vwordNodes">
<xsl:call-template name="str-split-to-words">
<xsl:with-param name="pStr" select="$pQString"/>
<xsl:with-param name="pDelimiters" select="'?&'"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>
<xsl:template match="word">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>