Not able to access variable from one XSLT into another

Posted on 2007-10-10
Last Modified: 2013-11-18
Myinput xml
<?xml version="1.0" encoding="UTF-8"?>

Myfirst xsl a.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
      <xsl:import href="b.xsl" />
      <xsl:output method="html" />
      <xsl:template match="/">
            <xsl:apply-templates select="*" />
      <xsl:template match="books">
            <xsl:apply-templates select="book" />
      <xsl:template match="book">
            <xsl:value-of select="Name" /> : <xsl:value-of select="name" /><br />
            <xsl:value-of select="Title" /> : <xsl:value-of select="title" /><br />
            <xsl:value-of select="Author" /> : <xsl:value-of select="author" /><br />

My imported xsl b.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo="">
      <xsl:variable name="Name"><xsl:text>Name</xsl:text></xsl:variable>
      <xsl:variable name="Title"><xsl:text>Title</xsl:text></xsl:variable>
      <xsl:variable name="Author"><xsl:text>Author</xsl:text></xsl:variable>

: VB
: VB6
: P

I am not getting the value of the variables in my main xsl.

Question by:gcmachel
    LVL 60

    Expert Comment

    by:Geert Bormans
    <xsl:value-of select="name" />
    accesses the name element in the current context
    if you need to acess a variable, you need to prepend a "$"

    <xsl:value-of select="$name" />
    LVL 60

    Accepted Solution

    should be
    <xsl:value-of select="$Name" />


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now