了解 XSD 中的 GUID 模式定义
Understanding a GUID pattern definition in XSD
我最近 found 遵循定义 GUID 的模式定义:
<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}\}"/>
我需要一些帮助来理解这一点。这是我的问题:
/ not at the ending, at the begin of the value attribute.
- between the letter definition(ex:[a-fA-F0-9]).
w3 网站上没有解释。
第 1 点:
/ not at the ending, at the begin of the value attribute.
您显示的 xs:pattern
中唯一的 /
是 empty-element tag 的 XML 语法的一部分。这是一个正常的 XML 构造,与为 GUID 定义的模式无关;它可以等效地用显式结束标记编写:
<xs:pattern value="..."></xs:pattern>
点 2:
- between the letter definition(ex:[a-fA-F0-9]).
[]
中的-
表示正则表达式中的范围。因此,[a-f]
允许从 a
到 f
的所有字母,包括在内。整个[a-fA-F0-9]
允许所有十六进制数字。
还有一些你没问的:
\{
或 \}
表示需要文字 {
或 }
。
{8}
表示前面的8个子模式(十六进制数字)是
预期。
[]
之外的 -
表示需要文字 -
。
所以,这个模式一起匹配包裹在 { }
中的 GUID,例如:
{90B1532C-3611-48D8-BBAB-D44855FA73BD}
我最近 found 遵循定义 GUID 的模式定义:
<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}\}"/>
我需要一些帮助来理解这一点。这是我的问题:
/ not at the ending, at the begin of the value attribute.
- between the letter definition(ex:[a-fA-F0-9]).
w3 网站上没有解释。
第 1 点:
/ not at the ending, at the begin of the value attribute.
您显示的 xs:pattern
中唯一的 /
是 empty-element tag 的 XML 语法的一部分。这是一个正常的 XML 构造,与为 GUID 定义的模式无关;它可以等效地用显式结束标记编写:
<xs:pattern value="..."></xs:pattern>
点 2:
- between the letter definition(ex:[a-fA-F0-9]).
[]
中的-
表示正则表达式中的范围。因此,[a-f]
允许从 a
到 f
的所有字母,包括在内。整个[a-fA-F0-9]
允许所有十六进制数字。
还有一些你没问的:
\{
或\}
表示需要文字{
或}
。{8}
表示前面的8个子模式(十六进制数字)是 预期。[]
之外的-
表示需要文字-
。
所以,这个模式一起匹配包裹在 { }
中的 GUID,例如:
{90B1532C-3611-48D8-BBAB-D44855FA73BD}