HREF in XSL

Hello!

I can’t properly get result into my Nokia emulator version 3.0 browser from my xsl stylesheet by using tag name: <xsl:attribute name=“href”>. Data from TAMINO are correct display in pretty table but I can’t make href attribute in my XSL file in order to ASP page displayed in NOKIA will good transform.

Please help me!

Regards
Dariusz Baumann
POLAND

Hi

How and where are you using the xsl:attribute tag ? You should have it immediately after the
tag you are trying to add the attribute to.

e.g.


<xsl:attribute name=“href”> … etc.

Regards,
Muiris.

Hello!

Thanks Muiris for reply. Before you answered I got a idea. I used

tag instead of tag, so that is why it was not worked.

NOW, it worked! :slight_smile:

Regards
Dariusz Baumann
POLAND

To find out what you’re doing wrong, I’ll need to see your code, and to know a little bit more about the input and desired output of your transformation.

Michael Kay

Hello!

My previous XSL was:
--------------------------------
<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” version=“1.0”>
<xsl:output omit-xml-declaration=“yes”/>

<xsl:template match="/">









<xsl:for-each select="//mydatabase">





</xsl:for-each>

Nr Name Address
<xsl:value-of select=“nr”/> <xsl:value-of select=“name”/>


<xsl:attribute name=“href”>find.asp?nr=<xsl:value-of select=“nr” />&address=<xsl:value-of select=“address” />
</xsl:attribute>
<xsl:value-of select=“address” />






</xsl:template>

</xsl:stylesheet>
--------------------------------


My corrected XSL is:

--------------------------------
<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” version=“1.0”>
<xsl:output omit-xml-declaration=“yes”/>

<xsl:template match="/">









<xsl:for-each select="//mydatabase">





</xsl:for-each>

Nr Name Address
<xsl:value-of select=“nr”/> <xsl:value-of select=“name”/>

<xsl:attribute name=“href”>find.asp?nr=<xsl:value-of select=“nr” />&address=<xsl:value-of select=“address” />
</xsl:attribute>
<xsl:value-of select=“address” />





</xsl:template>

</xsl:stylesheet>
--------------------------------

The one difference is tag instead of tag



Regards
Dariusz Baumann
POLAND

Thanks, it’s nice when a problem turns out to be that easy.

I’m surprised your XSLT processor a(or rather, your XML parser) allows you to write


<xsl:attribute name=“href”>find.asp?nr=<xsl:value-of select=“nr” />&address=<xsl:value-of select=“address” />
</xsl:attribute>
<xsl:value-of select=“address” />


- the “&” should be escaped as “& a m p ;” (perhaps it was, but has been corrupted by the forum software?)

I personally tend to write this kind of thing using attribute value templates:



It’s just a bit shorter and easier to read (and therefore easier to spot mistakes).

Michael Kay

Yes, it appears that when you type “& a m p ;” into a forum message (without the spaces), it comes out as “&”.

Michael Kay

I personally tend to write this kind of thing using attribute value templates:



It’s just a bit shorter and easier to read (and therefore easier to spot mistakes).

Maybe … but it doesn’t work for me. I’ve changed my XSL like this (There are three letters: amp after character ampersand):


<xsl:attribute name=“href”>find.asp?nr={<xsl:value-of select=“nr” />}&address=<xsl:value-of select=“address” />
</xsl:attribute>
<xsl:value-of select=“address” />


It displayed error in NOKIA TOOLKIT 3.

----
Ampersands

Yes, it appears that when you type “& a m p ;” into a forum message (without the spaces), it comes out as “&”.


You are right! :slight_smile:

Regards
Dariusz Baumann
POLAND