Must SVG foreignObject contain only XML? That seems to be my reading of the spec, so is it required to put XHTML inside, if I wish to use foreignObject? Or can I just copy my regular HTML5 syntaxed code inside?
The contents of any document must reflect the mime type it's served as.
If you serve the document as image/svg+xml then the whole document must be valid XML including any foreignObject child elements which basically limits you to XHTML. XML fails on error so if you paste in HTML you'll likely just get a syntax error printed than have anything rendered.
If you serve the document as text/html then the whole document is HTML and any SVG in it would be parsed with an HTML parser, no namespaces required etc. Any foreignObject elements in such SVG will be parsed as if they were standard HTML. HTML attempts to render what it can of invalid documents.
Related
My objective is to convert word document to HTML and if equation presents in a document, then it must be converted into mathml before saving it as HTML.
So I converted all the equation into mathml using mathtype. Now, word document will have mathml content too.
If I save it as "web page filtered" document, I get it as HTML but mathml tags are getting converted to entity.
For example:
sample.docx
<mrow>Lj</mrow>
is converted to
<mrow> &C456;</mrow>
EXPECTATION
I need to convert this document into HTML but if mathml contents present, then that mathml content alone shouldn't be converted into HTML. What would be the solution for this?
I need something like, XML file <![CDATA[ unparsed char ]]> . In word file, how can I shield mathml content not to be converted?
What are browsers interpreting when the get a file extension upon load?
I try to mix html, svg and dtd (entities). I try to do that in a valid way. But now a stand for a problem that i dont understand. I did:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html [
<!ENTITY duration "3s">
...
...
<div style='width:100%; border:1px solid black;'>high there</div>
<p>toaster</p>
<hr/>
<svg width="600" ...
and my 'page' displays well as intended, my Rubymine 'reads' the the file without any annotation.
as long as the file extenstion is SVG (ie. index.svg). If I change it to HTML - bad luck. The Page only looks a bit like it should.
see both variants here:
as svg and as html
what happens now behind the scene when the browser "changes its mind" depending on a file exetension?
BTW my RumyMine tells me that there is something wrong with the file whe it has the 'html' extention (but not what).
I would preferre both: tell me what happens, and tell me what would be the correct way to do what i want.
This has nothing to do with the browser processing the extension, but it starts with how the server processes the extension.
In fact, the spec says:
File extensions are not used to determine the supplied MIME type of a
resource retrieved via HTTP because they are unreliable and easily
spoofed.
When the page is served as http://keepitsimple-soft.com/question.html, your Apache server includes this HTTP header in the response: Content-Type: text/html, so the browser knows that it's an HTML page and uses an HTML parser to read it. The HTML parser doesn't process those entity definitions in the DOCTYPE, so it can't correctly interpret them in the SVG.
When the page is served as http://keepitsimple-soft.com/question.svg, the server includes this HTTP header in the response: Content-Type: image/svg+xml. In this case, the browser recognises the "+xml" part and parses the file using its XML parser. This does interpret the entity definitions, and can therefore handle the SVG fully.
As far as what you should do, you can either use XHTML and stick with the XML parser, or resolve the entity definitions before sending the page over the wire, in which case, your page should work with the HTML parser. (Though I haven't tested this.)
I thought XHTML documents were supposed to be displayed with exactly the same standards compliance mode as "strict" HTML documents.
However, there is a difference in how they display pre elements: in HTML documents, if the <pre> start tag is followed by a LF (or CRLF), this is ignored. Not so in XHTML.
Example: a HTML file and a XHTML file that have the same content, but are rendered differently.
(Or if you think it's cheating to give a HTML file and a XHTML file exactly the same content, including DOCTYPE, here are two files that follow more classic rules: HTML 4.01 strict and XHTML 1.0 strict.)
So, does that mean that statements like this W3C page's
all line breaks and spaces are rendered exactly as they appear in the HTML. The exception is a newline immediately after the start tag <pre> and immediately before the end tag </pre>, which are discarded.
are only valid for HTML, not for XHTML? I haven't found any indication that XHTML can display things differently if it likes. But all the browsers I've tested do.
The removal of the starting newline is nothing to do with the rendering in HTML, and Dave Raggett's page is just a little imprecise and getting a little out of date. The removal of the starting newline is a property of the HTML parser.
In the in body tree construction phase the HTML5 spec for the text/html mime type says:
A start tag whose tag name is one of: "pre", "listing"
If the stack of open elements has a p element in button scope, then close a p element.
Insert an HTML element for the token.
If the next token is a "LF" (U+000A) character token, then ignore that token and
move on to the next one. (Newlines at the start of pre
blocks are ignored as an authoring convenience.)
Set the frameset-ok flag to "not ok".
An XML parser is simply not allowed to do this by the XML parsing rules, so XHTML does not drop that new line.
I have an XML file ("exchange.xml") and an XSL file ("exchange.xsl") for parsing it. exchange.xml has the following line:
<?xml-stylesheet type="text/xsl" href="exchange.xsl"?>
Indicating that exchange.xsl should be used to parse the file.
It parses as expected if I load exchange.xml in a browser. However, I want to have exchange.xml embedded in an HTML file which otherwise does not have any XML in it. How do I do this? As far as I understand it, when you embed XML in HTML with the XML tag's SRC ID, you then have to parse it yourself for it to be displayed. I want it to automatically be displayed using the XSL file I've already created for it.
It has also come to my attention that some browsers (e.g. Android default browser) won't parse the XML with the XSL file, and require a server-side transform. Is it possible to embed my XML into an HTML file but use a server-side transform?
As far as I am aware HTML 4 as specified by the W3C does not provide any way to embed XML markup in an HTML 4 document. And of the browsers I know only IE has an extension to HTML 4 that allows that, the so called XML data islands, http://msdn.microsoft.com/en-us/library/ms766512%28v=VS.85%29.aspx, where IE's HTML parser recognizes an xml element that can contain XML markup as its content or link to it with the src attribute. So unless you want to use something IE specific like an XML data islands the cross-browser way to load XML as data inside of an HTML document is to use XMLHttpRequest with Javascript.
You can use PHP: XSL class for transforming XML and include it via PHP in your page.
eg: showxml.php
<?php
function processXML($file,$styles){
... //example here
}
<html>
...
<div id="xml>
<?php echo processXML('foo.xml','bar.xsl'); ?>
</div>
...
</html>
When i validating my site i got following issue
<embed src="banner.swf" quality="high" pluginspage="http://www.macromedia…
✉
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash.
How Can i solve this???
<embed> is deprecated, you should use <object> instead.
See http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3
embed isn't part of the HTML 4.0 or XHTML 1.0 specification (although it is part of HTML5). The object tag is the standardized tag to embed Flash and similar content in a webpage.