Re: [xsl] node-set in .Net 2.0?

Subject: Re: [xsl] node-set in .Net 2.0?
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Mon, 28 Nov 2005 19:25:54 -0700

Not that it matters, but why are you binding 'ns' instead of 'msxsl'?

Anyway, not important. The following C# will compile to a .NET 2.0 console app:

using System;
using System.Xml;
using System.Xml.Xsl;

namespace ConsoleApplication1
   class Program
       static void Main(string[] args)
           XslCompiledTransform xslt = new XslCompiledTransform();
           xslt.Transform("test.xml", "test.html");

using the following dummy xml saved as test.xml:

<?xml version="1.0" encoding="utf-8" ?>

and the following xsl transformation file saved as test.xsl:

<xsl:stylesheet xmlns:xsl="";

<xsl:variable name="list">
<item test="foo">bar</item>
<item test="bar">of chocolate</item>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="ns:node-set($list)/item" />
<xsl:template match="item">
<xsl:value-of select="@test"/>:<xsl:value-of select="."/>

creates the following output saved as test.html:

foo:barbar:of chocolate

I'm building against the final .NET 2.0 release so I'm not sure where your problem might be. A sample of your xml and xsl transformation file might help clear things up, but until I see it I can't no this for sure.

bryan rasmussen wrote:


I'm running a node-set heavy transform in .Net, I keep getting the
following error:

The 'Function 'ns:node-set()' has failed.'
If I change the variable that is creating the node-set not to I get
the following error:
The expression passed to this method should result in a NodeSet.

the ns namespace is associated with

IIRC this namespace was allowed in earlier versions of .NET. Does
anyone know if this has changed, has .Net's already arcane nodeset
handling rules changed? Does one have to explicitly allow nodesets to
be created in ones code?

Bryan Rasmussen

Current Thread