Jump to content

crr

Members
  • Posts

    4
  • Joined

  • Last visited

crr's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. crr

    schema help

    This is how I got it to work : <xsd:element name="jobs"> <xsd:complexType> <xsd:sequence> <xsd:element name="job" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="year" type="xsd:string"/> <xsd:element name="company" type="xsd:string"/> <xsd:element name="job_title" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType></xsd:element> Thanks
  2. I was able to do it this way...which i hope is right. <xsd:element name="phone"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:string" > <xsd:attribute name="area" type="xsd:string" /> </xsd:extension> </xsd:simpleContent></xsd:complexType></xsd:element>
  3. crr

    schema help

    Hi, For the following XML block i was able to write the xsd code correctly: ----------- <job><year>1990-1995</year><company>A1 University</company><job_title>Professor</job_title></job><job><year>1995-2010</year><company>A2 University</company><job_title>Head of Department</job_title></job><job><year>2011-Present</year><company>A3 University</company><job_title>Research</job_title></job> ------------ as: <xsd:complexType name="jobtype"> <xsd:sequence> <xsd:element name="year" type="xsd:string"/> <xsd:element name="company" type="xsd:string"/> <xsd:element name="job_title" type="xsd:string"/> </xsd:sequence></xsd:complexType> ---------------- However if I want to enclose the XML block inside another tag (jobs) I am lost, can someone please help: <jobs> <job><year>1990-1995</year><company>A1 University</company><job_title>Professor</job_title></job><job><year>1995-2010</year><company>A2 University</company><job_title>Head of Department</job_title></job><job><year>2011-Present</year><company>A3 University</company><job_title>Research</job_title></job> </jobs> Thanks very much for any assistance.
  4. I am new to writing schemas and I am trying to write a schema for the following xml file: <?xml version="1.0"?><resumexmlns="http://w3schools.com/res" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://w3schools.com/res rcopy.xsd" ><name> Jane </name><address><street> This is the street </street><city>xyz</city><state>CA</state><zipcode>11111</zipcode></address><phone area="650">000-2000</phone><comment>Thank you for reading </comment></resume> The xsd code I wrote is (rcopy.xsd) : ------------------------------------------ <?xml version="1.0" ?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"targetNamespace="http://w3schools.com/res"xmlns="http://w3schools.com/res" elementFormDefault="qualified"><xsd:element name="resume" /><xsd:element name="name" type="xsd:string"/><xsd:element name="address"><xsd:complexType><xsd:sequence><xsd:element name="street" type="xsd:string"/><xsd:element name="city" type="xsd:string"/><xsd:element name="state" type="xsd:string"/><xsd:element name="zip" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="phone"> <xsd:complexType> <xsd:sequence> <xsd:element name="phone" type="xsd:string" /> </xsd:sequence> <xsd:attribute name="area" type="xsd:string" /></xsd:complexType></xsd:element><xsd:element name="comment" type="xsd:string"/></xsd:schema> When trying to validate it with xmllint I am getting the following error: xmllint --noout --schema rcopy.xsd rcopy.xml rcopy.xml:16: element phone: Schemas validity error : Element '{http://w3schools.com/res}phone': Character content other than whitespace is not allowed because the content type is 'element-only'.rcopy.xml:16: element phone: Schemas validity error : Element '{http://w3schools.com/res}phone': Missing child element(s). Expected is ( {http://w3schools.com/res}phone ).rcopy.xml fails to validate Any help in correcting my problem will be helpful.. Thanks
×
×
  • Create New...