rspec/rules/S3851/xml/rule.adoc

48 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
The ``++<xs:all>++`` group element isn't supported universally among web service stacks. That means that if you use it, you may end up failing to transmit your data (in the resulting XML files) to systems that can't process it. For that reason, ``++<xs:sequence>++`` should be used instead. The only constraint imposed by the use of an ``++<xs:sequence>++`` is the order it imposes, but that is usually a benefit for human readers.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,xml]
2021-04-28 16:49:39 +02:00
----
<xs:complexType name="fruitType">
<xs:all> <!-- Noncompliant -->
<xs:element name="name" type="xs:string"/>
<xs:element name="color" type="xs:string"/>
</xs:all>
</xs:complexType>
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,xml]
2021-04-28 16:49:39 +02:00
----
<xs:complexType name="fruitType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="color" type="xs:string"/>
</xs:sequence>
</xs:complexType>
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use a "sequence" here instead.
=== Highlighting
``++xs:all++``
endif::env-github,rspecator-view[]