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;

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

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 <xsl:for-each select="/root/customer"> to get all the information as well.

So? any idea?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.