Special restriction on IDREF

Discussion in 'XML' started by Luigi, Dec 11, 2007.

  1. Luigi

    Luigi Guest

    Hello!

    I'm writing a schema where an element has got a reference to another
    element via IDREF. The problem is that I would restrict the possible
    references to the sole elements of a specific type, or, in other
    words, to those element with a specific tag name. For instance:

    <xs:element name="A">
    <xs:complexType>
    <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
    </xs:element>

    <xs:element name="B">
    <xs:complexType>
    <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
    </xs:element>

    <xs:element name="C">
    <xs:complexType>
    <xs:attribute name="idref" type="xs:IDREF"/>
    </xs:complexType>
    </xs:element>

    I want that C elements could have references only to A elements. Is it
    possible?

    Thank you in advance.
    Luigi, Dec 11, 2007
    #1
    1. Advertising

  2. Luigi

    Pavel Lepin Guest

    Luigi <> wrote in
    <>:
    > I'm writing a schema where an element has got a reference
    > to another element via IDREF. The problem is that I would
    > restrict the possible references to the sole elements of a
    > specific type, or, in other words, to those element with a
    > specific tag name.
    >
    > I want that C elements could have references only to A
    > elements. Is it possible?


    As far as I can tell, it's not possible. Check on
    application side. XML Schema is not designed to define
    arbitrarily complex grammars. If you're willing to separate
    namespaces for id attributes on A and B elements, this
    might be possible using key/keyref (see 3.11.2 in XML
    Schema Structures and/or 5.2 in XML Schema Primer).

    --
    ....also, I submit that we all must honourably commit seppuku
    right now rather than serve the Dark Side by producing the
    HTML 5 spec.
    Pavel Lepin, Dec 11, 2007
    #2
    1. Advertising

  3. IDs/IDREFs are pretty simpleminded. Since you're working in schema, you
    may want to look at keys and keyrefs; I think it may be possible to
    persuade them to do what you want.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Dec 11, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rico
    Replies:
    2
    Views:
    408
  2. kevkev

    JAXB and IdRef

    kevkev, May 18, 2005, in forum: Java
    Replies:
    3
    Views:
    4,317
    kevkev
    May 19, 2005
  3. Elhanan
    Replies:
    0
    Views:
    1,140
    Elhanan
    Mar 30, 2006
  4. Lars
    Replies:
    0
    Views:
    1,209
  5. Hauke Fuhrmann

    restrict IDREF to special elements

    Hauke Fuhrmann, Oct 26, 2003, in forum: XML
    Replies:
    1
    Views:
    647
    Mark Preston
    Oct 27, 2003
Loading...

Share This Page