473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XSL variable indirection

Hello,

I am trying to use XSLT. Here is the problem that I am facing.

My XML file:

<Book level="1" name="Mapplicationtoc1">
....... Some more tags
</Book>

My XSL file
1) a.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.abc.com/">
<xsl:include href="../../shared/myxsl.xsl" />
<xsl:template match="abc:Book">
//Book
<xsl:variable name="tempMsg">
<xsl:value-of select="@name"/>
</xsl:variable>

<xsl:value-of select= "*[$tempMsg]"/>

</xsl:template>
</xsl:stylesheet>

Contents of
2)myxsl.xsl

<xsl:variable name="Mapplicationtoc1">About MyXSL</xsl:variable>
<some more such messages>

Now in the output I want "About MyXSL" to be displayed after
applying the templates for Book.
This is some thing like "pointer to pointer". I want to retrieve
the book name which is "Mapplicationtoc1" and I want the value of
variable named Mapplicationtoc1. This variable is present in myxsl.xsl.

What is the solution for this? I goggled a bit on this and got that
*[local-name() = $tempMsg] should be used but this does not work in my
case.

Waiting for reply
Regards,
Sucheta Phatak,

Sep 20 '05 #1
2 1448
Hi,

Tempore 13:11:23, die Tuesday 20 September 2005 AD, hinc in foro {comp.text.xml} scripsit <su************@gmail.com>:
Now in the output I want "About MyXSL" to be displayed after
applying the templates for Book.
This is some thing like "pointer to pointer". I want to retrieve
the book name which is "Mapplicationtoc1" and I want the value of
variable named Mapplicationtoc1. This variable is present in myxsl.xsl.


This is not possible in XSLT. You cannot possible call variables indirectly.

Try to think of another workaround. Here's some inspiration:

1) a.xsl

<xsl:template match="abc:Book">
<xsl:value-of select="$message[@name=current()/@name]"/>
</xsl:template>

2) myxsl.xsl

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="myvar"
xmlns:myvar="myVariables">
<xsl:output method="xml" indent="yes"/>

<myvar:map xmlns="">
<message name="Mapplicationtoc1">About MyXSL</message>
<!-- some more such messages -->
</myvar:map>

<xsl:variable name="message"
select="document('')/xsl:stylesheet/myvar:map/message"/>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Don't send spam. I don't like it and it is illegal.
Sep 20 '05 #2
Thanks Joris,

That solved my problem.

Regards,
Sucheta.

Joris Gillis wrote:
Hi,

Tempore 13:11:23, die Tuesday 20 September 2005 AD, hinc in foro {comp.text.xml} scripsit <su************@gmail.com>:
Now in the output I want "About MyXSL" to be displayed after
applying the templates for Book.
This is some thing like "pointer to pointer". I want to retrieve
the book name which is "Mapplicationtoc1" and I want the value of
variable named Mapplicationtoc1. This variable is present in myxsl.xsl.


This is not possible in XSLT. You cannot possible call variables indirectly.

Try to think of another workaround. Here's some inspiration:

1) a.xsl

<xsl:template match="abc:Book">
<xsl:value-of select="$message[@name=current()/@name]"/>
</xsl:template>

2) myxsl.xsl

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="myvar"
xmlns:myvar="myVariables">
<xsl:output method="xml" indent="yes"/>

<myvar:map xmlns="">
<message name="Mapplicationtoc1">About MyXSL</message>
<!-- some more such messages -->
</myvar:map>

<xsl:variable name="message"
select="document('')/xsl:stylesheet/myvar:map/message"/>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Don't send spam. I don't like it and it is illegal.


Sep 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steven T. Hatton | last post by:
Somewhere I seem to recall an example where the author was able to access some kind of representation of a variable's type and use it to create another variable of the same type. It may have been...
8
by: Groups User | last post by:
C allows type casting in which a variable is converted from one type to another. Does C (whatever standard) allow the type of a variable to change, within a statement, avoiding the conversion?...
10
by: Adam Warner | last post by:
Hi all, Just before Christmas Chris Torek gave me some great advice about closures in C: <http://groups.google.co.nz/groups?selm=cqcl3k030vj%40news3.newsguy.com&output=gplain> It includes this...
2
by: hsharsha | last post by:
Consider the below code: extern __declspec(dllimport) int myvariable; template<const int *p> class MyClass{ public: static void myfunction(){ } }; int main(void){
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
6
by: data | last post by:
I searched the internet and saw an old posting which has the same problem I am experiencing. The asp server doesn't recognize the variable I declare publicly in my codebehind class. The variable...
36
by: pereges | last post by:
Apart from the some rules set by the C standard what , in your opinion, are good naming convetions for variables ? Can you please give an example or two ?
21
by: Christian Meier | last post by:
Hello NG I have the following code: file1.h: static const int iValue = 5; <EOF>
3
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.