-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong MIME type on HTML5 pages in XHTML namespace #198
Comments
@joewiz commented on Jul 8, 2018, 1:36 PM UTC: Which file extension are you using? If you’re using In my next reply, I’ll cover the difference between eXide’s templates, eXide’s saving behavior, eXist’s file extension-based mime-type resolution, and XQuery serialization. |
@dariok commented on Jul 8, 2018, 1:39 PM UTC: The extension does not seem to make a difference. Cf. http://exist.baukast.digital:8888/exist/apps/pageCount/index.xhtml which also is returned as Added: I assumed that there are 4 things working here, eXide's templates, its saving mechanism, what eXist actually does save and lastly how it is served (e.g. by Jetty). This is why I decided not to open this issue in the eXide repo. |
@dariok Ok, so it sounds like you've anticipated these points, but here are the various components involved in the create-save-edit-save-serve processes you described:
To answer your question more directly, eXist does not store a file's doctype when it is ingesting a file; nor does it particularly distinguish between different kinds of HTML documents, as long as they're well-formed XML documents. eXide, in particular, conflates HTML and XHTML documents as belonging to the same "mode" and assigns the same mime type to these documents. Once a document is stored, if you want to serve (serialize) it using HTML5 rules and a doctype declaration (as opposed to the default XML method applied to ), you need to tell eXist to serialize it as such; see http://exist-db.org/exist/apps/doc/xquery#serialization. I do see one possible opportunity for avoiding the unexpected behavior you described in your original post: We could add an "XHTML" mode to eXide, which preserves the mime type of |
@joewiz Let me start from the back: ad 4 I of course know about XQuery serialization but I do not understand how the XQuery serialization rules apply here. They obviously do if Ihave an XQuery that generates or otherwise handles the XHTML file. Setting the output option for the way a query result displayed is fair enough, but not applicable here as the file is not part of any query. ad 3 That indeed seems to choose the correct MIME type:
http://exist.baukast.digital:8888/exist/apps/pageCount/test.xhtml is served as ad 2 and 1 If I want to create an HTML file from within eXide, I have to choose this after selecting "new". Obviously, other selections in this dialog result in different MIME types. That is the way I expect it to be. Now, if I choose HTML, I have two options, one is actually an HTML fragment for templating – which thus should never be served on its own and thus it's MIME typ is of secondary importance –, the other the option in question: “HTML5 Document in XHTML Namespace”. It is obvious that this file is meant to be an XHTML file and eXide's template dutifully includes the XML declaration on top. Consequently, the MIME type should be I myself do not actually need the file to be XHTML expressly. I'd be perfectly happy with an HTML5 file served as I think there are three different options:
As regards the DOCTYPE: I do not really understand why eXist should drop If the file is considered to be an XML file, I'd be puzzled if eXist drops the doctype declaration. After all, it is a part of the XML spec and, albeit used less and less frequently due to current alternatives, still an integral part of many XML files. I do not know whether that still is the case, but I remember reading or hearing that for XML files the doctype part is stored separately but added back by the serializer. Of course, an XHTML file does not need the doctype, while a normal HTML5 does need it. In any case, if it is dropped anyway, the template should not contain it in the first place. It would be better, though, to retain it for HTML files as it is a required part of the standard (even though the file should get rendered by browsers nonetheless). Options 2 and 3 from above would need the doctype to be included while it could be left out for option 1. |
@dariok Ah, I wasn't clear exactly how you were serving up the files. Please disregard my explanation of serialization options then. As regards the DOCTYPE, if you'd like to pursue the issue of eXist storing a document's doctype in addition to the document, you're right that this is an eXist issue and not an eXide issue. Please see https://markmail.org/thread/27fxcjicang6yk3q for the most recent discussion about this, and open an issue or discussion on exist-open specifically about this. Would you be interested to file a PRs improving eXide's templates or adding support for an XHTML mode? I think the links to the source in my first note would provide pointers to the places that would need work. |
@joewiz I'll gladly have a look at it next week when I'm back in the office. Thank you for the pointer to the discussion, I will look at it, too, and see hiw i can contribute. All best! |
Closed by #199. |
@dariok commented on Jul 8, 2018, 12:59 PM UTC:
What is the problem
When using eXide to create an HTML file with the option "HTML5 file in XHTML namespace", this file is saved (and consequently served) with the incorrect MIME type of
text/html
. Additionally, the doctype is omitted by Jetty. While it is possible to manually change the MIME type, it is changed back totext/html
each time you save the file from eXide.The beginning of the file in eXide as auto-created:
The response of eXist with such a file:
HTTP header:
Content-Type: text/html;charset=utf-8
Beginning of file:
What did you expect
application/xhtml+xml
;Describe how to reproduce or add a test
Create a file in eXide with the above parameters and check the response as served by Jetty.
Please always add the following information
This issue was moved by adamretter from eXist-db/exist#2006.
The text was updated successfully, but these errors were encountered: