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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

from element value to url querystring (XSL)

Status
Not open for further replies.

ozane

Technical User
Feb 3, 2005
57
TR
i want to get values from xml and transfrom it via xsl. for a value of element i want to create a hyperlink. but link should contain a value from other element as querystring. how can i do that?? i tried to create a variable and add it to href. but no way, i miss something...
thanks

Code:
<a href="CSWMetaDetail.aspx?MetaID={$metaID}">
<span style="font-weight:bold;color:blue">
<xsl:value-of select="dc:title"></xsl:value-of></span></a>

<xsl:variable name="metaID" select="csw:GetRecordsResponse/csw:SearchResults/dc:identifier"	></xsl:variable>
 

<xsl:variable name="metaID" select="csw:GetRecordsResponse/csw:SearchResults/dc:identifier"/>

<a href="CSWMetaDetail.aspx?MetaID={$metaID}" style="font-weight:bold;color:blue">
<xsl:value-of select="dc:title"/></a>

 
i cant get the value of the metaID variable in the url
 
Does the variable have a value ?

Have you tried:

<xsl:variable name="metaID" select="csw:GetRecordsResponse/csw:SearchResults/dc:identifier"/>

<xsl:value-of select="$metaID"/>
 
>i cant get the value of the metaID variable in the url
If you mean at the server, you have to remind that the name/data value pair need be url encoded. Maybe that's the problem... not sure though with the thin info.
 
How about something like the following?
Code:
<a>
<xsl:attribute name="href">
  <xsl:text>CSWMetaDetail.aspx?MetaID=</xsl:text>
  <xsl:value-of select="csw:GetRecordsResponse/csw:SearchResults/dc:identifier"/>
</xsl:attribute>
<span style="font-weight:bold;color:blue"><xsl:value-of select="dc:title"/></span>
</a>

Tom Morrison
 
Your code is fine, but simon is right, you must declare the variable before using it. Equally valid would be:
Code:
<a href="CSWMetaDetail.aspx?MetaID={csw:GetRecordsResponse/csw:SearchResults/dc:identifier}">
  <span style="font-weight:bold;color:blue">
    <xsl:value-of select="dc:title"/>
  </span>
</a>
But you must make sure csw:GetRecordsResponse/csw:SearchResults/dc:identifier actually points to a value (use <xsl:value-of select="csw:GetRecordsResponse/csw:SearchResults/dc:identifier"/> to test)

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top