rspec/rules/S3852/xml/rule.adoc

43 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++ID++`` and ``++IDREF++`` are constructs inherited from DTDs, and they suffer from painful drawbacks, mainly:
* ``++ID++``s are too widely scoped: an ``++ID++`` must be unique in the XML document. This means that if an XML document contains ``++<Person>++`` elements and ``++<Dog>++`` elements, both with a "name" attribute of ``++type="xs:ID"++``, then two people can't have the same name. Neither can two dogs, or a person and a dog.
* IDs must comply with tight naming scheme. For example, "123" is not a valid value for an ID.
Instead, ``++KEY++`` and ``++KEYREF++`` should be used. And if you really need to insure uniqueness, use ``++xs:unique++`` to add a uniqueness constraint.
=== 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
----
ToDo
----
=== 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
----
ToDo
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use "(KEY|KEYREF)" instead.
=== Highlighting
``++ID=++``|``++IDREF=++``
endif::env-github,rspecator-view[]