Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two questions

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
1. Is it possible to access a variable defined in a URL string of a web application accessed by XSLT? From what I have seen so far I would say know, but then my three days of experience isn't up to much!!

2. If the above isn't possible. I have defined a variable at the top of my XSLT file, and I want to be able to use this variable lower down in the document to output only the attributes that match the variable.

This is the definition:

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
	<xsl:output method="html" encoding="Windows-1252" />
   	<xsl:variable name="NumberOfRows" select="4" />
   	<xsl:variable name="Language" select="En" />

the lower down the doc I have:

Code:
<xsl:value-of select="URLText[@Language='$Language']"/>

And this doesn't work. It just returns the formatting elements but with nothing in the cells. The full XSLT I have is in this thread:
Any help appreciated

Tony
 
remove the quotes, add spaces around the opperators and try:
Code:
<xsl:value-of select="URLText[@Language = $Language]"/>

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks for the response, you seem to be the only person on this forum!

That didn't work, all I get back is blank fields!

Is it possible to do this?
Is it also possible to access a URL variable?
 
Code:
<xsl:variable name="Language" select="En" />

This is looking for a node "En" for the value of the variable. What you want is the string 'En'. So do this:

Code:
<xsl:variable name="Language" select="'En'" />

or this:

Code:
<xsl:variable name="Language">En</xsl:variable>

As for accessing the URL variable, you can't (unless you are using certain XSLT processors on the server-side).

Jon
 
can you post a clipping of the XML you are trying to access...?

And you might try this...
<xsl:variable name="Language">En</xsl:variable>
instead of...
<xsl:variable name="Language" select="En" />

select is most likely trying to select the En tag...
If one does not exist it could be setting your variable to false or just blank, rather than the text 'En'... another thing you could try is placing the text in single quotes ('):
<xsl:variable name="Language" select="'En'" />

The thing about variables, is they are inherited...
Such as:
Code:
<...>
  <a>  
  <...>
    <b>
  <...>
    <c>
    <...>
      <d>
a can't see any others...
b can see a
c can see a
d can see a & c

I believe it is possible to declare your variables outside of the <xsl:template> tags, if you need more than one template to access it...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top