Versioning xaml
One of the things we haven't talked a lot about is the versioning support built into xaml. Once version 2 of WPF comes out, we want people to be able to write xaml documents that take advantage of new, V2 features while still running as best is possible on machines that only have V1. Unlike some parts of WPF, we actually have pretty thorough documentation on this topic, because it's part of the XPS spec -- specifically appendix B of https://www.microsoft.com/whdc/xps/xpspkg.mspx. But the highlights:
xaml lets you declare certain name spaces as being ignorable -- "if you haven't heard of this namespace, just pretend those tags aren't even there, they're not that important". As in:
<Circles
xmlns="https://schemas.example.com/Circles/v1"
xmlns:mc="https://schemas.microsoft.com/winfx/2005/06/markup-
compatibility"
xmlns:v2="https://schemas.example.com/Circles/v2"
xmlns:v3="https://schemas.example.com/Circles/v3"
mc:Ignorable="v2 v3"
mc:PreserveAttributes="v3:Luminance">
<Circle Center="0,0" Radius="20" Color="Blue"
v2:Opacity="0.5" v3:Luminance="13" />
</Circles>
(this example ignores attributes, but you can also ignore whole tags) You can also specify the opposite of ignorable -- MustUnderstand. And there's also ProcessContent, which means in effect ignore me but pay attention to my children. And you can give multiple choices -- if you understand Foo, use this xaml, and if you don't use some other xaml:
<Circles
xmlns="https://schemas.example.com/Circles/v1"
xmlns:mc="https://schemas.microsoft.com/winfx/2005/06/markup-
compatibility"
xmlns:v2="https://schemas.example.com/Circles/v2"
xmlns:v3="https://schemas.example.com/Circles/v3"
mc:Ignorable="v2 v3">
<mc:AlternateContent>
<mc:Choice Requires="v3">
<v3:Circle Center="0,0" Radius="20" Color="Blue" Opacity="0.5"
Luminance="13" />
</mc:Choice>
<mc:Fallback>
<LuminanceFilter Luminance="13">
<Circle Center="0,0" Radius="20" Color="Blue"
v2:Opacity="0.5" />
</LuminanceFilter>
</mc:Fallback>
</mc:AlternateContent>
</Circles>
All this is yours to play with in the November CTP and beyond.
Comments
- Anonymous
January 18, 2006
Thank you :)
There are two question for me that I'll look for their answers in OpenPackaging:
1- How can we govern on the types of attributes and elements of these ignorable namespaces?
2- How can we link one namespace to another? For example if we require V2 to be if V3 exist how can this be applicable?