schema, attributes, interdependent restrictions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc Hebert

    schema, attributes, interdependent restrictions


    I'm trying to figure out if something is possible to specify and
    constrain using a schema. I'll explain using an example.

    sample xml:
    <person name="John" age="32"/>
    <person name="Julie" age="25"/>

    In my schema, I'd love to be able to place different restrictions on
    the attribute 'age' based on the value of 'name'... so in this
    example, I might want to enforce that any entry where name="John"
    includes an age attribute that falls between 30-39, and that Julie's
    age value is 20-29.

    What I tried to do, and is invalid, is define a JohnPerson and
    JuliePerson element type, and then specify that I expected a list
    (all) of elements having an element name="person" and
    type="JohnPerso n", "JuliePerso n", etc... by the parser rejected that
    with "Multiple elements with name 'person', with different types,
    appear in the model group."

    Any ideas?

    Many thanks,
    Marc
  • Bjoern Hoehrmann

    #2
    Re: schema, attributes, interdependent restrictions

    * Marc Hebert wrote in comp.text.xml:
    >I'm trying to figure out if something is possible to specify and
    >constrain using a schema. I'll explain using an example.
    >
    >sample xml:
    ><person name="John" age="32"/>
    ><person name="Julie" age="25"/>
    >
    >In my schema, I'd love to be able to place different restrictions on
    >the attribute 'age' based on the value of 'name'... so in this
    >example, I might want to enforce that any entry where name="John"
    >includes an age attribute that falls between 30-39, and that Julie's
    >age value is 20-29.
    This is not possible with XML Schema 1.0. You could check out NVDL (with
    multiple XML Schema schemas), RELAX NG, and Schematron (possibly XML
    Schema with embedded Schematron), none of which will work in simple XML
    Schema 1.0 implementations of course.
    --
    Björn Höhrmann · mailto:bjoern@h oehrmann.de · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

    Comment

    • Marc Hebert

      #3
      Re: schema, attributes, interdependent restrictions

      On May 23, 7:43 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
      * Marc Hebert wrote in comp.text.xml:
      >
      I'm trying to figure out if something is possible to specify and
      constrain using a schema. I'll explain using an example.
      >
      sample xml:
      <person name="John" age="32"/>
      <person name="Julie" age="25"/>
      >
      In my schema, I'd love to be able to place different restrictions on
      the attribute 'age' based on the value of 'name'... so in this
      example, I might want to enforce that any entry where name="John"
      includes an age attribute that falls between 30-39, and that Julie's
      age value is 20-29.
      >
      This is not possible with XML Schema 1.0. You could check out NVDL (with
      multiple XML Schema schemas), RELAX NG, and Schematron (possibly XML
      Schema with embedded Schematron), none of which will work in simple XML
      Schema 1.0 implementations of course.
      --
      Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
      Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
      68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
      Thanks very much for that info, that saves me a few hours of trying to
      do something impossible.

      Marc

      Comment

      • hugo

        #4
        Re: schema, attributes, interdependent restrictions

        test
        "Marc Hebert" <hebert.marc@gm ail.comwrote in message
        news:5539b376-9c63-4aff-ad3d-c37993974523@34 g2000hsh.google groups.com...
        >
        I'm trying to figure out if something is possible to specify and
        constrain using a schema. I'll explain using an example.
        >
        sample xml:
        <person name="John" age="32"/>
        <person name="Julie" age="25"/>
        >
        In my schema, I'd love to be able to place different restrictions on
        the attribute 'age' based on the value of 'name'... so in this
        example, I might want to enforce that any entry where name="John"
        includes an age attribute that falls between 30-39, and that Julie's
        age value is 20-29.
        >
        What I tried to do, and is invalid, is define a JohnPerson and
        JuliePerson element type, and then specify that I expected a list
        (all) of elements having an element name="person" and
        type="JohnPerso n", "JuliePerso n", etc... by the parser rejected that
        with "Multiple elements with name 'person', with different types,
        appear in the model group."
        >
        Any ideas?
        >
        Many thanks,
        Marc

        Comment

        Working...