954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

using dynamic links

Hello there!
I am pretty new to xml and xsl. I have been trying to achive a dynamic link creation. My xml file has the format like;

[INDENT]company_name[INDENT]2334xsTu4
info@comany.com[/INDENT][/INDENT]

I want to use an XSL file to give me a link like detail.aspx?id=2334

I have tried
<xsl:value-of select="id"/>
<a href="detay.aspx?id={id}">
<xsl:value-of select="company"/>
</a>

but didnt get what i need:( I need a company name with a link:) so I can post it to details.aspx page with the company id.
I am using to get all the information as well.

So? any idea?

Ceviz
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

Well first off your input sample isn't well formed XML, so there's something wrong with the sample you've given.

However, if you're trying to build a string that looks like that, this transformation will work. I've modified your original input as well to make it work.

Input

<root>
	<customer>company_name
		<id>2334</id>
		<code>xsTu4</code>
		<mail>info@comany.com</mail>
	</customer>
</root>


XSLT Transformation

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
		<xsl:apply-templates select="root"/>
	</xsl:template>

	<xsl:template match="root">
		<xsl:element name="links">
			<xsl:apply-templates select="customer"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="customer">
		<xsl:element name="page">
			<a>
				<xsl:attribute name="href">
					<xsl:value-of select="concat('detail.aspx?id=',id)"/>
				</xsl:attribute>
			</a>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>


This produces an output of the following.

<links>
	<page>
		<a href="detail.aspx?id=2334"/>
	</page>
</links>


Without more details, I can't really help much more.

iceandrews
Junior Poster
185 posts since May 2010
Reputation Points: 10
Solved Threads: 30
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: