Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:05:33+00:00 2026-06-04T01:05:33+00:00

I know this is an old question that has been passed around SO several

  • 0

I know this is an old question that has been passed around SO several times but I was wondering whether anyone can expand on whether a URL that has a querystring attached to it can be stripped out via XSLT 1.0 and can be used as a parameter for later use of the XSLT transformation.

For example, I have a URL of http://www.mydomain.com/mypage.htm?param1=a&param2=b

via XSLT, I am looking for a result of something along the lines of:

<xsl:param name="param1">a</xsl:param> and <xsl:param name="param2">b</xsl:param>

where both parameter name (param1, param2) and it’s value (a, b) has been extracted from the quesrystring to allow me to use $param1 and $param2 later on say in an if condition

e.g. <xsl:if test="$param1 = 'a'> comes out true but if we use <xsl:if test="$param1 = 'b'> comes out false.

I have seen a similar question here: Retrieve page URL params or page URL in XSLT which uses the str-split-to-words template but I have unsuccessfully got it working (possibly due to me implementing it the wrong way) so any working examples of how it can be done in practice would be massively beneficial.

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="'?&amp;'"/>
  </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>&#xA;</xsl:text>
</xsl:template>

</xsl:stylesheet>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:05:34+00:00Added an answer on June 4, 2026 at 1:05 am

    There are a few problems in your code:

    1. <xsl:import href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/strSplit-to-Words.xsl"/> I doubt that the wanted stylesheet can be imported directly from its SourceForge view page — especially taking into account, that it itself imports other FXSL stylesheets. The correct way to use FXSL is to download it to the local computer and reference its stylesheets off the file location it resides in at the local computer.

    …

    .2. <xsl:with-param name="pStr" select="$pQString"/> This will produce a compilation error because you missed to define the $pQString global/external parameter. You need to define this parameter at global level. It can be given a default value (for example a particular URL) for easier testing. However, the idea of using this parameter is that the invoker of the transformation should pass this parameter to the transformation.

    .3. The results of the transformation are written to the output. While this is good for demonstration purposes, you want to be able to use these results later in the transformation. The way to do this is to capture these results in a variable, make another variable from it, with a regular tree (from its RTF type) and then reference the nodes of this last variable.

    Here is an example of the code you want (provided that you have downloaded FXSL, unzipped the distribution and saved this code in the same directory as the unzipped distribution of FXSL):

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     >
    
       <xsl:import href="strSplit-to-Words.xsl"/>
    
       <xsl:output indent="yes" omit-xml-declaration="yes"/>
    
       <xsl:param name="pUrl" select=
       "'http://www.mydomain.com/mypage.htm?param1=a&amp;param2=b'"/>
    
       <xsl:param name="pQString" select=
         "substring-after($pUrl, '?')"
         />
    
    
        <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="'?&amp;'"/>
              </xsl:call-template>
            </xsl:variable>
    
           <xsl:variable name="vrtfqueryParams">
             <xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
           </xsl:variable>
    
           <xsl:variable name="vqueryParams" select="ext:node-set($vrtfqueryParams)/*"/>
    
           <xsl:value-of select="$vqueryParams/@name[. ='param1']"/>
           <xsl:text> : </xsl:text>
           <xsl:value-of select="$vqueryParams[@name = 'param1']"/>
    
           <xsl:text>&#xA;</xsl:text>
           <xsl:value-of select="$vqueryParams/@name[. ='param2']"/>
           <xsl:text> : </xsl:text>
           <xsl:value-of select="$vqueryParams[@name = 'param2']"/>
        </xsl:template>
    
        <xsl:template match="word">
          <param name="{substring-before(.,'=')}">
            <xsl:value-of select="substring-after(.,'=')"/>
          </param>
        </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on any XML document (not used in this demo), the wanted, correct result — the query-string parameters referenced of a results variable by name — is produced:

    param1 : a
    param2 : b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked several times, but I would like to
I know this question has been asked countless times before, but the other threads
I know this has been done many times before (some posts are really old
i know this has been asked here . But my question is slightly different.
I know this question has been asked and answered before, but none of the
I know this question has been asked before, but I have tried the given
I know this topic has been beat to death but a lot of the
I know the question about measuring developer performance has been asked to death, but
I know, variations of this question had been asked before. But my case may
I know this topic is bit old, but i did surf the web and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.