querry on ID's and IDREF in DTD

Discussion in 'XML' started by Maulik Thaker, Feb 21, 2006.

  1. Hi ppl,

    I have a querry based on ID. Suppose if i have got two primary keys
    (ID) and one foreign key (IDREF) in the same attribute, is there a way
    to use them.



    For example :

    INSTRUCTUR

    1) FirstName varchar(32) Primary key
    2) LastName varchar(32) Primary key
    3) emailID varchar(64) Foreign Key

    Now the question is what could be the possible DTD for this kind of
    situation.
    Can anyone please let me know regarding this and if u have any good
    suggestions for the weblink for such kind of DTD's please let me know.

    Thanks in advance.

    Maulik.
    Maulik Thaker, Feb 21, 2006
    #1
    1. Advertising

  2. DTDs do not support the concept of multiple keys. Only one attribute per
    element type may be declared as having type ID.

    (http://www.w3.org/TR/2004/REC-xml11-20040204/#one-id-per-el)

    If you're working with schemas rather than DTDs, you could try using
    keys rather than IDs. Or you could just have your software explicitly
    search for elements that have the appropriate attribute/value pair,
    using XPaths or something of that sort.
    Joe Kesselman, Feb 21, 2006
    #2
    1. Advertising

  3. Maulik Thaker

    Aalap Guest

    Hi,

    but what if i wanted to implement that structure using DTD only..

    Thanks
    Aalap
    Joe Kesselman wrote:
    > DTDs do not support the concept of multiple keys. Only one attribute per
    > element type may be declared as having type ID.
    >
    > (http://www.w3.org/TR/2004/REC-xml11-20040204/#one-id-per-el)
    >
    > If you're working with schemas rather than DTDs, you could try using
    > keys rather than IDs. Or you could just have your software explicitly
    > search for elements that have the appropriate attribute/value pair,
    > using XPaths or something of that sort.
    Aalap, Feb 24, 2006
    #3
  4. >>DTDs do not support the concept of multiple keys. Only one attribute per
    >>element type may be declared as having type ID.

    > but what if i wanted to implement that structure using DTD only..


    Then the DTD can't help you. As I said:

    >> Or you could just have your software explicitly
    >>search for elements that have the appropriate attribute/value pair,
    >>using XPaths or something of that sort.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Feb 24, 2006
    #4
  5. Maulik Thaker

    Aalap Guest

    hey

    Thanks again.....

    suppose i took instructor as an element and first name , last name ,
    email as the child elements.......and each element should have an
    attribute called first name ,last name and email respectively . and in
    that case first name and last name can have and ID rt?

    Aalap
    Aalap, Feb 24, 2006
    #5
  6. > suppose i took instructor as an element and first name , last name ,
    > email as the child elements.......and each element should have an
    > attribute called first name ,last name and email respectively . and in
    > that case first name and last name can have and ID rt?


    Yes. Ugly, but yes.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Feb 24, 2006
    #6
  7. Maulik Thaker

    Aalap Guest

    Hey thanks.......a lot !!!
    Aalap, Feb 25, 2006
    #7
  8. Note that IDs must be unique, though. So if you make firstname an ID,
    nobody else can have the same firstname; if lastname is also an ID, not
    only can no two people have the same lastname, but no lastname can be
    the same as any firstname.

    I doubt that's what you're trying to achieve. IDs are generally the
    wrong solution for anything except pointing to a specific location in a
    document.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Feb 25, 2006
    #8
  9. Maulik Thaker

    Aalap Guest

    Hey

    even i just realised that . i surely dont want that
    So there is no way i can use ID for a composite key for a table....
    also i am getting and error in XML spy
    This file is not valid:
    Required attribute 'dept' is missing.
    even though i have it in the dtd .

    Thanks
    Aalap
    Aalap, Feb 25, 2006
    #9
  10. > Required attribute 'dept' is missing.
    > even though i have it in the dtd .


    Sounds like the problem is that you do have it in the DTD but it's
    missing in the instance document.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Feb 25, 2006
    #10
  11. Maulik Thaker

    Aalap Guest

    And what abt the composite key thing....can i implement it using the
    DTD
    `
    Aalap, Feb 25, 2006
    #11
    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:
    404
  2. Joseph Tilian
    Replies:
    0
    Views:
    348
    Joseph Tilian
    Dec 21, 2004
  3. Ronald Fischer
    Replies:
    4
    Views:
    1,752
    Ronald Fischer
    Mar 17, 2005
  4. kevkev

    JAXB and IdRef

    kevkev, May 18, 2005, in forum: Java
    Replies:
    3
    Views:
    4,314
    kevkev
    May 19, 2005
  5. test
    Replies:
    2
    Views:
    2,015
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page