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 7663453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:03:50+00:00 2026-05-31T14:03:50+00:00

I have used the following code in my XSL: <xsl:variable name=link select=normalize-space(concat(‘#’,$chapter2))/> <a href={$link}>Next

  • 0

I have used the following code in my XSL:

<xsl:variable name="link" select="normalize-space(concat('#',$chapter2))/>

<a href="{$link}">Next chapter</a>

It should navigate to chapter 2 position on click of the next chapter link.
Its not navigating to chapter 2 in chrome and firefox. When I hover to the link I found that in chrome and firefox after ‘#’ some extra characters gets added like #14678776e_chapter2.

How to fix this issue.

$chapter2 is position() value
Code:

<xsl:variable name=chapter2 select="position()"/>

Code for xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="w3.org/1999/XSL/Transform";
        xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        exclude-result-prefixes="msxsl"> 

    <xsl:output method="html" indent="yes"/> 

    <xsl:template match="/">
        <xsl:variable name="chapter" select="position()"/>
        <xsl:variable name="link" select="concat('#',$chapter)"/>
        <a href="{$link}" title="{$link}">
            <xsl:value-of select="$link"/>
        </a>
    </xsl:template>

</xsl:stylesheet>

There is no input xml for now. The above code can be run directly

Thanks,
Sam

  • 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-05-31T14:03:51+00:00Added an answer on May 31, 2026 at 2:03 pm

    The name “chapter2” needs to be surrounded by quotes:

    <xsl:variable name=chapter2 select="position()"/>
    

    Also, make sure the template that defines chapter2 is not the same that defines chapter1, or else the variable binding of chapter1 will shadow the variable binding of chapter2, since both will equal the result of the position function. This code works fine:

    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="pitarget.xml"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
                    >
    <xsl:variable name="gal" select="'howdy'"/>
    <?var gal?><!--howdy-->
    <?echo gal?>
    <?html5 ?>
    
    <xsl:output method="html" encoding="utf-8" version="" indent="yes" standalone="no" media-type="text/html" omit-xml-declaration="no" doctype-system="about:legacy-compat" />
    
    <xsl:template match="xsl:stylesheet">
      <xsl:apply-templates select="processing-instruction()"/>
    </xsl:template>
    
    <xsl:template match="/">
      <xsl:variable name="chapter" select="position()"/>
      <xsl:variable name="link" select="concat('#',$chapter)"/>
      <xsl:value-of select="processing-instruction('html5')"/>
      <a href="{$link}" title="{$link}"><xsl:value-of select="$link"/></a>
      <html>
        <head>
          <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        </head>
        <body>
          <xsl:apply-templates/>
        </body>
      </html>
    </xsl:template>
    
    
    <xsl:template match="processing-instruction('echo')">
      <xsl:variable name="chapter2" select="position()"/>
      <xsl:variable name="link" select="normalize-space(concat('#',$chapter2))"/>
      <a href="{$link}">Next chapter</a>
      <xsl:value-of select="//xsl:variable/@select[../@name=current()]"/>
      <xsl:value-of select="count(document('pitarget.xml')//*) - 1"/>
    </xsl:template>
    
    <xsl:template match="processing-instruction('var')">
      <xsl:processing-instruction name="{.}">
        <xsl:value-of select="."/>
        <xsl:value-of select="./following-sibling::node()"/>
      </xsl:processing-instruction>
    </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following code to programmatically select tableview cells - (void) selectTableCell{
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine
I have used the following code in a number of applications to load .DLL
i have used the following code in .htaccess Options +FollowSymlinks RewriteEngine On RewriteBase /
I have the following code - it is used to load a drop down
I have used the code supplied in the following CodeProject article in the past
I have the following code in an Autofac Module that is used in my
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I have used following code to add three variables but instead of adding these

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.