Jump to content

shiyanderu

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by shiyanderu

  1. <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string" maxOccurs="unbounded"/> <xs:element name="from" type="xs:string"/> <xs:element name="subject"> <xs:complexType> <xs:attribute name="date" type="xs:date" use="required" form="qualified"/> </xs:complexType> </xs:element> <xs:element name="body"> <xs:complexType> <xs:sequence> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
  2. Hello again,I have a custom date attribute that I'd like to add as "required" on an element. I would like this date attribute to follow the mm/dd/yyyy format, and so I would like to put restrictions on it.W3Schools has mentioned that restrictions can be added to both elements and attributes, but I have yet to see any example of a restriction being set on an attribute. If anyone could help me set a restriction on an attribute to conform to mm/dd/yyyy, I would be most grateful.Code's below :-)<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string" maxOccurs="unbounded"/> <xs:element name="from" type="xs:string"/> <xs:element name="subject"> <xs:complexType> <xs:attribute name="date" type="xs:date" use="required" form="qualified"/> </xs:complexType> </xs:element> <xs:element name="body"> <xs:complexType> <xs:sequence> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
  3. Hi y'all,I'm a little new to XSDs and XML, so please bare with me :-)I have the following schema, where I have a note that can have a body sub-element. The body can contain any arbitrary markup from any XML namespace. So I have: <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string" maxOccurs="unbounded"/> <xs:element name="from" type="xs:string"/> <xs:element name="subject"> <xs:complexType> <xs:attribute name="date" type="xs:date" use="required" form="qualified"/> </xs:complexType> </xs:element> <xs:element name="body"> <xs:complexType> <xs:sequence> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema> The problem is, I now want to make an XML instance based on this schema in the following way: <?xml version="1.0" encoding="UTF-8"?><note xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="\\svpfile03\tsxc010\DO_NOT_DELETE\Desktop\note.xsd"xmlns:xs="http://www.w3.org/2001/XMLSchema"> <to> someone </to> <from/> <subject date="2006-02-15"/> <body> Meeting at 5pm </body></note> The problem is that XmlSpy seems to keep complaining that: Text 'Meeting at 5pm' is not allowed for element <body>. The element declaration's content type is 'element-only'.I tried instead putting in an xs:string element and put the text in there, but then it complained that:While validating against complex type '{anonymous}', element <xs:string> matched wildcard {##any} but no element declaration was found.Anyone know how I can make the <body> element have <any> sub-elements but also be able to handle a text field? Any help would be appreciated. Many thanks!
×
×
  • Create New...