Log in

No account? Create an account
entries friends calendar profile Previous Previous Next Next
This is an ex-HTML - shadows of echoes of memories of songs
This is an ex-HTML
Okay, I think I'm going mad. I put the following into our CMS:
<li> Item 1
<li> SubItem 1</li>
<li> SubItem 2</li>
<li> Item 2</li>
and it (silently, without any notification) 'corrected' it to the following:
<li>Item 1
<li>SubItem 1</li>
<li>SubItem 2</li>
<li>Item 2</li></ul>
I pointed this out to the people who are setting up the new site for us, and they raised it as a support call with the CMS people, and got the following response:
"Could you please use the following schema:

<li>Item 1</li>
<li>SubItem 1</li>
<li>SubItem 2</li>
<li>Item 2</li>

Such syntax is formatted correctly."
If such syntax is formatted correctly, why doesn't it validate? I'm not even trying to be a validation Nazi about this (it's not as if anything that comes out of this CMS is ever going to validate anyway), it's more that I don't really want to have to 'correct' all our existing HTML to prevent it being 'corrected' by the CMS.

Tags: ,

Read 32 | Write
From: stephdairy Date: March 20th, 2007 09:48 am (UTC) (Link)
I don't see why their option shouldn't validate. Both it and your original version are valid HTML 4 (though only theirs is also valid XHTML).

Their CMS's behaviour is reminiscent of that of LJ's HTML "fixer" which spews out a load of close tags for any elements you may have forgotten to close at any point in the rest of the document...

I'd say this "miscorrection" is a bug in the CMS, unless the CMS is expecting to deal with XHTML.

j4 From: j4 Date: March 20th, 2007 09:56 am (UTC) (Link)
Okay, now I'm even more confused. Is this article* just fibbing when it says that a nested list like my original is 'correct' for XHTML? (NB my example does close the <li> for Item 1, after the <ul> which it contains.)

* I'm not saying that it's an authoritative source, but.
fanf From: fanf Date: March 20th, 2007 10:10 am (UTC) (Link)
I agree with you and the article you link to. The HTML 4.01 DTD says that the only elements allowed within an <ol> or <ul> are <li>, so nested lists have to go within list items.

From: stephdairy Date: March 20th, 2007 10:13 am (UTC) (Link)
No, I just misread your example. Perhaps I should just shut up until I've drunk my coffee.

The HTML 4.01 Strict DTD allows LI to contain almost anything, including UL. (Curiously I can't see anything that allows a UL to contain another UL or OL, but see my comment about coffee...)

bellinghman From: bellinghman Date: March 20th, 2007 09:53 am (UTC) (Link)
Hmm, their example is valid according to what I see on the W3C site, but marked DEPRECATED.
  1. The </li> isn't required
  2. You can dump a sublist in without a <li>!
  3. lists will sometimes run backward!
chrisvenus From: chrisvenus Date: March 20th, 2007 10:37 am (UTC) (Link)
I'm not sure about number 2. Because you don't know where the implicity /li is going in you can't say that the sublist isn't in it really.

Certainly my reading of the usage at http://www.w3.org/TR/html401/struct/lists.html#edef-UL implies to me that ULs and OLs may only contain LIs and that LIs may contian any flow type stuff (which would include ULs and OLs). I don't think there is a valid deprecated usage where a UL or OL could be in another one of them without being inside an LI as well.
bellinghman From: bellinghman Date: March 20th, 2007 10:49 am (UTC) (Link)
Ah, bugger.

The deprecated example has omitted </li>, so the sublist is effectively within a <li>. Which just goes to show that omitting close attribute tags is stupid and should always have been banned.
chrisvenus From: chrisvenus Date: March 20th, 2007 10:52 am (UTC) (Link)
I agree. The only time it should have been acceptable was for self closing tags like br and hr where a closing tag doesn't make sense. And even then it would have been nicer if they'd enforced making them self closing since if they'd introduced it at the beginning nobody would have had a problem with it. Damn them all. :)
bellinghman From: bellinghman Date: March 20th, 2007 10:56 am (UTC) (Link)

Hence the distinction between 'attribute' tags (forgive me if I don't use correct terminology here) and br. And hr, which I didn't remember.

<br/> style self-closing would have been good, too, but I can understand them not getting that first time round.
barnacle From: barnacle Date: March 20th, 2007 10:52 am (UTC) (Link)
Their option is dead wrong. But your option may be failing because they might be doing DTD validation and I don't know enough DTD language to be sure that it's right. There's a condition that might mean that li elements can contain EITHER block content (div, p etc.) or inline content (plain text, span, label, b, i, em, a etc.) but not both.



<!ENTITY % flow "%block; | %inline;">
<!ELEMENT LI - O (%flow;)* ...

The dash and the O means that the opening LI tag is required and the closing is optional. That seemss ambiguous depending on your SGML parser's behaviour and how it treats the binding there. As I say, I don't speak DTD or SGML well enough, but that could be interpreted as "any number of either-block-or-inline elements" or "either any number of block elements or any number of inline elements."

The schema also may be tight: http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd creates a complexType called Flow which can be any one of four choices. I think choice means it has to be a single one of them, but then that one can occur multiple times. So multiple elements from the block or inline groups, but not a mixture.

Try wrapping everything within the LI in a DIV and see where that gets you.
j4 From: j4 Date: March 20th, 2007 11:08 am (UTC) (Link)
I'm pretty sure "%block;|%inline;" is either-but-not-both, BICBW (I haven't used SGML DTDs in anger since 2003).

The CMS claims that what it's producing is XHTML. <html xmlns="http://www.w3.org/1999/xhtml">

    is block, not inline - isn't it? - so I'm not sure why wrapping the
      in an
    • inside a
      would be different. Or am I missing your point? I'm getting increasingly confused here. :-(
barnacle From: barnacle Date: March 20th, 2007 12:12 pm (UTC) (Link)
Me too. Do you think LiveJournal 0.2 will use something like wiki-ish?

If %flow; is %block;|%inline;, then it's either but not both. But then what does (%flow;)* mean, which is the content of LI elements? Does it mean lots of block XOR lots of inline, or does it mean lots of things, each of which can either be block or inline? My answer is a shrug.

It seems that DTD and schema validation could produce different results with your version. Given that in the schema Flow is an extension of a complexType (which can contain #PCDATA), then yours should work there; in the DTD (%flow;)* might match something that itself matches %inline;%block;, or it might not.
j4 From: j4 Date: March 20th, 2007 12:27 pm (UTC) (Link)
Oh, arsebiscuits, sorry about LJ's HTML-eating, there; there really really needs to be a "verbatim" setting where nothing gets auto-interpretedbollocksed. (I suppose the standard OSS answer applies: if I want it, I should write it rather than whinging.) Did what I said make any sense in the email notification?

Coming back to yer blocks/inlines, I am pretty sure (after some hasty revision of what SGML knowledge I used to have) that %block;|%inline means one-or-more block XOR one-or-more inline.
From: rgl Date: March 20th, 2007 11:20 am (UTC) (Link)
I don't think wrapping it in a DIV will help: the definition of %inline; includes #PCDATA, which makes it a Mixed Content Model and means you can have text arbitrarily intermingled with the various options specified in the definition of %inline;.
barnacle From: barnacle Date: March 20th, 2007 12:00 pm (UTC) (Link)
Yes, I know. "<li><div> fooItem 1> ... </ul> </div>", would be an option to get round the li's requirements, though. I don't know about the content in div: that might be "Flow" too.
barnacle From: barnacle Date: March 20th, 2007 12:05 pm (UTC) (Link)
Rrgh. Bloody LiveJournal's halfway-house HTML comprehension nubbins bollocks ARGH.
jvvw From: jvvw Date: March 20th, 2007 11:14 am (UTC) (Link)
Sounds very much like a bug in the CMS and that the CMS folk don't really know what they're talking about it. I'd try and raise it as a bug through whatever channels there are, explaining that their syntax isn't valid HTML citing the stuff you have here and then just accept that you'll probably have to workaround it (what CMS are you using out of curiosity?)
j4 From: j4 Date: March 20th, 2007 11:19 am (UTC) (Link)
I'd try and raise it as a bug

I'd feel much more confident about doing that if my readership had reached a consensus on whether the auto-corrected version and/or the suggested correction were correct or not. :-/

what CMS are you using out of curiosity?

Sitecore. It's probably very nice if you want something that looks/feels like Windows XP and which doesn't require you to see any of those nasty angle-brackety things. :-/
From: rgl Date: March 20th, 2007 11:24 am (UTC) (Link)
I'm pretty much positive that your version is right and theirs is wrong. I tend to use http://validator.w3.org to get a definitive answer on such things, though it only works with complete pages rather than fragments.
j4 From: j4 Date: March 20th, 2007 11:38 am (UTC) (Link)
I've wrapped that fragment in a test page and you're right, it doesn't validate.

Now, how do I go about telling software developers who are senior to me (and who know I'm not in a "technical" role) that they're wrong?
barnacle From: barnacle Date: March 20th, 2007 12:06 pm (UTC) (Link)
"Can you clarify what you mean by valid, as this seems to fail on the W3C validation test server?"

"Clarify" is a great word for this situation.
j4 From: j4 Date: March 20th, 2007 12:10 pm (UTC) (Link)
Magic - thank you!

(I'm afraid all my politeness generators are out of whack at the moment, as a bug in the code means that they convert everything to "AGGGGHHHHHH! COCKING COCKMONSTERS!" - which is formatted correctly.)
barnacle From: barnacle Date: March 20th, 2007 12:59 pm (UTC) (Link)
Interestingly, I got that error from gcc only last week. Apparently your cock has to be UTF-8, and bend in the middle like a real cock should.
ewx From: ewx Date: March 20th, 2007 02:43 pm (UTC) (Link)
UTF-8 cocks are also self-synchronizing, which is convenient.
j4 From: j4 Date: March 20th, 2007 03:01 pm (UTC) (Link)
I'm not sure I'm following all this stuff about how UTF-8 cocks work... do you think you boys could show me?
imc From: imc Date: March 20th, 2007 03:40 pm (UTC) (Link)
barnacle From: barnacle Date: March 20th, 2007 05:11 pm (UTC) (Link)
That's straight out of the ISO-8859-COCK codepage. In UTF-8 you'll need:

0xE2 B3
j4 From: j4 Date: March 20th, 2007 05:39 pm (UTC) (Link)
It's an optical illusion, right? I mean, they're actually both the same size.
barnacle From: barnacle Date: March 21st, 2007 05:07 pm (UTC) (Link)
Yeah, when they're in use, but the second cock takes up more storage space while being in theory more portable across cockplementations.

It's one step in undoing the damage caused by the Tower of Cockle.
(Deleted comment)
ewx From: ewx Date: March 20th, 2007 11:58 am (UTC) (Link)

You're right that their suggestion is broken; UL contains one or more LI but not another nested UL. (The same rule makes the empty UL illegal, too.) It sounds like their software has a completely broken model of UL.

Given the syntax they suggest is invalid, presumably browsers are allowed to do anything they like with it, so any possible choice of eventual displayed output would be "formatted correctly".

redbird From: redbird Date: March 20th, 2007 12:07 pm (UTC) (Link)
You could send them back a note saying, as politely as you can manage, that the syntax you're entering and the CMS is refusing is valid HTML, and that their suggested fix is not good HTML, even though the CMS accepts it, as shown by the validator.

It may fit some local DTD, but HTML is not SGML, and you presumably are working on something that will be seen by outsiders and run through browsers that don't have your DTD.

[It's too early in the morning for me to find the politic phrasing; some mention of the fact that you know they didn't create the CMS might help.]
Read 32 | Write