Xsd value: simpleContent

I just want to know what and when:

<xsd:simpleContent>
...
</xsd:simpleContent>

.

+6
source share
4 answers

As Jordan said, it allows you to extend complexType, for example:

  <xsd:complexType name="SizeType"> <xsd:simpleContent> <xsd:extension base="xsd:integer"> <xsd:attribute name="system" type="xsd:token"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> 

I suggest looking at these examples, they are very useful to me:

http://www.datypic.com/books/defxmlschema/examples.html

0
source

<xsd:simpleContent> used when you have an element that can contain structural markup (= complex type) and the element is not allowed to contain child elements. In other words, the content type of the elements allows only attributes and text content. Example: <foo bar="baz">foobar</foo> is an element defined using <xsd:complexType> and <xsd:simpleContent> .

It is true that using <xsd:simpleContent> involves creating a type either as a constraint or as an extension, but in fact all complex types are implicitly either constraints or extensions. An extension or restriction simply does not need to be explicitly written in the code, because there is an abbreviated syntax that allows you to leave them.

+6
source

If you need an element whose value is a date and that takes attributes, for example:

 <event type="birthday">2011-07-17</event> 

then you need a complex type with simple content (CT-SC). It is defined by using the content type - xs: date - and expanding it with an attribute definition for the type attribute.

+4
source

This basically allows you to extend the complexType element. If you have a β€œdecimal” complexType, you can expand it with simpleContent to be a β€œcurrency” type by adding a currency sign, such as $ or €, and a code such as USD or EUR. 4.75 as a decimal digit will become something like $ 4.75 USD with these extensions.

Microsoft article is good for basic understanding: http://msdn.microsoft.com/en-us/library/ms256106.aspx

+1
source

Source: https://habr.com/ru/post/892558/


All Articles