[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: node-set in .Net 2.0?

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

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.Load("test.xsl");
           xslt.Transform("test.xml", "test.html");
       }
   }
}

using the following dummy xml saved as test.xml:

<?xml version="1.0" encoding="utf-8" ?>
<foo>
   <bar>test</bar>
</foo>

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:ns="urn:schemas-microsoft-com:xslt"
               version="1.0">

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


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:

Hey

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
xmlns:ns="urn:schemas-microsoft-com:xslt"

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?

Cheers,
Bryan Rasmussen

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.