473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem querying a XSLT stylesheet

I loaded a XSLT stylesheet into a XMLDocument to retrieve some of the data.
I received an exception when the SelectNodes method was invoked. The
message was "System.Xml.XPath.XPathException - Namespace Manager or
XsltContext needed. This query has a prefix, variable, or user-defined
function."
Q324899

I queried MSDN for Namespace Manager and found this article: "Manage
namespaces Using the XmlNamespace Manager"
http://msdn.microsoft.com/library/de...aceManager.asp

So, based upon the article, I modified my code to look like this:

TemplateDoc = New Xml.XmlDocument
TemplateDoc.Load(Filename)

Manager = New Xml.XmlNamespaceManager(TemplateDoc.NameTable)
' also tried this...
' Manager.AddNamespace("mbe", "http://dummy.com")
Manager.AddNamespace("xmlns:mbe", "http://dummy.com")
Manager.PushScope()

Nodes = TemplateDoc.SelectNodes("//mbe:Parameters/parameter")

But, I'm still getting the exception. Anyone have any suggestions?

For what it's worth, I also queried MSDN for XsltContext. The web page for
XsltContext said to refer to Q324899 for more information. Querying on
Q324899 just brought me back to the link above.

Richard

P.S.
Here's what the file looks like:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:mbe="http://dummy.com">
<mbe:Parameters>
<parameter name="value1" required="yes" />
<parameter name="value2" />
</mbe:Parameters>

<xsl:output method="html" />
<xsl:template match="*" >
<html>
<body>
Sample Table
<table>
<xsl:for-each select="Data">
<tr>
<td>Title: </td>
<td><xsl:value-of select="Title" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Nov 12 '05 #1
2 3490


Richard L Rosenheim wrote:
I loaded a XSLT stylesheet into a XMLDocument to retrieve some of the data.
I received an exception when the SelectNodes method was invoked. The
message was "System.Xml.XPath.XPathException - Namespace Manager or
XsltContext needed. This query has a prefix, variable, or user-defined
function."
Q324899

I queried MSDN for Namespace Manager and found this article: "Manage
namespaces Using the XmlNamespace Manager"
http://msdn.microsoft.com/library/de...aceManager.asp

So, based upon the article, I modified my code to look like this:

TemplateDoc = New Xml.XmlDocument
TemplateDoc.Load(Filename)

Manager = New Xml.XmlNamespaceManager(TemplateDoc.NameTable)
' also tried this...
' Manager.AddNamespace("mbe", "http://dummy.com")
Manager.AddNamespace("xmlns:mbe", "http://dummy.com")
Manager.PushScope()

Nodes = TemplateDoc.SelectNodes("//mbe:Parameters/parameter")


You need to pass the namespace manager as the second argument to
SelectNodes.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Thank you, that was it. Didn't even notice that SelectNodes took a second
parameter.

Richard Rosenheim
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...


Richard L Rosenheim wrote:
I loaded a XSLT stylesheet into a XMLDocument to retrieve some of the data. I received an exception when the SelectNodes method was invoked. The
message was "System.Xml.XPath.XPathException - Namespace Manager or
XsltContext needed. This query has a prefix, variable, or user-defined
function."
Q324899

I queried MSDN for Namespace Manager and found this article: "Manage
namespaces Using the XmlNamespace Manager"
http://msdn.microsoft.com/library/de...aceManager.asp
So, based upon the article, I modified my code to look like this:

TemplateDoc = New Xml.XmlDocument
TemplateDoc.Load(Filename)

Manager = New Xml.XmlNamespaceManager(TemplateDoc.NameTable)
' also tried this...
' Manager.AddNamespace("mbe", "http://dummy.com")
Manager.AddNamespace("xmlns:mbe", "http://dummy.com")
Manager.PushScope()

Nodes = TemplateDoc.SelectNodes("//mbe:Parameters/parameter")


You need to pass the namespace manager as the second argument to
SelectNodes.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
20
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
2
by: nanookfan | last post by:
Hi all, I'm having a bizarre problem converting XML files to HTML using an XSLT. The problem is only occuring in my Netscape 7.0 browser. What makes it more bizarre is that it is only...
1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: li72 | last post by:
Hi. everyone I am new to xslt and Xforms technologies. I am trying to write a very simple xslt stylesheet to transform a very simple xml doc into Xforms doc. (Hello world example) here are my xml...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.