xHTML 1.0 strict - Validate iFrames - validation

Is it possible to validate iFrames in xhtml 1.0 strict? Preferably without any use of javascript to inject the iframe into the page.
I know there is no point in validating just for the sake of validation, but lets just say that I like the green validation message on w3c ;) (I am forced by factors beyond my control to use iframes)
Or maybe there is something very similar I can use in xHTML to get iframe-like behavior without losing compatibility across different browsers? (object?)
Perhaps there is a way to add a second doctype containing iframe rules?

i'm not sure but I think you can include another page with object as you suggest.
<object data="/another.html" type="text/html"></object>

If you need iframes, use Transitional instead of Strict. The point of it is for when you need to use legacy features like iframes.

Related

Is a webpage loaded/rendered faster with HTML 4 transitional or HTML 5 DTD?

I have a webpage that is HTML 4 transitional and HTML 5 compliant. In the latest version of the browsers is there a performance gain (decrease in the time to load/render the page) if I code the page to use the HTML5 DTD (which means don't put a DTD) over the HTML 4 transitional DTD?
The HTML5 doctype is several characters smaller than previous iterations which means fewer bytes and a smaller file size, which in theory would suggest that the HTML5 version has better performance.
However, I would suggest that if all you do is change the doctype, the performance gains will be minimal.
HTML5 parsing is 5% - 20% faster on Gecko
https://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/
The DTD is just there to tell the browser (and a validator) what type of HTML you use and how your tags are deemed "valid".
DTDs use a terse formal syntax that declares precisely which elements and references may appear where in the document of the particular type, and what the elements’ contents and attributes are.
A DOCTYPE tells the browser what mode to use: strict or quirks mode which dictate how the browser should layout the page.
The HTML layout engines in modern web browsers perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as text/html determines a layout mode, such as "quirks mode" or "standards mode".
HTML5 has the doctype <!DOCTYPE html> - a DOCTYPE with no DTD.
don't confuse them, they are different things.
There is no performance gain to it as far as i know. However, using a DOCTYPE makes a browser layout the page in a standards-compliant (and a more consistent, but not totally) way across browsers. This is a "handsomeness" benefit rather than speed.
Since web browsers are implemented with special-purpose HTML parsers, rather than general-purpose DTD-based parsers, they don't use DTDs and will never access them even if a URL is provided. The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.

XHTML Transitional rel attribute alternative

I'm trying to add some custom data within a tag to reference later in a jQuery call, and I usually use "rel=" for something like this. However, I'm working in an XHTML Transitional document, and it gives me a "there is no rel attribute".
Are there any alternate attributes I can use to attach custom data to an HTML tag while still keeping the document valid?
If you care much about XHTML validity in the case you mentioned, a common practice is to use the class attribute and space different things there.
HTML5 allows this via the data attribute or rather prefixing your own custom attributes with data-, e.g. data-my-var="hello". But this is invalid in XHTML.

XSL transformation in Firefox, how to omit xmlns in returned transform?

I am trying to do XSL transformation in javascript in Firefox 3.5. The transformed value has something like this:
<span xmlns="http://www.w3.org/1999/xhtml/">...</span>
How can I ensure that the xmlns isn't set here? This happens only in Firefox and not IE.
Why do you want to remove the namespace?
The purpose of namespaces are not always well understood or appreciated.
If you are transforming to XHTML, the namespace is valid (and can be useful). It tells you(and more importantly, the browser) what type of span element you are dealing with so you can decide how to render it. Depending on the vocabulary, or the version of the vocabulary, you may decide to handle the XML differently.

extract xpath

I want to retrieve the xpath of an attribute (example "brand" of a product from a retailer website).
One way of doing it is using addons like xpather or xpath checker to firefox, opening up the website using firefox and right clicking the desired attrbute I am interested in. This is ok. But I want to capture this information for many attributes and right clicking each and every attribute maybe time consuming. Also, the other problem I have is that attributes I maybe interested in will be there for one product. The other attributes maybe for some other product. So, I will have to go that product & then do it manually again.
Is there an automated or programatic way of retrieving the xpath of the desired attributes from a website rather than having to do this manually?
You must notice that not all websites use valid XML that you can use xpath on...
That said, you should check out some HTML parsers that will allow you to use xpath on HTML even if it is not a valid XML.
Since you did not specify the technology you are working with - I'll suggest the .NET HTML Agility Pack, if you need others, search for questions dealing with this here on SO.
The solution I use for this kind of thing is to write an xpath something like this:
//*[text()="Brand"]/following-sibling::*
//*[text()="Color"]/following-sibling::*
//*[text()="Size"]/following-sibling::*
//*[text()="Material"]/following-sibling::*
It works by finding all elements (labels) with the text you want and then looking to the next sibling in the HTML. Without a specific URL to see I can't help any further.
This is a generalised version you can make more specific versions by replacing the asterisks is tag types, and you can navigate differently by replacing the axis following sibling with something else.
I use xPaths in import.io to make APIs for this kind of thing all the time, It's just a matter of finding a xPath that's generic enough to find the HTML no matter where it is on the page, but being specific enough to get the right data.

MVC Framework - Server-side DOM manipulation

I'm building an MVC framework, and I'm looking for native solutions / frameworks / tag libraries to draw from or to replace my framework entirely.
I'm interested in the following features specifically:
server-side DOM manipulation
server-side events (page reload, form submit, node insertion, etc.)
traversing the DOM tree using css selectors
validation of html nodes nesting
validation of html nodes allowed attributes
support for tag libraries / user controls
Pretty much what you get with JavaScript, but on the server-side and with some little extras.
Any solution will do (even if partial), any language will do, any pointers are appreaciated (even from client-side languages, as long as it's possible to check the source code). Dealing with malformed html is not a prerequisite. Outputting valid markup is a big plus.
Please offer practical solutions by pointing the language/framework that is being discussed and, if possible, what features it provides.
have you checked out aptana jaxer?
If you load your page into a DOM-parser you would be able to modify it from there. Then outputting it to the output buffer seems trivial.
But you would need to store the entire document in memory, which will inflict on the performance.
So, jQuery has a sort of selectors API implemented, I guess I can take a look at their source code. Also, PHP has support for XPath, this could help too.
Found a php html dom parser that also implements some html selectors here: http://simplehtmldom.sourceforge.net
Fizzler uses HTMLAgility pack and adds a server side queryselectorall to provide css selection: http://code.google.com/p/fizzler/
Maybe you are looking for ItsNat

Resources