ATTLIST id ID not working?

Discussion in 'XML' started by Alain Ketterlin, Oct 1, 2003.

  1. eric <> writes:

    > <!ATTLIST category id ID #IMPLIED>


    > <category id = "Barber and Beauty Salons">


    ID-attribute values cannot contain spaces. See
    http://www.w3.org/TR/REC-xml#id

    -- Alain.
    Alain Ketterlin, Oct 1, 2003
    #1
    1. Advertising

  2. Alain Ketterlin

    eric Guest

    Greetings!

    Not sure if this is the right place to post this or if I should post in the
    Java newsgroup.

    I have a DTD which specifies:

    <!ATTLIST category id ID #IMPLIED>

    In my xml document I have:

    <category id = "Barber and Beauty Salons">
    ..
    ..
    ..
    <category id="Attorneys">
    ..
    ..
    ..
    <category id = "Florists">

    My thinking is that the DTD has specified id as a unique ID.

    When I try this in my jsp page:

    Element test = doc.getElementById("Attorneys");
    out.println("Testing " + test);

    All I get for test is null. Is this a feature, bug or somthing I'm doing
    wrong? :))

    Eric
    eric, Oct 1, 2003
    #2
    1. Advertising

  3. eric wrote:
    > <!ATTLIST category id ID #IMPLIED>
    >
    > In my xml document I have:
    >
    > <category id = "Barber and Beauty Salons">


    This does not match the production rules for ID (contains whie space).

    > ..
    > ..
    > ..
    > <category id="Attorneys">
    >
    > When I try this in my jsp page:
    >
    > Element test = doc.getElementById("Attorneys");
    > out.println("Testing " + test);
    >
    > All I get for test is null. Is this a feature, bug or somthing I'm doing
    > wrong? :))


    Hmm, maybe you're not parsing with validation switched on.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
    Johannes Koch, Oct 1, 2003
    #3
  4. Alain Ketterlin

    eric Guest

    Johannes,

    Thanks for pointing out the whitespace! It did not make any difference
    though.

    I should have put this in my original post. Here's how I set up the
    validation:

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating (true);

    if(dbf.isValidating())
    out.println("It is validating <br />");

    I get no errors and the out.println displays. I wonder why the white space
    in the id wasn't caught?

    Still getting null for doc.getElementById("Attorneys");

    Eric


    Johannes Koch wrote:

    > eric wrote:
    >> <!ATTLIST category id ID #IMPLIED>
    >>
    >> In my xml document I have:
    >>
    >> <category id = "Barber and Beauty Salons">

    >
    > This does not match the production rules for ID (contains whie space).
    >
    >> ..
    >> ..
    >> ..
    >> <category id="Attorneys">
    >>
    >> When I try this in my jsp page:
    >>
    >> Element test = doc.getElementById("Attorneys");
    >> out.println("Testing " + test);
    >>
    >> All I get for test is null. Is this a feature, bug or somthing I'm doing
    >> wrong? :))

    >
    > Hmm, maybe you're not parsing with validation switched on.
    eric, Oct 1, 2003
    #4
  5. Alain Ketterlin

    Eric Sirois Guest

    Hello Eric,

    Try the following print statement instead.

    Element test = doc.getElementById("Attorneys");
    out.println("Testing " + test.getNodeName());

    We've run into the same problem before. Usually I would expect the
    Java object value to be printed, but it always returns a null for XML
    Node objects.

    Check the API for the Node class for a table of values that will be
    returned depending on the method called for a specific implemenation of
    the Node class.

    Kind regards,
    Eric

    eric wrote:
    > Greetings!
    >
    > Not sure if this is the right place to post this or if I should post in the
    > Java newsgroup.
    >
    > I have a DTD which specifies:
    >
    > <!ATTLIST category id ID #IMPLIED>
    >
    > In my xml document I have:
    >
    > <category id = "Barber and Beauty Salons">
    > .
    > .
    > .
    > <category id="Attorneys">
    > .
    > .
    > .
    > <category id = "Florists">
    >
    > My thinking is that the DTD has specified id as a unique ID.
    >
    > When I try this in my jsp page:
    >
    > Element test = doc.getElementById("Attorneys");
    > out.println("Testing " + test);
    >
    > All I get for test is null. Is this a feature, bug or somthing I'm doing
    > wrong? :))
    >
    > Eric
    >
    Eric Sirois, Oct 3, 2003
    #5
    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. Ratman
    Replies:
    0
    Views:
    649
    Ratman
    Sep 14, 2004
  2. Martin Heuckeroth
    Replies:
    5
    Views:
    676
    JiangZemin
    Apr 1, 2005
  3. Alan Silver
    Replies:
    1
    Views:
    3,769
    Alan Silver
    Aug 2, 2005
  4. rblah
    Replies:
    3
    Views:
    457
    Peter Flynn
    Jan 18, 2004
  5. Manfred Lotz

    ATTLIST and enumerations

    Manfred Lotz, Feb 24, 2014, in forum: XML
    Replies:
    4
    Views:
    268
    Peter Flynn
    Feb 27, 2014
Loading...

Share This Page