Good morning,
I am trying to understand how attribute "derivedBy" in a XML schema works to build a list of basic types, for instance a string.
I searched for working examples. There are not many examples online, but I found this one:
https://www.brainbell.com/tutors/XML/XML_Book_B/Viewing_Schemas_in_XML_Tools.htm
Unfortunately, I could not make it work in two different files (.xml and xsd) and I need a working example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="StringList" base="xs:string" derivedBy="list" />
<xs:complexType name="root">
<xs:sequence>
<xs:element type="StringList" name="myListElement"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="root" type="root"></xs:element>
</xs:schema>
And the xml document I'm trying to validate is:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="derivedBy.xsd">
<myListElement>
a b c
</myListElement>
</root>
I'm trying to validate it with XML Tools plugin in Notepad++, but I'm getting an error I don't knwo how to fix:
Unable to parse schema file.
Parsing error at line 3:
Element '{http://www.w3.org/2001/XMLSchema}simpleType:The content is not valid. Expected is (annotation?, (restriction|list|union)).
What am I doing wrong?
Besides, as I don't find much information online about derivedBy="list", does it mean it's not longer in use?
Thank you in advance for your help.
question from:
https://stackoverflow.com/questions/65899304/derivedby-attribute-in-xml-schema-to-create-a-list-of-basic-types 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…