XML课本程序代码-第四章课后习题

  • 格式:doc
  • 大小:112.00 KB
  • 文档页数:6

test1.XML<?xml version="1.0" encoding="UTF-8"?><orderxmlns:xsi="/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="test1.xsd"><order_id>12345678</order_id><amount>105.99</amount><credit_card><card_type>AMEX</card_type><card_num>4111*******1111</card_num></credit_card><date>02-03-2009</date><customer><name>Jonh Smith</name><phone phone_type="home">(416)416-3234</phone> </customer><shipping_addr><street>5050 Maple Street</street><city>Toronto</city><province>Ontario</province><country>Canada</country></shipping_addr><comment>The order system is for Canadian customers only.</comment></order>test1.xsd<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="/2001/XMLSchema"> <xs:element name="order"><xs:complexType><xs:sequence><xs:element name="order_id" type="xs:string"/><xs:element name="amount" type="xs:string"/><xs:element ref="credit_card"/><xs:element name="date" type="xs:string"/><xs:element ref="customer"/><xs:element ref="shipping_addr"/><xs:element name="comment" type="xs:string"/></xs:sequence></xs:complexType></xs:element><xs:complexType name="credit_card_type"><xs:sequence><xs:element name="card_type" type="credit_card2"/><xs:element name="card_num" type="xs:string"/></xs:sequence></xs:complexType><xs:element name="credit_card" type="credit_card_type"/><xs:complexType name="customer"><xs:sequence><xs:element name="name" type="xs:string"/><xs:element name="phone"><xs:complexType><xs:simpleContent><xs:extension base="phone_type1"><xs:attribute name="phone_type" type="xs:string" use="required"/></xs:extension></xs:simpleContent></xs:complexType></xs:element></xs:sequence></xs:complexType><xs:element name="customer" type="customer"/><xs:complexType name="address"><xs:sequence><xs:element name="street" type="xs:string"/><xs:element name="city" type="xs:string"/><xs:element name="province" type="xs:string"/><xs:element name="country" type="xs:string"/> </xs:sequence></xs:complexType><xs:element name="shipping_addr" type="address"/><xs:simpleType name="credit_card2"><xs:restriction base="xs:string"><xs:enumeration value="Visa"/><xs:enumeration value="MasterCard"/><xs:enumeration value="AMEX"/></xs:restriction></xs:simpleType><xs:simpleType name="phone_type1"><xs:restriction base="xs:string"><xs:pattern value="(\d{3})\d{3}-\d{4}"/> </xs:restriction></xs:simpleType></xs:schema>test2.XML<?xml version="1.0" encoding="UTF-8"?><order>xmlns:xsi="/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="test2.xsd"><order_id>12345678</order_id><amount>105.99</amount><credit_card>温碧泉<card_type>Visa</card_type><card_num>4111*******1111</card_num> </credit_card><date>02-03-2009</date><customer><name>Jonh Smith</name><phone phone_type="home">416-555-1234</phone> </customer><shipping_addr><street>5050 Maple Street</street><city>Toronto</city><province>Ontario</province><country>Canada</country></shipping_addr><comment>The order system is for Canadian customers only.</comment></order>test2.xsd<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="/2001/XMLSchema"><xs:element name="order"><xs:complexType><xs:sequence><xs:element name="order_id" type="xs:string"/><xs:element name="amount" type="xs:string"/><xs:element name="credit_card"><xs:complexType><xs:sequence><xs:element name="card_type"><xs:complexType><xs:simpleContent><xs:extension base="credit_card2"/></xs:simpleContent></xs:complexType></xs:element><xs:element name="card_num"/></xs:sequence></xs:complexType></xs:element><xs:element name="date" type="xs:string"/><xs:element ref="customer"/><xs:element name="billing_addr" type="address"/><xs:element ref="shipping_addr"/><xs:element name="comment" type="xs:string"/></xs:sequence></xs:complexType></xs:element><xs:complexType name="customer"><xs:sequence><xs:element name="name" type="xs:string"/><xs:element name="phone"><xs:complexType><xs:simpleContent><xs:extension base="xs:string"><xs:attribute name="phone_type" type="xs:string" use="required"/></xs:extension></xs:simpleContent></xs:complexType></xs:element></xs:sequence></xs:complexType><xs:element name="customer" type="customer"/><xs:complexType name="address"><xs:sequence><xs:element name="street" type="xs:string"/><xs:element name="city" type="xs:string"/><xs:element name="province" type="xs:string"/><xs:element name="country" type="xs:string"/></xs:sequence></xs:complexType><xs:simpleType name="credit_card2"><xs:restriction base="xs:string"><xs:enumeration value="Visa"/><xs:enumeration value="MasterCard"/><xs:enumeration value="AMEX"/></xs:restriction></xs:simpleType><xs:element name="shipping_addr" type="address"/></xs:schema>。