gpt4 book ai didi

.net - 是什么决定了 WCF WSDL 中 XML 属性的顺序?

转载 作者:行者123 更新时间:2023-12-05 07:54:32 30 4
gpt4 key购买 nike

之前也有人问过类似的问题,我的理解是XML或者schema中不能指​​定XML属性的顺序。但是,我想知道,WSDL 中的 XML 属性的顺序是由 WCF 随机生成的还是遵循某些规则。

例如,在某个阶段,我们在生成的 WSDL 中有以下(部分)XML 标记。

<xs:element maxOccurs="unbounded" minOccurs="0"

现在再次生成它就变成了

<xs:element minOccurs="0" maxOccurs="unbounded"

交换了最小值和最大值的顺序。

另一个例子:

<wsdl:port binding="tns:BasicHttpBinding_IReferenceDataBusinessService" name="BasicHttpBinding_IReferenceDataBusinessService">

成为

<wsdl:port name="BasicHttpBinding_IReferenceDataBusinessService" binding="tns:BasicHttpBinding_IReferenceDataBusinessService">

只是想知道是什么决定了 WCF 中的此类订单?是否可以调整流程以保持相同的顺序,从而更轻松地比较两个 WSDL 文件?

谢谢。

最佳答案

您承认属性顺序无关紧要,然后继续暗示您无论如何都希望按照属性顺序行事。根据定义,它是一个实现细节。依赖任何给定的属性排序,后果自负。

此外,属性顺序只是按词法比较 XML 文档的众多障碍之一。在开始这样的努力之前,请熟悉 Canonical XML Version 1.1 涵盖的所有内容。 .总结如下:

The canonical form of an XML document is physical representation of the document produced by the method described in this specification. The changes are summarized in the following list:

  • The document is encoded in UTF-8
  • Line breaks normalized to #xA on input, before parsing
  • Attribute values are normalized, as if by a validating processor
  • Character and parsed entity references are replaced
  • CDATA sections are replaced with their character content
  • The XML declaration and document type declaration are removed
  • Empty elements are converted to start-end tag pairs
  • Whitespace outside of the document element and within start and end tags is normalized
  • All whitespace in character content is retained (excluding characters removed during line feed normalization)
  • Attribute value delimiters are set to quotation marks (double quotes)
  • Special characters in attribute values and character content are replaced by character references
  • Superfluous namespace declarations are removed from each element
  • Default attributes are added to each element
  • Fixup of xml:base attributes [C14N-Issues] is performed
  • Lexicographic order is imposed on the namespace declarations and attributes of each element

健壮的代码不依赖于实现在任何这些维度上的意外(非必要)属性。

关于.net - 是什么决定了 WCF WSDL 中 XML 属性的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31195817/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com