|
From: Roy C. <so...@ho...> - 2006-05-28 19:46:18
|
Hi Oleg,
Thanks for your reply. I feel kinda stupid, I was indeed missing the
ExsltContext object. I thought my code broke on the call to Compile(), while
it was in fact the call to Select(). The reason was obviously the missing
ExsltContext object.
Regards, Roy
>From: Oleg Tkachenko <ol...@tk...>
>To: Roy Cornelissen <so...@ho...>
>CC: mvp...@li...
>Subject: Re: [mvp-xml-help] DynamicContext.Compile
>Date: Thu, 25 May 2006 23:11:08 +0200
>
>Hmmm, you must be missing something. Here is a working sample:
>
><foo xmlns:b="bar">
> <b:bar>text</b:bar>
></foo>
>
>XmlDocument doc = new XmlDocument();
>doc.Load("../../XMLFile1.xml");
>string xpath = "/foo/b:bar";
>XPathExpression expr = XPathExpression.Compile(xpath);
>ExsltContext ctx = new ExsltContext(doc.NameTable);
>ctx.AddNamespace("b", "bar");
>expr.SetContext(ctx);
>Console.WriteLine(doc.CreateNavigator().SelectSingleNode(expr).OuterXml);
>
>--
>Oleg
>
>
>Roy Cornelissen wrote:
>>Hi,
>>
>>I'm in the process of implementing the Mvp.Xml library into my project.
>>I'm having trouble precompiling xpath expressions that use namespace
>>prefixes. If I specify the namespace prefix in the xpath expression, I get
>>the exception "Namespace Manager or XsltContext needed. This query has a
>>prefix, variable, or user-defined function.". If I leave out the prefix,
>>the expression does not return the nodes I expect, so I do need to specify
>>a namespace in my xpath query.
>>
>>Am I overlooking something?
>>
>>Thanks!
>>
>>Regards, Roy Cornelissen
>>
>>_________________________________________________________________
>>Hotmail en Messenger on the move http://www.msn.nl/services
>>
>>
>>
>>-------------------------------------------------------
>>Using Tomcat but need to do more? Need to support web services, security?
>>Get stuff done quickly with pre-integrated technology to make your job
>>easier
>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>_______________________________________________
>>mvp-xml-help mailing list
>>mvp...@li...
>>https://lists.sourceforge.net/lists/listinfo/mvp-xml-help
_________________________________________________________________
Talk with your online friends with MSN Messenger
http://www.join.msn.com/messenger/overview
|