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 — LiveJournal
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 31 | 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.

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.
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.
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.
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. :-/
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 31 | Write