Software EngineeringToday we will be covering…XML - ElementsXML – valuesXML – minOccurs/maxOccursXML – max/min [II]XML – Attribute groupsXML Attribute groups [II]XML – Choice and SequenceXML – Choice and Sequence [II]XML - ConclusionNetwork basicsFirewallsNATSocketsSimple Client – Janak ParekhSimple Server – Janak ParekhMultithreaded ServerParse this Stream/FileConclusionSoftware EngineeringRecitation 2Suhit GuptaToday we will be covering…XML IISockets, Server – Client relationships, Servers capable of handling multiple clients.XML - ElementsElements are capable of taking on several values ––string boolean float double decimal timeInstant timePeriod month year century recurringDate recurringDay timeDuration recurringDuration binary uriReference ID IDREF ENTITY NOTATION language IDREFS ENTITIES NMTOKEN NMTOKENS Name QName NCName integer nonPositiveInteger negativeInteger long int short byte nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte positiveInteger date time–And on and on and on and on…..–Read the primer 0 for more and in depth informationXML – values<xsd:simpleType name="MyInteger" base="xsd:integer"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="99"/> </xsd:simpleType><xsd:simpleType name="Sku" base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:simpleType>XML – minOccurs/maxOccursAdding Attributes to the Inline Type Definition <xsd:element name="Item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="quantity"> <xsd:simpleType base="xsd:positiveInteger"> <xsd:maxExclusive value="100"/> </xsd:simpleType> </xsd:element> <xsd:element name="price" type="xsd:decimal"/> <xsd:element ref="comment" minOccurs="0"/><xsd:element name="shipDate" type="xsd:date" minOccurs='0'/> <xsd:attribute name="partNum" type="Sku"/> <xsd:attribute name="weight" type="xsd:decimal"/><xsd:attribute name="shipBy"> <xsd:simpleType base="string"> <xsd:enumeration value="air"/> <xsd:enumeration value="land"/> <xsd:enumeration value="any"/> </xsd:simpleType></xsd:attribute></xsd:complexType></xsd:element>XML – max/min [II]You can specify max and min valuesBy combining and nesting the various groups provided by XML Schema, and by setting the values of minOccurs and maxOccurs, it is possible to represent any content model expressible with an XML.XML – Attribute groupsAdding Attributes Using an Attribute Group <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="quantity"> <xsd:simpleType base="xsd:positiveInteger">....<xsd:attributeGroup name="ItemDelivery"> <xsd:attribute name="partNum" type="Sku"/> <xsd:attribute name="weight" type="xsd:decimal"/> <xsd:attribute name="shipBy"> <xsd:simpleType base="xsd:string"> <xsd:enumeration value="air"/> <xsd:enumeration value="land"/> <xsd:enumeration value="any"/> </xsd:simpleType> </xsd:attribute></xsd:attributeGroup>XML Attribute groups [II]Using an attribute group in this way can improve the readability of schema, and facilitates updating schema because an attribute group can be defined and edited in one place and referenced in multiple definitions and declarations. These characteristics of attribute groups make them similar to parameter entities in XMLXML – Choice and SequenceNested Choice and Sequence Groups<xsd:complexType name="PurchaseOrderType"> <xsd:choice> <xsd:group ref="shipAndBill" /> <xsd:element name="singleAddress" type="Address" /> </xsd:choice> <xsd:element ref="comment" minOccurs="0" /> <xsd:element name="items" type="Items" /> <xsd:attribute name="orderDate" type="xsd:date" /></xsd:complexType><xsd:group name="shipAndBill"> <xsd:sequence> <xsd:element name="shipTo" type="Address" /> <xsd:element name="billTo" type="Address" /> </xsd:sequence></xsd:group>XML – Choice and Sequence [II]A choice group element allows only one of its children to appear in an instance.Un-named groups of elements can be constrained so that only one of the elements may appear in an instance.Alternatively, they can also be defined, and along with elements in named groups, they can be constrained to appear in the same order (sequence) as they are declared.XML - ConclusionI think that should be it on XML.Any more info… read about it on the webXML Primer 0 - http://www.w3.org/TR/2000/WD-xmlschema-0-20000407/http://www.w3schools.comNetwork basicslink: connection between components, including wireless => point-to-point (modem), multiple access (Ethernet)router, switch: forward packetsnode: router (= intermediate system), host (= end system)clients: access resources and servicesservers: provide resources and services (may also be client)dumb terminal: no local processingFirewallscomputer between internal (“intranet”) and external network= policy-based packet filteringwatch single point rather than every PClimit in/out services, restrict incoming packetscan’t prevent people walking out with diskspacket filter: restrict IP addresses (address filtering), portsconnection filter: only allow packets belonging to authorized (TCP) connectionsencrypted tunnel: tunnel = layer same layer inside itself à virtual network: connectintranets across InternetNA(P)T: network address (and port) translator are not firewalls, but can prevent allincoming connectionsNATSocketsWhat are ports?What are sockets?What is the difference?Simple Client – Janak Parekhimport java.net.*;import java.io.*;public class client { public static void main(String[] args) { try { Socket s = new Socket("128.59.209.243",2099); BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter pw = new PrintWriter(s.getOutputStream()); /* The following comment does not work as intended--Java is too clever * about connections, so this line gets printed immediately */ // System.out.println("Connected to server, talking"); pw.println("Hello"); pw.flush(); // Now wait for something back String st = br.readLine(); System.out.println(st); // Clean up s.close(); } catch(Exception e) { e.printStackTrace(); } }}Simple Server –
View Full Document