Blog Home  Home RSS 2.0 Atom 1.0 CDF  
Hairy Spider Blog - XSLT
A web of intrigue
 
 Friday, August 26, 2005

I've started using NCover to monitor the test coverage on a CruiseControl.net project. Disappointed with the included version of the ncover report I quickly through together a new version of the NCover.xsl to be used by CruiseControl.net. Simply download the file and copy it to: cruisecontrol.net/webdashboard/xsl/

It's based on the original ncover.xsl but inspired by the version from Yves Lorphelin's code coverage tool NCover

8/26/2005 9:09:46 AM (GMT Daylight Time, UTC+01:00)  #      CruiseControl.net | XSLT  | 
 Wednesday, March 02, 2005

Rob regarding your comment in this post:

I've uploaded this DualDocParserSample.zip file for your perusal.

It's all self contained and is just a little contrived. Nevertheless the principal is there. It's just that often I have XmlDocuments coming from loads of places and rather than merge them into one document it would be nice to pass in the various nodes as parameters to the transform sheet. Another example would be to pass in a look up file to use to decode some information.

The other useful information I found with this was the document() function, and the xsl:include element, both of which deserve a bit more use. 

3/2/2005 10:49:18 AM (GMT Standard Time, UTC+00:00)  #      XSLT  | 
 Tuesday, March 01, 2005

A follow up to yesterday's post about parsing 2 documents in the one stylesheet it is possible to do this.

I was very close to solving the problem but was sending the wrong object through. A look at the documentation (oops) reveals that I needed to pass a XPathNodeIterator.

Once I'd done this then everything worked fine. If anyone wants some example code let me know.

3/1/2005 6:37:47 PM (GMT Standard Time, UTC+00:00)  #      XSLT  | 
 Monday, February 28, 2005

I've been puzzling over this and I'm sure I've seen it done somewhere. Surely it must be possible to pass a document as a parameter to an xsl transform.

I've created the xslt and added the <xsl:param name="doc" /> and added the document via the XsltArgumentList.AddParam() method.

However, when I try to do anything to the $doc param inside the xslt file I get nothing.

<xsl:value-of select="string($doc)" /> returns "System.Xml.DomDocument"

Which makes me think that the AddParam() has performed a ToString() on the object before adding it as a param, but curiously:

<xsl:value-of select="$doc" /> does nothing.

I'm sure I'll get to the bottom of it tomorrow.

2/28/2005 6:31:44 PM (GMT Standard Time, UTC+00:00)  #      XSLT  | 
 Thursday, January 08, 2004

You have to thank the xpath translate function.

While implementing the comments functionality for this blog, I came across the problem of transforming the following data snippet:


<xml>
	<comment name="Rhys"
     url="http://www.hairy-spider.com/blog">Comment data</comment>
	<comment name="Dave"
    url="HTTP://www.google.com/">Comment data</comment>
	<lcomment name="Pete"
    url="www.yahoo.com">Comment data</comment>
</xml>

What I then wanted to do was to write out an A tag with the href set to the url attribute. No the href for the third statement will need an http:// added, so I need to detect if url starts with http:// if so write out that otherwise add an http://. This is easily achieved with the xsl:if command:

xsl:if test="starts-with(@url,'http://')"

The problem with this is that the starts-with function is case sensitive, and so I had to rely on an old trick involving the translate function and the final statement became

xsl:if test="starts-with(translate(@url, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'http://'))"

It's the first time I've had to use this method in anger, and I'm really pleased with the results. Now I've got half a dozen other ways where I can use this function.

1/8/2004 10:18:07 AM (GMT Standard Time, UTC+00:00)  #      XSLT  | 
Copyright © 2008 Rhys Jeremiah. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: