XML Schema unordered list
Steve Beech <[email protected]> Thu, 14 Aug 2003 15:04:31 +0100
| Newsgroups | gmane.comp.java.sun.xml.general |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C3626C.FBD92D50
Content-Type: text/plain;
charset="big5"
Hi All,
I have an XML doc which has some optional elements. I need to create a
schema to validate this document.
My XML dox example is shown below:
<resource>
<subject>economics</subject>
<name>econores</name>
<summary>an economics resource</summary>
<location>somewhere</location>
<resource_type>sometype</resource_type>
<keyword>economics</keyword>
<icon>no icon</icon>
<admin>xy54w</admin>
<result>x</result>
<partialResults>hhhhhh</partialResults>
<diagnostic xmlns=" http://www.some.co.uk/diagnostic
<http://www.some.co.uk/diagnostic> ">Theres something wrong</diagnostic>
</resource>
What I need to allow is any of the first 9 elements to appear 0 to many
times in any order, and the final element to appear 0 or 1 times, but always
at the end.
I've tried the following schema definition, but this just insists that all
elements are present. Can anyone help me ??!?!
<xs:element name="resource">
<xs:complexType>
<xs:sequence maxOccurs="1" minOccurs="0">
<xs:sequence maxOccurs="unbounded" minOccurs="1">
<xs:choice>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="subject"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="name"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
name="summary" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="location"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="resource_type"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="keyword"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="icon"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="admin"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="result"/>
<xs:element maxOccurs="1" minOccurs="0"
ref="partialResults"/>
</xs:choice>
</xs:sequence>
<xs:any namespace=" http://www.some.co.uk/diagnostic"/
<http://www.some.co.uk/diagnostic> >
</xs:sequence>
<xs:anyAttribute namespace="
http://www.angel.ac.uk/diagnostic"/ <http://www.angel.ac.uk/diagnostic> >
</xs:complexType>
</xs:element>
Thanks in advance.
Steve
-----------------------------------------------------
xml-interest: A list for discussing XML technologies in the Java Platform.
To post, mailto:[email protected]
Archives at: http://archives.java.sun.com/xml-interest.html
To unsubscribe, mailto:[email protected] the following message;
signoff xml-interest.
------_=_NextPart_001_01C3626C.FBD92D50
Content-Type: text/html;
charset="big5"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>Hi
All,</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>I have
an XML doc which has some optional elements. I need to create a schema to
validate this document.</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>My XML
dox example is shown below:</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2><resource></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff
size=2><subject>economics</subject></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><name>econores</name></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><summary>an economics
resource</summary></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff
size=2><location>somewhere</location></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff
size=2><resource_type>sometype</resource_type></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2>
<keyword>economics</keyword></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><icon>no icon</icon></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><admin>xy54w</admin></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><result>x</result></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff
size=2><partialResults>hhhhhh</partialResults></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003> <FONT face=Arial
color=#0000ff size=2><diagnostic xmlns="<A
href="http://www.some.co.uk/diagnostic">http://www.some.co.uk/diagnostic</A>">Theres
something wrong</diagnostic></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></resource></FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>What I
need to allow is any of the first 9 elements to appear 0 to many times in any
order, and the final element to appear 0 or 1 times, but always at the
end.</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>I've
tried the following schema definition, but this just insists that all elements
are present. Can anyone help me ??!?!</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2> <xs:element
name="resource"><BR>
<xs:complexType><BR>
<xs:sequence maxOccurs="1"
minOccurs="0"><BR>
<xs:sequence maxOccurs="unbounded"
minOccurs="1"><BR>
<xs:choice><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="subject"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="name"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0" name="summary"
type="xs:string"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="location"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="resource_type"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="keyword"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="icon"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="admin"/><BR>
<xs:element maxOccurs="unbounded" minOccurs="0"
ref="result"/><BR>
<xs:element maxOccurs="1" minOccurs="0"
ref="partialResults"/><BR>
</xs:choice><BR>
</xs:sequence><BR>
<xs:any namespace="<A
href='http://www.some.co.uk/diagnostic"/'>http://www.some.co.uk/diagnostic"/</A>><BR>
</xs:sequence><BR>
<xs:anyAttribute namespace="<A
href='http://www.angel.ac.uk/diagnostic"/'>http://www.angel.ac.uk/diagnostic"/</A>><BR>
</xs:complexType><BR> </xs:element><BR>
</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff size=2>Thanks
in advance.</FONT></SPAN></DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=002040214-14082003><FONT face=Arial color=#0000ff
size=2>Steve</FONT></SPAN></DIV></BODY></HTML>
-----------------------------------------------------
xml-interest: A list for discussing XML technologies in the Java Platform.
To post, mailto:[email protected]
Archives at: http://archives.java.sun.com/xml-interest.html
To unsubscribe, mailto:[email protected] the following message;
signoff xml-interest.
------_=_NextPart_001_01C3626C.FBD92D50--