Loading ...
Sorry, an error occurred while loading the content.

Re: Schemas: update

Expand Messages
  • Dino Morelli <dino.morelli@snet.net>
    ... isn t permitted inside an element, which is what allows the elements to be unordered. If the order of all elements in were forced,
    Message 1 of 10 , Jan 26, 2003
    • 0 Attachment
      --- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
      > I've seen this style of structure modeled as a repeating choice in
      > XSD.
      >

      <choice> isn't permitted inside an <all> element, which is what allows the elements to be unordered. If the order of all elements in <channel> were forced, then a <choice> would work. But looking at both the RSS spec and some RSS XML documents seems to show that the order is expected to be arbitrary.
    • Simon Fell
      ... you have a sequence containing a repeating choice of all the elements, this give you what you re looking for. Cheers Simon
      Message 2 of 10 , Jan 26, 2003
      • 0 Attachment
        On Sun, 26 Jan 2003 21:50:42 -0000, in szf you wrote:

        >--- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
        >> I've seen this style of structure modeled as a repeating choice in
        >> XSD.
        >>
        >
        ><choice> isn't permitted inside an <all> element, which is what allows the elements to be unordered. If the order of all elements in <channel> were forced, then a <choice> would work. But looking at both the RSS spec and some RSS XML documents seems to show that the order is expected to be arbitrary.

        you have a sequence containing a repeating choice of all the elements,
        this give you what you're looking for.

        Cheers
        Simon
      • Dino Morelli <dino.morelli@snet.net>
        ... In doing so, the forces the children to be in that specific order. The RSS document I ve been using as an example (yesterday s Scripting News)
        Message 3 of 10 , Jan 26, 2003
        • 0 Attachment
          --- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
          > On Sun, 26 Jan 2003 21:50:42 -0000, in szf you wrote:
          >
          > >--- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
          > >> I've seen this style of structure modeled as a repeating choice in
          > >> XSD.
          > >>
          > >
          > ><choice> isn't permitted inside an <all> element, which is what allows the elements to be unordered. If the order of all elements in <channel> were forced, then a <choice> would work. But looking at both the RSS spec and some RSS XML documents seems to show that the order is expected to be arbitrary.
          >
          > you have a sequence containing a repeating choice of all the elements,
          > this give you what you're looking for.
          >

          In doing so, the <sequence> forces the children to be in that specific order. The RSS document I've been using as an example (yesterday's Scripting News) doesn't seem to have the <channel> child elements in any particular order, nor is it mandated by the spec. <sequence> can't be used that way, it won't validate unless the order is specific.

          Only <all> can be used to make an arbitrary child order and <all> can't take any elements other than <element>. Can't use <choice> in it.
        • Simon Fell
          ... the sequence only contains the choice, the choice is set to have maxOccurs= unbounded , so that in effect you end up with any number of elements from
          Message 4 of 10 , Jan 26, 2003
          • 0 Attachment
            On Sun, 26 Jan 2003 22:09:20 -0000, in szf you wrote:

            >--- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
            >> On Sun, 26 Jan 2003 21:50:42 -0000, in szf you wrote:
            >>
            >> >--- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
            >> >> I've seen this style of structure modeled as a repeating choice in
            >> >> XSD.
            >> >>
            >> >
            >> ><choice> isn't permitted inside an <all> element, which is what allows the elements to be unordered. If the order of all elements in <channel> were forced, then a <choice> would work. But looking at both the RSS spec and some RSS XML documents seems to show that the order is expected to be arbitrary.
            >>
            >> you have a sequence containing a repeating choice of all the elements,
            >> this give you what you're looking for.
            >>
            >
            >In doing so, the <sequence> forces the children to be in that specific order. The RSS document I've been using as an example (yesterday's Scripting News) doesn't seem to have the <channel> child elements in any particular order, nor is it mandated by the spec. <sequence> can't be used that way, it won't validate unless the order is specific.
            >
            >Only <all> can be used to make an arbitrary child order and <all> can't take any elements other than <element>. Can't use <choice> in it.

            the sequence only contains the choice, the choice is set to have
            maxOccurs="unbounded", so that in effect you end up with any number of
            elements from within the choice. I'm obviously not explaining this
            very well, i'll post a sample (after the game, go Raiders!)

            Cheers
            Simon
          • Simon Fell
            ... Given this schema
            Message 5 of 10 , Jan 26, 2003
            • 0 Attachment
              On Sun, 26 Jan 2003 14:58:57 -0800, in szf you wrote:

              >>In doing so, the <sequence> forces the children to be in that specific order. The RSS document I've been using as an example (yesterday's Scripting News) doesn't seem to have the <channel> child elements in any particular order, nor is it mandated by the spec. <sequence> can't be used that way, it won't validate unless the order is specific.
              >>
              >>Only <all> can be used to make an arbitrary child order and <all> can't take any elements other than <element>. Can't use <choice> in it.
              >
              >the sequence only contains the choice, the choice is set to have
              >maxOccurs="unbounded", so that in effect you end up with any number of
              >elements from within the choice. I'm obviously not explaining this
              >very well, i'll post a sample (after the game, go Raiders!)
              >
              >Cheers
              >Simon

              Given this schema

              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
              elementFormDefault="qualified"
              attributeFormDefault="unqualified">
              <xs:element name="foo">
              <xs:complexType>
              <xs:sequence>
              <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element name="a"/>
              <xs:element name="b"/>
              <xs:element name="c"/>
              <xs:element name="d"/>
              </xs:choice>
              </xs:sequence>
              </xs:complexType>
              </xs:element>
              </xs:schema>

              The following instance doc is valid (verified with XMLSpy 4.4)
              <foo>
              <a></a>
              <c/>
              <c/>
              <c/>
              <d/>
              <a/>
              </foo>

              Which i believe is what you were looking for.

              Cheers
              Simon
              www.pocketsoap.com
            • Dino Morelli <dino.morelli@snet.net>
              ... Ok, I tried your document out and schema out and some other versions with the elements in different orders and/or missing. In your above example, it
              Message 6 of 10 , Jan 27, 2003
              • 0 Attachment
                --- In RSS2-Support@yahoogroups.com, Simon Fell <szf@z...> wrote:
                > On Sun, 26 Jan 2003 14:58:57 -0800, in szf you wrote:
                >
                > >>In doing so, the <sequence> forces the children to be in that specific order. The RSS document I've been using as an example (yesterday's Scripting News) doesn't seem to have the <channel> child elements in any particular order, nor is it mandated by the spec. <sequence> can't be used that way, it won't validate unless the order is specific.
                > >>
                > >>Only <all> can be used to make an arbitrary child order and <all> can't take any elements other than <element>. Can't use <choice> in it.
                > >
                > >the sequence only contains the choice, the choice is set to have
                > >maxOccurs="unbounded", so that in effect you end up with any number of
                > >elements from within the choice. I'm obviously not explaining this
                > >very well, i'll post a sample (after the game, go Raiders!)
                > >
                > >Cheers
                > >Simon
                >
                > Given this schema
                >
                > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                > elementFormDefault="qualified"
                > attributeFormDefault="unqualified">
                > <xs:element name="foo">
                > <xs:complexType>
                > <xs:sequence>
                > <xs:choice minOccurs="0" maxOccurs="unbounded">
                > <xs:element name="a"/>
                > <xs:element name="b"/>
                > <xs:element name="c"/>
                > <xs:element name="d"/>
                > </xs:choice>
                > </xs:sequence>
                > </xs:complexType>
                > </xs:element>
                > </xs:schema>
                >
                > The following instance doc is valid (verified with XMLSpy 4.4)
                > <foo>
                > <a></a>
                > <c/>
                > <c/>
                > <c/>
                > <d/>
                > <a/>
                > </foo>
                >
                > Which i believe is what you were looking for.
                >


                Ok, I tried your document out and schema out and some other versions with the elements in different orders and/or missing.

                In your above example, it validates if I remove all <a> elements from the data document. If this was one of the mandatory <title>, <link> or <description> elements in RSS under <channel>, it would pass through documents that are incorrect.

                I tried changing the schema to:
                ...
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="a" minOccurs="1" />
                ...

                But the validator ignores the minOccurs on the <element> there and lets documents through without it still.

                So, now we have the non-ordering allowed and multiple copies of elements. But can't constrain some of the choice elements to be one-and-only-one required at the same time, unfortunately.
              • Dino Morelli <dino.morelli@snet.net>
                I m writing this to let everyone know that I m stopping work on this and getting on to other things. To summarize, I can t figure out how to construct a schema
                Message 7 of 10 , Jan 28, 2003
                • 0 Attachment
                  I'm writing this to let everyone know that I'm stopping work on this and getting on to other things.

                  To summarize, I can't figure out how to construct a schema to validate RSS documents.

                  The reason in a nutshell is, in a given child list <channel> or <item> we need arbitrary ordering, items that appear once always, items that appear 0 or 1 time and items that appear 0 or more-than-1 time. These rules can't be modeled for the child of one element with any combination of <xs:all> <xs:choice> <xs:sequence>, etc...

                  Given that we can't lightly change the spec for RSS documents and have breakage with existing documents, aggregators, what-have-you, I'm forced to conclude that a W3C schema for RSS2 can't be achieved with the schema rules as they exist today.

                  I will archive my incomplete working documents for this project. If anyone would like a copy of them, send me an email.
                Your message has been successfully submitted and would be delivered to recipients shortly.