[Typo3-dev] TYPO3 and XHTML

Sebastian Roth sebastian.roth at gmail.com
Wed May 11 09:46:26 CEST 2005


Good morning,

On 5/11/05, Christopher <tombedlam at yahoo.com> wrote:
> I hate seeing markup in program code, so I've done some
> preliminary work on a class like this - almost exactly as you
> describe it in fact. The code

Removing markup from code would make the entire system much more
modular. (like css does with xhtml). So there is a need for an
appropriate technique.

> basically revolves around an array of the html elements each of
> which contains an array of attributes and properties (such as
> whether or not there is a closing tag needed for the given element).
> In addition, there are a few basic functions for opening tags, closing
> tags, quoting attributes etc that get re-used throughout the class.
> It also checks the current doctype to determine how to correctly
> output the tags (question about this: I'd like to have the script parse
> the appropriate dtds; can anyone direct me to a reference that
> would describe how to do this?)

To do that, you need to fetch the entire document structure and
validate your part of it against its position inside.
"
% wc -l /usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd
978 /usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd
"
I'll be definitely slow when doing the validation for each element.
Doing it for the entire document sounds better, but is already done by
tidy.

> usuall markup situations, but it's not suitable for viewing without a
> re-write or at least a cleanup, but I have managed to output
> correct markup in all the major situations I could think of (which
> does *not* include complex nesting arrangements - though it
> might work, I'm not sure).
> 
> You basically call the functions like this:
> 
> $testOutput = $this->buildDouble("comment","","Script output:")
>   .$this->buildSingle("img",$imgAttributes,0)
>   .$this->buildSingle("br","",3)
>   .$this->buildSingle("mEta",$metaAttributes,2)
>   .$this->buildDouble("comment","",$commentContent)
>   .$this->buildDouble("P","",$pContent)
>   .$this->buildDouble("comment","","Script output: END");
> 
> ...and you can probably guess what the output would look like ;-)

Hm, this sounds imho like an job for xml/xslt. Still not efficient
enough but clean.
$x  = do_xslt( sprintf( '<para><image html:id="yeh"
source="%s"></para>', $src ) );
But this would (in case of the image) also invole extending of the
xslt parser. (to automatically set height/width settings for example).
Doing it with those tools would also open the door for PDF/SVG more
directly. (i thought about xsl:fo or something the apache guys use).

I also see a place to optimize by creating md5sums (or something
faster/quicker) of the first argument to do_xslt and the current
typeNum. We than could store it in binary form in the database & save
some extra bytes.

One of the biggest problems when using xslt could be that we increment
the number of required packages (external modules) by 1.

Another problem would be the usage of 'rte'. But this should be
manageable via xslt (we can define `filters`).

> If the performance hit could be shown not to be too severe, I think
> something like this could solve a number of small but aggravating
> problems...

I agree also that separation of content & output is the key, also in
extensions & code. Why not doing it the elegant way now? :)

Seb.




More information about the TYPO3-dev mailing list