0

im currently learning XML and im having a lot difficulties to understand its syntax. Currently im trying to understand the global element feature..but im stuck on the example. the schema wont validate with the XML file. Just point out the errors if you can guys...thanks

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="FirstName" type="xs:string"/>
    <xs:element name="LastName" type="xs:string"/>
    <xs:element name="Salary" type="xs:integer"/> 
    <xs:element name="Employees">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="1" maxOccurs="unbounded" name="Employee">
                    <xs:complexType>
                        <xs:sequence>

                            <xs:element name="Name">
                                <xs:complexType>
                                    <xs:sequence>

                                        <xs:element ref="FirstName"/>
                                        <xs:element ref="LastName"/>

                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>

                            <xs:choice>
                                <xs:element>
                                    <xs:simpleType>
                                        <xs:restriction base="Salary">
                                            <xs:minInclusive value="10000"/>
                                            <xs:maxInclusive value="90000"/>
                                        </xs:restriction>
                                    </xs:simpleType>                         
                                </xs:element>
                                <xs:element name="Wage" type="xs:decimal"/>
                            </xs:choice>


                        </xs:sequence>
                    </xs:complexType>
                </xs:element>

            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
user2228135
  • 239
  • 6
  • 17
  • possible duplicate of [XML Schema (XSD) validation tool?](http://stackoverflow.com/questions/124865/xml-schema-xsd-validation-tool) – Alberto Jul 21 '14 at 07:31

1 Answers1

0

Here are your errors that the schema throws during validation using Xerces:

  • src-resolve: Cannot resolve the name 'Salary' to a(n) 'type definition' component.
  • cos-applicable-facets: Facet 'maxInclusive' is not allowed by type #AnonType_EmployeeEmployees.
  • src-element.2.1: : One of 'ref' or 'name' must be present in a local element declaration.

You can rewrite it to this:

<xs:element name="Salary">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="10000"/>
            <xs:maxInclusive value="90000"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>
insertusernamehere
  • 23,204
  • 9
  • 87
  • 126
  • thanks. got it. i was using a validator that was not displaying the errors. so i had no idea what was wrong with the code. guess, i hav to use a more advanced validator. – user2228135 Sep 17 '13 at 08:50