WCS 常见配置文件类型架构 V1
下面提供了 WCS 通用配置文件类型的 v1.0 架构定义。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wcs="http://schemas.microsoft.com/windows/2005/02/color/WcsCommonProfileTypes"
targetNamespace="http://schemas.microsoft.com/windows/2005/02/color/WcsCommonProfileTypes"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
blockDefault="#all"
version="1.0">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" />
<xs:annotation>
<xs:documentation xml:lang="en">
Common types used in WCS profile schemas.
Copyright (C) Microsoft. All rights reserved.
</xs:documentation>
</xs:annotation>
<xs:simpleType name="NonNegativeFloatType">
<xs:restriction base="xs:float">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="NonNegativeCIEXYZType">
<xs:attribute name="X" type="wcs:NonNegativeFloatType" use="required"/>
<xs:attribute name="Y" type="wcs:NonNegativeFloatType" use="required"/>
<xs:attribute name="Z" type="wcs:NonNegativeFloatType" use="required"/>
</xs:complexType>
<xs:simpleType name="GUIDType">
<xs:restriction base="xs:string">
<xs:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="LocalizedTextType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="xml:lang" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="MultiLocalizedTextType">
<xs:sequence>
<xs:element name="Text" type="wcs:LocalizedTextType" minOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:schema>
仅支持 UTF-8 或 UTF-16 编码。 为了保持最佳互操作性,强烈建议不要使用所有其他 XML 编码。
WCS 常见配置文件类型架构 V2 新增内容
在 Windows 7 中,WCS 通用配置文件类型架构已更新为包含支持 WCS 校准架构的类型。
<xs:complexType name="ParameterizedCurvesType">
<xs:sequence>
<xs:element name="RedTRC" type="wcs:ParameterizedCurveType"/>
<xs:element name="GreenTRC" type="wcs:ParameterizedCurveType"/>
<xs:element name="BlueTRC" type="wcs:ParameterizedCurveType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ParameterizedCurveType">
<xs:attribute name="Gamma" type="wcs:NonNegativeFloatType" use="required"/>
<xs:attribute name="Offset1" type="xs:float" use="optional"/>
<xs:attribute name="Gain" type="wcs:NonNegativeFloatType" use="optional"/>
<xs:attribute name="Offset2" type="xs:float " use="optional"/>
<xs:attribute name="TransitionPoint" type="wcs:NonNegativeFloatType" use="optional"/>
<xs:attribute name="Offset3" type="xs:float" use="optional"/>
</xs:complexType>
<xs:simpleType name="FloatList">
<xs:list itemType="xs:float"/>
</xs:simpleType>
<xs:complexType name="OneDimensionLutType">
<xs:sequence>
<xs:element name="Input" type="wcs:FloatList"/>
<xs:element name="Output" type="wcs:FloatList"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="HDRToneResponseCurvesType">
<xs:sequence>
<xs:element name="RedTRC" type="wcs:OneDimensionLutType"/>
<xs:element name="GreenTRC" type="wcs:OneDimensionLutType"/>
<xs:element name="BlueTRC" type="wcs:OneDimensionLutType"/>
</xs:sequence>
<xs:attribute name="TRCLength" use="required">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="2" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
WCS 配置文件架构版本控制
在本附录中,术语“配置文件使用者”是指 WCS 软件或使用 WCS 配置文件的第三方软件组件。
较新版本的配置文件使用者将能够使用根据旧版本的架构编写的 WCS 配置文件。 若要充分利用架构最新版本中定义的功能,通常需要最新版本的配置文件使用者。 但是,较旧的配置文件使用者可以使用根据较新版本的架构编写的配置文件。 配置文件使用者可以忽略它无法理解的 XML 元素和属性。 结果是正确的,但与使用最新版本的配置文件使用者实现的结果相比,性能或保真度可能会下降。
下面是适用于配置文件使用者的版本控制准则:
- 给定版本的配置文件使用者必须识别版本命名空间中的所有元素和属性,或者不能识别它们。
- 如果配置文件使用者遇到它无法理解的命名空间中的元素或属性,则必须将其视为错误条件,除非配置文件包含有关回退处理的明确指导。
- 开放打包规范定义了一个附加的命名空间 URI,即标记兼容性命名空间,该命名空间定义提供此回退处理指南的元素和属性。
- 所有配置文件使用者的所有版本都必须识别并尊重标记兼容性命名空间中的所有元素和属性。
- 基于新版本的配置文件架构的配置文件使用者必须支持所有以前定义的版本命名空间。
在 v1.0 版本中,WCS 识别以下命名空间中的元素和属性:
https://schemas.microsoft.com/windows/2005/02/color/ColorDeviceModel
https://schemas.microsoft.com/windows/2005/02/color/GamutMapModel
https://schemas.microsoft.com/windows/2005/02/color/ColorAppearanceModel
https://schemas.microsoft.com/winfx/2005/06/markup-compatibility
下面演示了标记兼容性的示例。
<?xml version="1.0" encoding="utf-8" ?>
<ColorAppearanceModel
xmlns=http://schemas.microsoft.com/windows/2005/02/color/ColorAppearanceModel
xmlns:cam2=http://schemas.microsoft.com/windows/2007/08/color/ColorAppearanceModel
xmlns:mc=http://schemas.microsoft.com/winfx/2005/02/markup-compatibility
xs:schemaLocation="http://schemas.microsoft.com/windows/2005/02/color/ColorAppearanceModel ColorAppearanceModel.xsd"
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
mc:Ignorable="cam2">
<ProfileName>Default profile for ICC viewing conditions</ProfileName>
<mc:AlternateContent>
<mc:Choice Requires="cam2">
<cam2:AudioDescription source="ProfileExplanation.wav"/>
</mc:Choice>
<mc:Fallback>
<Description>Appropriate for a print in a D50 viewing booth</Description>
</mc:Fallback>
</mc:AlternateContent>
<Author>Microsoft</Author>
<ViewingConditions>
<WhitePointName>D50</WhitePointName>
<Background X="19.3" Y="20.0" Z="16.5" />
<Surround>Average</Surround>
<LuminanceOfAdaptingField>31.8</LuminanceOfAdaptingField>
<DegreeOfAdaptation>-1</DegreeOfAdaptation>
<cam2:Humidity>30%</cam2:Humidity>
</ViewingConditions>
</ColorAppearanceModel>
WCS 配置文件本地化
要求
WCS 配置文件包含某些元素,例如 ProfileName 和 Description,它们包含用户可读的文本。 此文本可本地化。
以下是配置文件创建者的版本控制准则:
对于第三方(如打印机制造商)创建的配置文件,配置文件作者应包含多种语言的描述性文本。
以下元素应可本地化:
元素 CDMP GMMP CAMP ProfileName x x x 说明 x x x 作者 x x x
表达可本地化元素
每个可本地化元素包含一个或多个 wcs:Text 子元素,每个子元素必须指定 xml:lang 属性,而不是直接包含文本。 如 XML 规范 第 2.12 节 (“语言标识”) 中所述,xml:lang 属性的值必须是 IETF RFC 3066 语言标识符,例如“en-US”、“en”或“fr-FR”。 在 WCS 架构中,xml:lang 属性的值不得为空字符串“”,即使 XML 在一般情况下允许这样做。 例如:
<cdm:ColorDeviceModel ... />
<cdm:Description>
<wcs:Text xml:lang="en-US">Hello</wcs:Text>
<wcs:Text xml:lang="fr-FR">Bonjour</wcs:Text>
</cdm:Description>
...
</cdm:ColorDeviceeModel>
两个 wcs:Text 元素不能具有相同的 xml:lang 属性。 每个 WCS 配置文件架构必须为每个可本地化元素单独强制实施此约束。 仅支持 UTF-8 和 UTF-16 编码。
架构支持
该设计使用在 WCS 通用配置文件类型架构中定义的 XSD 类型 wcs:LocalizedText 和 wcs:MultiLocalizedType:
<xs:complexType name="LocalizedText">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="xml:lang" type="xs:string" use="required"/>
<xs:extension/>
<xs:simpleContent/>
</xs:complexType/>
<xs:complexType name="MultiLocalizedType">
<xs:element name="Text" type="cam:LocalizedText" minOccurs="1"/>
</xs:complexType>
每个 WCS 配置文件架构将每个可本地化元素声明为 MultiLocalizedType 类型,例如:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cdm="http://schemas.microsoft.com/windows/2005/02/color/ColorDeviceModel"
xmlns:wcs="http://schemas.microsoft.com/windows/2005/02/color/WcsCommonProfileTypes"
targetNamespace=
"http://schemas.microsoft.com/windows/2005/02/color/ColorDeviceModel"
version="1.0">
<xs:import namespace=
"http://schemas.microsoft.com/windows/2005/02/color/WcsCommonProfileTypes"/>
<xs:element name="cdm:Description" type="wcs:MultiLocalizableType" minOccurs="0"/>
<xs:unique name="uniqueDescriptionLanguage">
<xs:selector xpath="cdm:ColorDeviceModel/cdm:Description/wcs:Text"/>
<xs:field xpath="@xml:lang"/>
</unique>
...
</xs:schema>
CDMP 架构强制实施 cdm:Description 元素的每个 wcs:Text 子元素必须具有唯一的 xml:lang 属性的约束。 它对其他可本地化元素强制实施相同的约束。 CAMP 和 GMMP 架构也这样做。
选择语言
在确定要显示的可本地化元素的语言版本时,应用程序代码应选择与“当前语言”最接近的“版本”。 “最接近的版本”和“当前语言”实际上的含义是依赖于平台的;请参阅下文。 如果配置文件不包含与当前语言匹配的语言版本,则应用程序应选择配置文件中的第一个版本 (可本地化元素) 的第一个 wcs:Text 子元素。
在 Windows Vista 上,语言选择按如下方式完成:每个线程都有一个关联的“首选 UI 语言”列表,可以通过调用 GetThreadPreferredUILanguages 来获取该列表。 列表按用户首选项的顺序返回。 例如,在为美国英语设置的系统上, GetThreadPreferredUILanguages 返回的列表为 { “en-US”, “en” }。 这意味着:1) 美国英语(如果存在)。 2) 否则,请使用英语的任何区域变体,例如“en-GB”或纯“en”。
对于该列表中的每种语言,UI 代码按列表顺序查找其 xml:lang 属性完全匹配的 wcs:Text 元素。 使用第一个匹配版本。 如果没有版本匹配,则使用第一个 wcs:Text 元素。
内置配置文件
Windows Vista 附带的标准 WCS 配置文件(例如 sRGB.cdmp)具有与其他配置文件相同的可本地化属性。
标准 Windows 解决方案是将本地化的字符串放入 MUI DLL 中,并引用它们,如下所示:
<cdm:Description resourceId="mscms.dll,-101">
<wcs:Text xml:lang="en-US">Hello, world!</wcs:Text>
<cdm:Description>
在 Windows 系统上,将从相应本地化版本的 MUI 资源的资源 ID 101 中提取说明文本,以便mscms.dll。 非 Windows 系统将使用 wcs:Text 子元素,如上所述。
我们会在每个 WCS 配置文件架构的根元素上引入一个全局唯一的可选 ID 属性。 标准配置文件 wcsRGB.cdmp 可能如下所示:
<cdm:ColorDeviceModel
ID=http://schemas.microsoft.com/2005/02/color/profiles/wcsRGB.cdmp
... >
<cdm:Description>
<wcs:Text xml:lang="en-US">Hello.</wcs:Text>
<wcs:Text xml:lang="fr-FR">Bonjour.</wcs:Text>
</cdm:Description>
...
</cdm:ColorDeviceModel>
对于随窗口提供的 WCS 颜色配置文件,Color CPL 显示来自资源的描述性信息,而不是配置文件中的 wcs:Text 元素。 这允许 Windows 以所有受支持的语言显示这些配置文件的本地化信息,而无需配置文件本身包含所有语言的描述性信息。
相关主题