473,698 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.XPa th.XPathExcepti on - 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.Loa d(Filename)

Manager = New Xml.XmlNamespac eManager(Templa teDoc.NameTable )
' also tried this...
' Manager.AddName space("mbe", "http://dummy.com")
Manager.AddName space("xmlns:mb e", "http://dummy.com")
Manager.PushSco pe()

Nodes = TemplateDoc.Sel ectNodes("//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:styleshe et 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:valu e-of select="Title" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Nov 12 '05 #1
2 3512


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.XPa th.XPathExcepti on - 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.Loa d(Filename)

Manager = New Xml.XmlNamespac eManager(Templa teDoc.NameTable )
' also tried this...
' Manager.AddName space("mbe", "http://dummy.com")
Manager.AddName space("xmlns:mb e", "http://dummy.com")
Manager.PushSco pe()

Nodes = TemplateDoc.Sel ectNodes("//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*******@yaho o.de> wrote in message
news:%2******** ********@tk2msf tngp13.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.XPa th.XPathExcepti on - 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.Loa d(Filename)

Manager = New Xml.XmlNamespac eManager(Templa teDoc.NameTable )
' also tried this...
' Manager.AddName space("mbe", "http://dummy.com")
Manager.AddName space("xmlns:mb e", "http://dummy.com")
Manager.PushSco pe()

Nodes = TemplateDoc.Sel ectNodes("//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
2746
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 straight XML file http://www.discovertravelandtours.com/test/templates/test.xml?Location=Germany To another XML file http://www.discovertravelandtours.com/test/templates/test2.xml?Location=Germany
20
6782
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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
3404
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 happening when I put my XML files and the .xsl files on my ISP's system for my home page. If I try to open the XML files in Netscape 7.0 on my own machine (ie, not on the ISP's system), the pages convert file and the result is displayed in HTML.
1
3601
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 version 2 of XSLT processor based on some condition. Q) How and where shall I write logic or import desirable XSLT on the Fly ? Q) When we call AAA.XSLT then it will be processed by XSLT Processor 1
5
7413
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 collection that I need. To begin, I am using xsltproc that conmes with Cygwin as my processor. I have no particular affinity to this processor except that it is open source and standards compliant. I don't like M$, but if using a M$ processing...
12
3226
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 (xml->html) doen't happen! I have XSLT files for this, they work, I mean when I put the output of the app as an XML file on some server, and make it use the XSLT files to transform into HTML, it works, I get a HTML page.
6
2485
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 I've hit a snag. How do I resolve multiple external references? The transform method on a stylesheet only takes one resolver, not an array Stephen
7
2858
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 parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
2
1669
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 doc and xslt stylesheet could plz tell me what wrong with my stylesheet. Remark: X-smiles is used as web browser and it returns an error message when the page is called. the page is called as: http://localhost:8080/mydoc.xml both xml do and xslt...
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.