Question

In: Computer Science

Create a schema file that captures the requirements for a <student> element> Here are the specifications...

Create a schema file that captures the requirements for a <student> element>

Here are the specifications for student:

3.1. A student must have a first name and last name.

3.2. A student may have a middle name, but it’s optional.

3.3. A student may have a home address, a work address, or both.

            3.3.1. Use a complex type to connect to a single schema definition for “address”

3.4. An address has: a street address, city, state, and zip code. Include the following limits:

3.4.1. Street address may have one or two entries

3.4.2. State must be two letters

3.4.3. Zipcode must be 5 or 9 digits
Online searches can help with regular expressions for this one!

Sample files:

<?xml version="1.0" encoding="utf-8"?>

<!--- Valid data -->

<student>

<first_name>Mani</first_name>

<middle_name>Rupee</middle_name>

<last_name>Patel</last_name>

<home_address>

    <street>2525 Longhorn Way</street>

    <street>Apartment 35</street>

    <city>Redmond</city>

    <state>WA</state>

    <zip>88899-3535</zip>

</home_address>

</student>

<?xml version="1.0" encoding="utf-8"?>

<!--- Valid data -->

<student>

<first_name>Michael</first_name>

<last_name>Hortensia</last_name>

<home_address>

    <street>Generic Technical Company</street>

    <street>1515 Longhorn Way</street>

    <city>Seattle</city>

    <state>WA</state>

    <zip>98585</zip>

</home_address>

<work_address>

    <street>346 3rd Street</street>

    <city>Olympia</city>

    <state>WA</state>

    <zip>98581</zip>

</work_address>

</student>

<?xml version="1.0" encoding="utf-8"?>

<student>

<!--- Invalid data -->

<first_name>Mani</first_name>

<work_address>

    <street>3535 Too many streets</street>

    <street>Rockford Way</street>

    <street>MacIntyre Lane</street>

    <city>Redmond</city>

    <state>WART</state>

    <zip>88899-35358</zip>

</work_address>

</student>

Solutions

Expert Solution

Below is the student schema with all the mentioned contraint applied-

===================== XML SCHEMA START===================================

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

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

<!-- Below 'required' constraint is used to make element first_name and last_name mandatory field -->
<xs:element name="first_name" type="xs:string" use="required"/>
<xs:element name="middle_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string" use="required"/>

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

<!-- Below 'maxOccurs' constraint is used to make element street to occur minimum 1 or maximum 2 times -->
<xs:element name="street" type="xs:string" maxOccurs="2"/>
<xs:element name="city" type="xs:string"/>

