Re: [xml] XHTML Doc serialization and meta element



Daniel Veillard wrote:


 Just trying to follow the best practices outlined by XHTML1 W3C spec
   http://www.w3.org/TR/xhtml1/#C_9
Modifying the document is not ideal I agree, but it's simpler than trying to
get all user application fixed !

 "Problem with this is if a meta element already exists"
Which meta ? there is a zillion of those possible. Things are always clearer
with a complete example.
Sorry thought I had been clear on that.
The following document is manually built via the API (this is why the double free as the meta element is created and not being freed until after the doc was serailized - but was already freed from the serialization) then xmlDocDumpFormatMemory is called:
Origional doc that was built:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
     <title></title>
  </head>
</html>

Results of output - excluding the crash part :):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <title></title>
  </head>
</html>

htmlSetMetaEncoding creates a new meta element and kills the old one.

In reality, there should be no meta tag since it's mime type is going to be application/xhtml+xml. http://www.w3.org/TR/xhtml-media-types/#application-xml as that also applies to this type as well.

Reading http://www.w3.org/TR/xhtml1/#C_9 it states:
"Note: be aware that if a document must include the character encoding declaration..." So it is not required to do this, but I dont think changing the default behavior is a good idea for exactly the reason you mention.

Was wondering if it would be possible (or even makes sense) to modify some behavior though. For example what if the format flag was re-purposed, allowing a new htmlSetMetaEncoding function that takes the flags (and would be called from the output functions passing the format flag from the save context or just call the new function if format has whichever flag, etc...) and if flag & NO_TREE_MOD (something like that) would only create a meta element if one is not found or possibly even not creating one at all which would allow the calling application then to determine if a meta element should be created or not. Could easily combine the 2 functions, the existing htmlSetMetaEncoding and a new one where origional one just calls the new one with no flags.

I wouldnt mind having to check if doc is xhtml and then calling htmlGetMetaEncoding. If no encoding the app could then handle the issue ints it own fashion and then set the format flag appropriately for the output function.

Just an idea unless someone has any other ways this might be handled.

Rob






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]