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”...
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,...
3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats>...
3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats> <up>Is</up> <doc>Fine</doc> </root> Schema starter: <xsd:schema xmlns:xsd=""> <xsd:element name="root" type="rootType" /> <xsd:complexType name="rootType">     <xsd:sequence>       <xsd:element name="" type="" minOccurs="1" />       <xsd:element name="” type="" minOccurs="1" />       <xsd:element name="" type="" minOccurs="1" />     </xsd:sequence> </xsd:complexType> </xsd:schema> 3.2. Use your schema to validate the XML file.                     3.2.1. You can use Visual Studio or online utilities to apply the schema to the XML file....
Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a...
Design c++ program so that it correctly meets the program specifications given below.   Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT