www.webdeveloper.com
Results 1 to 6 of 6

Thread: Custom tag in DTD document

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    Smile Custom tag in DTD document

    Hi there!

    I'm building a javascript image gallery. Which uses my user defined tag "gallery".
    And now I want to add this to a DTD document, so that it can be properly validated.

    I've tried to input it like this

    Code:
    <!-- gallery object, block object -->
    
    <!ELEMENT gallery EMPTY>
    <!ATTLIST gallery
      &#37;attrs;
      src         %Text;         #REQUIRED
      height      %Length;       #IMPLIED
      width       %Length;       #IMPLIED
      >
    But the w3c validator is complaining about it!

    Line 12, Column 27: document type does not allow element "gallery" here
    What could I do to make this validated correctly?

    The W3C is not complaining about my DTD document, it's only saying that my gallery tag is not allowed where it is.

    My html document looks like this

    Code:
    <!DOCTYPE html SYSTEM "http://www.mydomain.com/xhtml.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Image gallery</title>
    
    <script src="inc/js/gallery.js" type="text/javascript"></script>
    
    </head>
    
    <body>
    	<gallery src="images.xml"></gallery>
    </body>
    </html>
    Any one?

    Cheers,
    Artheus
    Last edited by artheus; 01-27-2010 at 02:44 AM.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Why use a custom element?
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Dec 2005
    Posts
    2,984
    Rather than question your methods (I like to experiment with weird stuff, too, to help me learn how things actually work), how about surrounding it in a div first?

    HTML Code:
    <body>
      <div>
        <gallery src="images.xml"></gallery>
      </div>
    </body>
    Interestingly enough I can't seem to ever put anything as a direct, first descendant of the body element without first wrapping it in a div without getting a validation error. I'm no W3C guru so I don't know why this is, but I'll bet that if you put a div around it first then it might fix the problem.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Interestingly enough I can't seem to ever put anything as a direct, first descendant of the body element without first wrapping it in a div without getting a validation error.
    Any block level element will validate, whereas an inline element must be enclosed in a block level element.

    Don't use "custom DTDs"
    Last edited by Fang; 01-28-2010 at 08:23 AM.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Sep 2008
    Posts
    61
    Thanks aj_nsc, for being supportive of my experimentations. I tried your suggestion, and it seem as though it's not working like that either... :/
    Fang.. Why be so negative towards experimenting? The only way of evoluting knowledge is through experimentation. I don't really get W3C there either.. Cause, using custom DTD's with valid syntax, should be just as normal as customizing files in any Open-Source project.

    So I don't really get the "big bad" harm in making custom DTD's for custom projects.. But I can see that it would be better to just use the good old div-tag with the className "gallery" instead.

    But that's not funny, and experimental is it??

    Cheers,
    Artheus

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    I'm in no way against experimenting, but have never seen the necessity of creating a custom DTD.

    You define the element as EMPTY, yet you add a closing tag???
    Code:
    <!ELEMENT GALLERY (&#37;block)  - O EMPTY>
    <!ATTLIST GALLERY
    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.3
    http://www.alistapart.com/articles/customdtd/
    Last edited by Fang; 01-29-2010 at 01:48 AM.
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles