0
votes

I am trying to build XSD schema for my XML doc. It's very simple but even though I'm stuck writing it. Debuger says that on the 5 line (<xs:element name="database">) and 15 line (<xs:element name="log">) xs:element is not supported in this context. What am I missing?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="config">
        <xs:complexType>
            <xs:element name="database">
                <xs:complexType>
                    <xs:element name="SqlServerName" type="xs:string" />
                    <xs:element name="DbInstance" type="xs:string"/>
                    <xs:element name="DbPort" type="xs:positiveInteger" />
                    <xs:element name="UseTrustedConnection" type="xs:bolean" />
                    <xs:element name="DbUser" type="xs:string" />
                    <xs:element name="DbPassword" type="xs:string" />
                </xs:complexType>
            </xs:element>
        <xs:element name="log">
            <xs:complexType>
                <xs:element name="LogFile" type="xs:string" />
            </xs:complexType>
        </xs:element>
      </xs:complexType>
    </xs:element>
</xs:schema>

XML should look like follows:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="config.xsd">
    <database>
        <SqlServerName>MyServer</SqlServerName>
        <DbInstance>SQLEXPRESS</DbInstance>
        <DbPort>1433</DbPort>
        <UseTrustedConnection>true</UseTrustedConnection>
    <DbUser></DbUser>
        <DbPassword></DbPassword>
    </database>
    <log>
        <LogFile>error.log</LogFile>
    </log>
</config>

TY.

1
after the xs:complexType you need to specify if it is a xs:sequence, xs:all or xs:choice. And the xs:bolean should be xs:booleanmartijn

1 Answers

0
votes

Martijn comment to my question contains proper answer and additional hint on error that I made. Thanks mate.

after the xs:complexType you need to specify if it is a xs:sequence, xs:all or xs:choice. And the xs:bolean should be xs:boolean