2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by iceandrews
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.