473,602 Members | 2,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="Mapplicat iontoc1">
....... Some more tags
</Book>

My XSL file
1) a.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et 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="Mapplicat iontoc1">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 "Mapplicationto c1" and I want the value of
variable named Mapplicationtoc 1. 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 1468
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 "Mapplicationto c1" and I want the value of
variable named Mapplicationtoc 1. 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="$messag e[@name=current()/@name]"/>
</xsl:template>

2) myxsl.xsl

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

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

<xsl:variable name="message"
select="documen t('')/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 "Mapplicationto c1" and I want the value of
variable named Mapplicationtoc 1. 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="$messag e[@name=current()/@name]"/>
</xsl:template>

2) myxsl.xsl

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

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

<xsl:variable name="message"
select="documen t('')/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
1430
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 in the context of templates. Here's why I ask; I have a member field declared like this: protected: vector<vector<SbVec3f*> >* strips_ptr;
8
5016
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? And if so, provide an example of how its done. Example: int a=23; int b=34;
10
2658
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 declaration of a function pointer variable called fp: void (*fp)(void *); What does the syntax above mean? I can only digest it as void * fp, i.e. fp is a pointer to void.
2
1949
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
4041
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
1719
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 works fine if I just display in the page "<%=myImageFileName%>", but the server control doesn't recognize it. Is it a miscrosoft bug or did I got the syntax wrong? I am stuck. Please help me. My imageurl is dynamicly generated during page...
36
3795
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
2742
by: Christian Meier | last post by:
Hello NG I have the following code: file1.h: static const int iValue = 5; <EOF>
3
10799
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, commercially sold application with only partial build instructions. The previous maintainer of the code (a mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.