Click to See Complete Forum and Search --> : <A href="#{@id}> Value is not coming


saradhi74
November 17th, 2003, 12:40 AM
Hi I have one problem please help me... I pasted the code below...

<A href="#{@id}-DESCRIPTION" name="{@id}-COST">
<xsl:value-of select="name"/>
</A>

I used the above code in below xsl file....

when I view taht file in browser I could able to see hyper links on name but value of href is same as what i giave "="{@id}"

infact the @id should display the value....

I am using IE 5.5

please help me in finding out the problem..

Thanks in advance

******************XML File :
<?xml version="1.0"?>
<!--<!DOCTYPE juicers SYSTEM "juicers.dtd">-->
<?xml-stylesheet type="text/xsl" href="Juicers1.xsl"?>
<juicers>
<juicer id="mighty-oj" electric="false" type="press">
<name>OJ Home Juicer</name>
<image>images\mighty_oj.gif</image>
<description>There&apos;s just no substitute for a recyclable waste as do frozen juices.</description>
<warranty>lifetime warranty</warranty>
<weight></weight>
<cost currency="USD">41.95</cost>
<retailer>http://www.thewhitewhale.com/oj.htm</retailer>
</juicer>
</juicers>



****************XSL File :

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns="">


<xsl:template match = "/">
<html>
<body>
<h2> Juicers Example </h2>
<table border="1">
<tr>
<td>Jucers</td>
<td>Cost</td>
</tr>
<xsl:for-each select="/juicers/juicer">
<tr>
<td>
<A href="#{@id}-DESCRIPTION" name="{@id}-COST">

<xsl:value-of select="name"/>
</A>

</td>
<td>

$ <xsl:value-of select="cost[@currency='USD']"/>
</td>
</tr>
</xsl:for-each>

</table>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/>

<table border="1" width="100%">

<tr>
<td>Jucers</td>
<td>Description</td>
</tr>
<xsl:for-each select="/juicers/juicer">
<tr>
<td>
<a href="#{@id}-COST" name="{@id}-DESCRIPTION">
<xsl:value-of select="name"/>
</a>
</td>
<td>
<xsl:value-of select="description"/>
</td>
</tr>
</xsl:for-each>
</table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

khp
November 17th, 2003, 10:50 AM
IE5.5 is somewhat messed up, when it comes to xslt support.

You might try rewriting the the anchor creation to something like this.

<xsl:element name="A">
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>-DESCRIPTION</xsl:text>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@id"/>
<xsl:text>-COST</xsl:text>
</xsl:attribute>
<xsl:value-of select="name"/>
</xsl:element>

saradhi74
November 18th, 2003, 12:03 AM
Hi thanks for ur suggestion....

but unfortunately I am getting following error

"Keyword xsl:text may not be used here. "

what to do?

If I process it server side will that work?

Thanks in advance
Pardha

khp
November 18th, 2003, 01:45 PM
Originally posted by saradhi74
but unfortunately I am getting following error

"Keyword xsl:text may not be used here. "


Try not to use the text nodes then.
This might work.


<xsl:element name="A">
<xsl:attribute name="href">
#<xsl:value-of select="@id"/>-DESCRIPTION
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@id"/>-COST
</xsl:attribute>
<xsl:value-of select="name"/>
</xsl:element>


Originally posted by saradhi74
If I process it server side will that work?


It should, both your original code and my first suggestion works in xalan.

saradhi74
November 19th, 2003, 12:37 AM
Hi thanks a lot buddy it worked I am able to see the results...
but .......

It is not nevigating to the corresponding link when I clicked on hyperlink instead it is staying there only..

what should I do to work it...

in HTML if we mention #xx then It will navigate to the corresponding link where that was referred...

Here I got this

file:///C:/web/juicers.xml#wheateena in address bar....

Thanks in advance..
and once again thank you very much for ur solution

saradhi

khp
November 19th, 2003, 12:52 AM
I see your point.

I don't think there is any way to get around that, without moving the xsl transformation to the server side.

saradhi74
November 19th, 2003, 12:56 AM
Hi thanks buddy will try out on server side..... and let u know

Thanku verymuch
Pardha

saradhi74
November 20th, 2003, 06:55 AM
Hi still luck din't favoured me..... :(

the code which u gave me worked to get hyperlinks but they are not nevigating to the corresponding link..


Please find my attached ZIP file

I attached .xml, xsl, .asp and .html (the source code generated)


pls. go thru them and suggest me what to do if you have any idea.

Thanking you in advance
Pardha

khp
November 20th, 2003, 03:31 PM
Try taking a look at the html file.
In the name attributes, you will see a bunch of escape characters. These are caused by the white space after the text "-DESCRIPTION" and "-COST". You could just remove all the white space.
But the cleanest solution is of course to wrap all the text in xsl:text nodes, as in my original response.