[英]Element with attributes with the same name from two namespaces
I am working on an XSD file including elemets such as: 我正在处理一个包含如下元素的XSD文件:
<xs:element name="group">
<xs:complexType>
<xs:attribute name="role" type="xs:string"/>
<xs:attribute ref="xlink:role"/>
</xs:complexType>
</xs:element>
Where no type is defined for the 'role' Attribute in the xlink namespace. 在xlink命名空间中未为'role'属性定义类型的地方。 How would an XML with this Schema look like?
具有此架构的XML的外观如何? How should I know which attribute 'role' is meant in the XML?
我怎么知道XML中的“角色”是什么意思? What is the purpose of making such attributes with the same name?
使这些属性具有相同的名称的目的是什么?
This is how XML may look like: XML可能是这样的:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<group xmlns:xlink="http://www.w3.org/1999/xlink" role="role1" xlink:role="http://uri1"/>
A name, as you see in the XSD, is qualified; 正如您在XSD中看到的那样,名称是合格的。 attributes, in your case - or at least for the test XSD I've used - could also be qualified or not.
在您的情况下-或至少对于我使用的测试XSD-属性也可以是合格的或不合格的。 By virtue of being qualified, { http://www.w3.org/1999/xlink }role is therefore different than {}role.
{ http://www.w3.org/1999/xlink }角色因此具有资格,因此与{} role不同。
As to the purpose... why do we have homonyms? 至于目的……为什么我们有谐音? I am sure that through the use of synonyms one may improve the quality of a contract, particularly when dealing with people not fond of XML namespaces, or whatever... I would not comment for your particular case, since I wouldn't know if role is indeed a small price to pay, speaking about the confusion it created, vs. how well is entranced in the business vocabulary your XSD is maybe trying to capture/apply.
我敢肯定,通过使用同义词,可以提高合同的质量,特别是在与不喜欢XML名称空间的人打交道或其他情况下……我不会对您的特殊情况发表评论,因为我不知道是否谈到它所造成的混乱,以及XSD可能试图捕获/应用的业务词汇量,角色确实是一个很小的代价。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.