<!-- To apply constraint on state for having only two letters , pattern is defined on element state below -->
<xs:element name="state" type="xs:string">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z]{2,2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

<!-- To apply constraint on zipcode for having integers of length 5 or 9 digits only , pattern is defined on element zip below -->
<xs:element name="zip">
<xs:simpleType>
<xs:restriction base="xsd:integer">
<xs:pattern value="(\d{5}(\d{9})?)"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<!-- All same constraints like home_address element also defined on element work_address below -->  

<xs:element name="work_address">
<xs:complexType>
<xs:sequence>
<xs:element name="street" type="xs:string" maxOccurs="2"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z]{2,2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="zip">
<xs:simpleType>
<xs:restriction base="xsd:integer">
<xs:pattern value="(\d{5}(\d{9})?)"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

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

</xs:schema>

===================== XML SCHEMA END ===================================

Please comment if any query.


Related Solutions

In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in...
In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in your new schema and populate with the supplied data. Tables do not have keys. Do not define them at this time. There are errors in the data population (INSERT) statements. It is your job to find the errors and correct them. This is important. You will need correct data for future exercises in this module. In the submission area, choose Write Submission and identify...
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
A database schema consisting of three relations STUDENT, COURSE, and STAFF is created as follows: CREATE...
A database schema consisting of three relations STUDENT, COURSE, and STAFF is created as follows: CREATE TABLE STUDENT (STU_ID CHAR(4), STUDENT_NAME CHAR(20), ADDRESS CHAR(20), BIRTHDATE DATE, GENDER CHAR(6)); CREATE TABLE COURSE (COURSE_ID CHAR(6), COURSE_TITLE CHAR(20), STAFF_ID CHAR(3), SECTION NUMBER(2)); CREATE TABLE STAFF (STAFF_ID CHAR(3), STAFF_NAME CHAR(20), GENDER CHAR(6), DEPARTMENT CHAR(20), BOSS_ID CHAR(3) SALARY NUMBER(8,2)); Write down SQL statement for each query below: 1) Find out the information of staff members who are female and earn either below $5,000 or above...
We use the WMCRM database and here is the summary of the database schema (where schema...
We use the WMCRM database and here is the summary of the database schema (where schema is used in its meaning of a summary of the database structure): VEHICLE (InventoryID, Model, VIN) SALESPERSON (NickName, LastName, FirstName, HireDate, WageRate, CommissionRate, OfficePhone, EmailAddress, InventoryID) CUSTOMER (CustomerID, LastName, FirstName, Address, City, State, ZIP, EmailAddress, NickName) PHONE_NUMBER (CustomerID, PhoneNumber, PhoneType) CONTACT(ContactID, CustomerID,ContactDate,ContactType,Remarks) Where InventoryID in SALESPERSON must exist in InventoryID in VEHICLE NickName in CUSTOMER must exist in NickName in SALESPERSON CustomerID in PHONE_NUMBER...
The requirements for this program are as follows: Create a header file named “Employee.h”. Inside this...
The requirements for this program are as follows: Create a header file named “Employee.h”. Inside this header file, declare an Employee class with the following features: Private members a std::string for the employee’s first name a std::string for the employee’s last name an unsigned int for the employee’s identification number a std::string for the city in which the employee works Public members A constructor that takes no arguments A constructor that takes two arguments, representing: the employee’s first name the...
Create an entity relationship diagram to describe the data requirements of the system. Here is how...
Create an entity relationship diagram to describe the data requirements of the system. Here is how some of the business is described: - In a real estate transaction, there is a buyer, a seller, a property, a purchase agreement and a real estate agent - A seller may have one or more properties to sell - A buyer wants to buy only one property - A purchase agreement is between the seller and the buyer, and only for one property...
1. [100] Create a C program for a number guessing game. Here are the requirements: a....
1. [100] Create a C program for a number guessing game. Here are the requirements: a. Your program generates a random number between -100 and 100 and keeps asking the user to guess the number until the user guesses it correctly. Your random number generator should be implemented as a C function which takes min and max values as input parameters and returns a random number between those values including the min and the max. b. If the user guesses...
Create a python application that inputs, processes and stores student data. Specifications: 1. Your application should...
Create a python application that inputs, processes and stores student data. Specifications: 1. Your application should be able to accept Student data from the user and add the information in a file type of your choice. 2. your application is a menu driven and allow the user to choose from the following menu Menu: 1 – Add students to file 2 – print all the student information 3 – print specific student information using studentID 4 – Exit the program...
Create a class Student (in the separate c# file but in the project’s source files folder)...
Create a class Student (in the separate c# file but in the project’s source files folder) with those attributes (i.e. instance variables): Student Attribute Data type (student) id String firstName String lastName String courses Array of Course objects Student class must have 2 constructors: one default (without parameters), another with 4 parameters (for setting the instance variables listed in the above table) In addition Student class must have setter and getter methods for the 4 instance variables, and getGPA method...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various entities recorded by a furniture company.   Write CREATE TABLE statements for the following four relation schemas. Define all necessary attributes, domains, and primary and foreign keys. Customer(CustomerID, Name, Address) FullOrder(OrderID, OrderDate, CustomerID) Request(OrderID, ProductID, Quantity) Product(ProductID, Description, Finish, Price) You should assume the following: Each CustomerID is a number with at most three digits, each OrderID is a number with at most five digits,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT