- From: Thomas Broyer <t.broyer@gmail.com>
- Date: Thu, 9 Sep 2010 20:01:45 +0200
On Thu, Sep 9, 2010 at 6:37 PM, Rostislav Hristov wrote: > I'm actually looking into manually editing these in an authoring > environment and this is why I want them to be valid. > > The parsing section looks fine but it doesn't help in this case. Yes, sorry, I was thinking in terms of "parse errors". I think there's no answer to your question, as validity of a DOM subtree depends on where you attach it: for instance, "<span>foo</span>" would be valid if put inside a <p> (in an already valid document), but not if put inside, say, a <tr>. And it's a simple example. You'd have to provide a "context" for validating your HTML fragment, just like when parsing the fragment. I think the best you can do is to parse the fragment using the spec'd algorithm (if you're not already dealing with a DOM tree) and then attach the result to a simple HTML document (containing a <title> and providing the "context" you want to validate the fragment in); but even that would not cover all cases and your fragment could very well turn into something invalid when put in some documents (duplicate IDs, <footer> inside a <footer>, sectionning content inside an <address>, something not an hN inside an <hgroup>, etc.) -- Thomas Broyer /t?.ma.b?wa.je/
Received on Thursday, 9 September 2010 11:01:45 UTC