G
G
Gluck Virtualen2017-03-08 11:20:25
XSD
Gluck Virtualen, 2017-03-08 11:20:25

How to indicate the mandatory nature of a separate element in an XSD schema?

I broke my brain...
Given: xml documents.
Task: write XSD schemas for them.

<?xml version="1.0" encoding="UTF-8" ?>
  <form>
    <id>обязателен</id>
    <deliveryMethod>обязателен</deliveryMethod>
    <date></date>
    <sum></sum>
  </form>

It is possible to set it as mandatory through the use attribute and property:
<xs:attribute name="r" use="required" />
But then this attribute will appear in the resulting XML, which is not allowed:
<id use="required">обязателен</id>
No information was found on this feature. It turns out that these schemes are useless if the most important thing cannot be indicated in them.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gluck Virtualen, 2017-03-09
@gluck59

The answer to the question is found here .
The problem is solved through the ass: you need to set the optional NOT mandatory :) elements by setting the parameters minOccurs=0 and maxOccurs=1.
The rest of the elements are considered required by default.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question