XSLT vs. .NET 2.0 XML Framework

Published 08 June 06 05:55 AM

I have a project that I am wondering about using either XSLT or the .NET Framework 2.0 to transform an XML document into a table and then bind it. I know that I can bind XML in ways, but I am in a bind on this one and am more familiar with Framework coding in C# rather than XSLT.

I have run into a problem trying to get a URL into the xslt template using <a href=”something”>something</a> with the href being formed by part URL and part <xsl:value-of select=”something” />. It fails because I am not very good with it yet. Anyone with help or ideas, please feel free to suggest. I am going to go about it using .NET in C# and will entertain any XSLT help that anyone wants to provide.

I have been to www.topxml.com and www.xmlforasp.net and found some things that are basic, but nothing about how to use XSLT to put html elements together.

More to come as I finish this project.

Comments

# AD said on June 9, 2006 12:03 PM:
If you're generating HTML, you might take a look at Template Engine:
http://www.adersoftware.com/index.cfm?page=templateEngine2

works with .net 2 and is easy to use.
# Phil Weber said on June 9, 2006 12:19 PM:
Hi, Ben: Here's some code I had lying around that converts an XML element with location and title attributes into an HTML list item (<LI>) contain a href:

<xsl:template match="item">
 <LI>
 <A>
   <xsl:attribute name="HREF"><xsl:value-of select="@location" /></xsl:attribute>
   <xsl:attribute name="TITLE"><xsl:value-of select="@title" /></xsl:attribute>
   <xsl:value-of select="@title" />
 </A>
 </LI>
</xsl:template>
# Phil Weber said on June 9, 2006 12:19 PM:
Hi, Ben: Here's some code I had lying around that converts an XML element with location and title attributes into an HTML list item (<LI>) contain a href:

<xsl:template match="item">
 <LI>
 <A>
   <xsl:attribute name="HREF"><xsl:value-of select="@location" /></xsl:attribute>
   <xsl:attribute name="TITLE"><xsl:value-of select="@title" /></xsl:attribute>
   <xsl:value-of select="@title" />
 </A>
 </LI>
</xsl:template>
# Grant Parks said on June 11, 2006 3:53 PM:
Did you try concat()?  I'm a bit rusty so the syntax may be a li'l off.

<a href="{concat($partUrl,'/',xpath-or-var-$something)}">something</a>
# chris@moneyexpert.com said on June 12, 2006 5:13 AM:
You have to add the attribute explicitly, like this:

<a>
<xsl:attribute name="href">
<xsl:value-of select="websiteBaseURL">/yourpage.aspx
</xsl:attribute>
<xsl:value-of select="websiteBaseURL">/yourpage.aspx
</a>
# Michel Carroll said on June 12, 2006 9:02 AM:
You could pass in the "part URL" bit as an XSL parameter and then use concat($urlParam,"/",$vos) , where $vos has previously been evaluated to the required <xsl:value-of select=”something” />

Without seeing more details, I can't say if this is going to work, but it should be worth a try.

Good luck!

Michel
# Tomasz Szalaj said on June 21, 2006 1:04 PM:
Try this:
<xsl:element name="elem">
<xsl:attribute name="href">
<xsl:text>URL</xsl:text>
<xsl:value-of select="something">
</xsl:attribute>
</xsl:element>

Greetings,
Tom
Anonymous comments are disabled

This Blog

Syndication

Page view tracker