Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Binding, XPath & Namespaces

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
Doug
Guest


 

Binding, XPath & Namespaces

Does anyone know if its possible to use an XPath binding into XML that uses
namespaces?

For example, this doesn't work, because I haven't defined the namespaces:

<Grid>
<Grid.Resources>
<XmlDataProvider x:Key="data">
<data:root xmlns:data="http://data">
<data:item>blah</data:item>
</data:root>
</XmlDataProvider>
</Grid.Resources>
<TextBlock Text="{Binding Source={StaticResource data}, XPath=/data:root/data:item}"
/>
</Grid>


Instead I get the exception:
XPathException:Namespace Manager or XsltContext needed. This query has a
prefix, variable, or user-defined function.

But, how can I provide it?

- Doug


Old 01-10-2006   #2 (permalink)
Drew Marsh
Guest


 

Re: Binding, XPath & Namespaces

Doug wrote:

> Does anyone know if its possible to use an XPath binding into XML that
> uses namespaces?
>
> ... code snipped for brevity ...
>
> But, how can I provide it?


This[1] should explain it.

HTH,
Drew

[1] http://winfx.msdn.microsoft.com/libr...e18fc4284b.asp


Old 01-10-2006   #3 (permalink)
Doug
Guest


 

Re: Binding, XPath & Namespaces

Wow, how on earth did I not find that! Thanks!

- Doug

> Doug wrote:
>
>> Does anyone know if its possible to use an XPath binding into XML
>> that uses namespaces?
>>
>> ... code snipped for brevity ...
>>
>> But, how can I provide it?
>>

> This[1] should explain it.
>
> HTH,
> Drew
> [1]
> http://winfx.msdn.microsoft.com/libr.../library/en-us
> /wcp_conceptual/html/a47c832f-dc84-48f2-96d5-cde18fc4284b.asp
>



Old 01-10-2006   #4 (permalink)
Doug
Guest


 

Re: Binding, XPath & Namespaces

Unfortunately I can't work out what this maps to in the November SDK.

XmlDataNameSpaceManager is gone. Now it looks like it might be the System.Xml.XmlNamespaceManager
from System.Xml.dll, but I'm having a bit of trouble creating it with XAML.

- Doug

> Wow, how on earth did I not find that! Thanks!
>
> - Doug
>
>> Doug wrote:
>>
>>> Does anyone know if its possible to use an XPath binding into XML
>>> that uses namespaces?
>>>
>>> ... code snipped for brevity ...
>>>
>>> But, how can I provide it?
>>>

>> This[1] should explain it.
>>
>> HTH,
>> Drew
>> [1]
>> http://winfx.msdn.microsoft.com/libr...=/library/en-u
>> s
>> /wcp_conceptual/html/a47c832f-dc84-48f2-96d5-cde18fc4284b.asp



Old 01-10-2006   #5 (permalink)
Doug
Guest


 

Re: Binding, XPath & Namespaces

Looks like I jumped the gun.

XmlDataNameSpaceManager which was a subclass of XmlNamespaceManager has been
removed. Instead this can be done using the utility subclass XmlNamespaceMappingCollection
(probably just the same thing with a new name). For example:

<XmlNamespaceMappingCollection x:Key="myNamespaces">
<XmlNamespaceMapping Prefix="y" Uri="http://schemas.somecompany.com/12/2005/y"
/>
</XmlNamespaceMappingCollection>

- Doug

> Unfortunately I can't work out what this maps to in the November SDK.
>
> XmlDataNameSpaceManager is gone. Now it looks like it might be the
> System.Xml.XmlNamespaceManager from System.Xml.dll, but I'm having a
> bit of trouble creating it with XAML.
>
> - Doug
>
>> Wow, how on earth did I not find that! Thanks!
>>
>> - Doug
>>
>>> Doug wrote:
>>>
>>>> Does anyone know if its possible to use an XPath binding into XML
>>>> that uses namespaces?
>>>>
>>>> ... code snipped for brevity ...
>>>>
>>>> But, how can I provide it?
>>>>
>>> This[1] should explain it.
>>>
>>> HTH,
>>> Drew
>>> [1]
>>> http://winfx.msdn.microsoft.com/libr...l=/library/en-
>>> u
>>> s
>>> /wcp_conceptual/html/a47c832f-dc84-48f2-96d5-cde18fc4284b.asp



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding inside binding question Yoavo Avalon 0 12-03-2007 08:24 AM
Binding Question (Binding in General) Jason Avalon 2 05-09-2007 04:41 AM
Calling an XPath on a Binding with an XmlNode causes StackOverflowException Keith Patrick Avalon 0 01-05-2007 10:22 AM
Xml Binding - Why does XPath return nothing? jmagaram Avalon 0 10-13-2006 04:25 PM
Xml Binding - Why does XPath return nothing? jmagaram Avalon 0 10-13-2006 04:24 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50