I posted earlier and through help on here was able to get my xml and xsd files to validate against each other. My next step was to import into an access database, but I'm confused as the restrictions I had set in the XSD do not even work in Access. Any ideas on how to make the ranking system work, and also why many of the other restrictions do not work? Is this a bonehead question where the xsd only applies to when I write in data into my xml (it won't validate based on restrictions) but doesn't transfer into a database?
My code:
<CompanyList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ssiddi83_leads.xsd"> <Company ranking="1"> <CompanyName>CasesWorldwide</CompanyName> <CompanyID>00001</CompanyID> <City>Mississauga</City> <Province>Ontario</Province> <ContactName> <LastName>Soliman</LastName> <FirstName>Ahmed</FirstName> <PhoneNumber>6479202891</PhoneNumber> <ContactCompanyID>00001</ContactCompanyID> </ContactName> <NumberOfEmployees>4000</NumberOfEmployees> </Company> **<Company ranking="3">** (this should be third but appears second on the database) <CompanyName>AccesoriesForPhones</CompanyName> <CompanyID>00002</CompanyID> <City>London</City> <Province>Ontario</Province> <ContactName> <LastName>Cheque</LastName> <FirstName>Please</FirstName> <PhoneNumber>6479596859</PhoneNumber> <ContactCompanyID>00002</ContactCompanyID> </ContactName> <NumberOfEmployees>16000</NumberOfEmployees> </Company> **<Company ranking="2">** (should be second but appears third) <CompanyName>PhonesCanada</CompanyName> <CompanyID>00003</CompanyID> <City>Ottawa</City> <Province>Ontario</Province> <ContactName> <LastName>Jrudeau</LastName> <FirstName>Tustin</FirstName> <PhoneNumber>2189578456</PhoneNumber> <ContactCompanyID>00003</ContactCompanyID> </ContactName> <NumberOfEmployees>34000</NumberOfEmployees> </Company> </CompanyList> <?xml version="1.0"?> <!-- XSD schema for CS Assignment #3.xml --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="CompanyList"> <xsd:complexType> <xsd:sequence> <xsd:element name="Company"> <xsd:complexType> <xsd:sequence> <xsd:element name="CompanyName"> <xsd:simpleType> **<xsd:restriction base="xsd:string"> <xsd:minLength value="1"/> <xsd:pattern value=".*[^\s].*" />** (this seems to work, can't be empty) </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="CompanyID" type="xsd:integer"/> <xsd:element name="City" type="xsd:string" minOccurs="0"/> <xsd:element name="Province" type="xsd:string" minOccurs="0"/> **<xsd:element name="ContactName" minOccurs = "1" maxOccurs="5">** (can put in more than 5 codes in the database) <xsd:complexType> <xsd:sequence> <xsd:element name="LastName" type="xsd:string" minOccurs="1"/> <xsd:element name="FirstName" type="xsd:string" minOccurs="1"/> <xsd:element name="PhoneNumber" type="xsd:integer" minOccurs="1"/> <xsd:element name="ContactCompanyID" type="xsd:integer" minOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="NumberOfEmployees" type="xsd:integer" minOccurs="0"/> </xsd:sequence> <xsd:attribute name="ranking" type="xsd:integer" use="optional"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>
No comments:
Post a Comment