views:

168

answers:

1

I am trying to extend an xhtml document to allow extra attributes.

In the w3.org it gives an example like so:

<!ATTLIST a
  myattr   CDATA        #IMPLIED
>

See: 6.1. Defining additional attributes - http://www.w3.org/TR/1999/xhtml-modularization-19990406/developing.html#s_dev_attrs

However i am not sure where to put that statement.

I have tried adding it like so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    <!ATTLIST a
      myattr   CDATA        #IMPLIED
>

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
...
</head>
<body>
...
</body>

But when I pick up the doc using DOM that extra DTD statement is ignored.

I have also tried:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [ 

    <!ATTLIST a
      myattr   CDATA        #IMPLIED
>
]>

    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    ...
    </head>
    <body>
    ...
    </body>

But that really caused DOM to throw a wobbly.

So I'd appreciate it if someone could show me a sample xhtml document that has an additional attribute defined. (i.e minimal full doc that could validate)

As you might have guessed....xhtml is not my strong point.

A: 

Your second example is correct, apart from the missing </html> end-tag. With that added it parses OK for me. What exactly “throws a wobbly”?

The ATTLIST declaration must indeed go in the DTD, the internal subset of which is within square brackets inside the DOCTYPE declaration.

(What are you hoping to achieve with this? Browsers don't care, even if they are running in native application/xhtml+xml mode. In normal text/html tag soup mode the DTD internal subset will just confuse them.)

bobince
I am using xhtml to store some content in the back-end. CMS-like. So, some resources might simply be defined by a meta tag <meta name="pageId" content="2354" />, whereas others might define extra keywords, related links etc for SEO.It could probably all go into a db at some stage, but xhtml is pretty flexible while i have yet to discover the extent of the fields needed. Hoped i could make xml editor recognise some custom attributes/offer prompts/default values etc. When I use the second example my docs get lost by either html tidy or php dom. Thanks though, nice knowing its not the xml syntax
JW