0
votes

I have, for my own edification, constructed an XHTML Strict 1.0 page containing a form. I'd like for it to accept text/xml MIME-types only and so I've specified the accept attribute accordingly. However, it can't be validated when also including the enctype="mulipart/form-data" attribute-value pair.
Is there an alternative to specifying the enctype when working with XHTML Strict 1.0? Do I need to specify the enctype or something similar at all?

I have not set up an actual "action" (cgi or some other back-end function). I'm only concerned with client-side for the moment and would like for the user to be prompted when uploading anything that's NOT xml. Do I need JavaScript here?

Also, it seems that not too many people are fond of XHTML in any form. If you have the liberty of choosing XHTML Strict/Frameset/Transitional or HTML 4.01 for a static page, which standard would be best?

2

2 Answers

0
votes

The form encoding (enctype attribute) has to be multipart/form-data for the file uploads to work.

According to what I can find, the accept attribute is not implemented in any browser at all.

So, using Javascript seems like the only option if you want to offer any feedback on the selected file before the actual upload.


There are some people that have very strong opinions about XHTML, but that doesn't mean that it's not a widely used standard.

0
votes

To address the last point first: Strict XHTML 1.1 suffers from the fact that the W3C recommendation really requires you to deliver the document as MIME type application/xml+xhtml or something like that, and that's virtually impossible to set up on a web server in a way that satisfies most, if not all, current clients. So if you cannot do it right anyway you might as well just use HTML 4.01, which is grammatically nearly equivalent and arguably more powerful (e.g. HTML 4.01 can validably prohibit nested anchors, while XHTML has to add that as a textual extra clause). You'll get the same job done, and it'll actually be understood by nearly all existing clients. (Since I trust you'll only be using DOM methods to manipulate the document client-side, there won't be a problem with AJAX backends sending other forms of XML, either.)

For the first question: There is nothing that forces any client to do anything specific. The accept attribute is a hint for the client what your server will probably accept or reject, but it doesn't have to act on this in any defined manner. If you like, you can add some optional additional verification on the client with scripting, but of course you always must validate input data on the server, too.