Jade Posted June 30, 2017 Share Posted June 30, 2017 (edited) Error I receive while implementing this code: Exception: cvc-complex-type.2.4.a: Invalid content was found starting with element 'employee'. One of '{contractemployee}' is expected. What changes shall I make in my code to correctly implement the xml document from the given image Code: XML: <?xml version="1.0" encoding="UTF-8"?> <company> <companyname></companyname> <address></address> <department> <dname></dname> <deptphoneno></deptphoneno> <deptfaxno></deptfaxno> <deptemail></deptemail> <employee> <empid></empid> <ename></ename> <emailid></emailid> <phoneno></phoneno> </employee> <contractemployee> <name></name> <phoneno></phoneno> </contractemployee> </department> </company> XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="catalog"> <xsd:complexType> <xsd:sequence> <xsd:element name="product" maxOccurs="unbounded" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:element name="productname" type="xsd:string"></xsd:element> <xsd:element name="storagenumber" type="xsd:short"></xsd:element> <xsd:element name="dimension"> <xsd:complexType> <xsd:sequence> <xsd:element name="width" type="xsd:byte"></xsd:element> <xsd:element name="heigth" type="xsd:string"></xsd:element> <xsd:element name="depth" type="xsd:byte" minOccurs="0"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="description" type="xsd:string"></xsd:element> <xsd:element name="supplier" type="xsd:string" maxOccurs="unbounded" minOccurs="0"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Edited June 30, 2017 by Jade Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2017 Share Posted June 30, 2017 I don't see any errors in that XML code. Link to comment Share on other sites More sharing options...
Jade Posted June 30, 2017 Author Share Posted June 30, 2017 53 minutes ago, justsomeguy said: I don't see any errors in that XML code. Sorry the code was incomplete Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2017 Share Posted June 30, 2017 Is that the right XSD? It's talking about catalog, product, etc. Link to comment Share on other sites More sharing options...
Smruti Khobragade Posted February 25, 2020 Share Posted February 25, 2020 I dont know much about xml but i observed in ur xml code u closed the employee tag in between when u should end it after closing contractemployee. Link to comment Share on other sites More sharing options...
Ingolme Posted February 29, 2020 Share Posted February 29, 2020 Please do not reply to old topics. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now