Am 27.01.2008 um 19:25 schrieb Kornel Lesiński:

On 11.01.2008, at 23:30, Rodrigo Moraes wrote:

Hello,
Today I finally created a demo of PHPTAL working with a PHP DOM
parser, and sent it to a temporary GoogleCode repository. Here's the
project:

http://code.google.com/p/phptalwithdom/
[...]

that's it. let me know what do you think. :)

I've created a new branch based on your code and added bunch of bugfixes:
https://svn.motion-twin.com/phptal/branches/withdom

Unfortunately it still doesn't work quite right (see tests/run- tests.php script).

PHPTAL's code-generator expects elements and attributes to have namespace prefixes, which were added as neccessary by the parser. DOM of course doesn't do this, which causes a lot of bugs and confusion. Handling of namespaces has to be fixed throughout the code before real DOM can be supported.

There are issues with DOM itself:
- it doesn't report line numbers for elements, so error messages (other than parse errors) can't include them. Not very user- friendly :(

It does! Just need to disable libxml error reporting, so no warnings etc are generated, then pull the errors by hand. See http://trac.agavi.org/browser/tags/0.11.1RC1/src/config/AgaviXmlConfigParser.class.php#L105 for an example.

- non-validating parser can't support named entities (like  ), but users will expect them to work. Switching to validating parser is not an option, because it will reject incomplete HTML fragments and PHPTAL elements.

That is possible as well. Just need to tell DOM to resolve externals and validate against them (= doctype). I think we can expect people to write well-formed XML.

- parser decodes numeric entities and represents them as literal characters, possibly exposing encoding issues.

Eh? what do you mean. As long as the charset info is correct, everything is fine. IIRC libxml will even read a charset value from a meta tag in an XML document that it recognizes as XHTML.


On a different topic, I really think we should use this DOM parser approach as the foundation for a completely new PHPTAL. There are some things that I think would be worth changing, for instance we should mandate the use of braces in function calls. That not only allows passing of arguments properly, it also eliminates the need of runtime evaluation of the type of the given element (array index, object property, object method). Not sure why it is as it is right now, but the "original" TAL uses braces for method calls, too, IIRC.


David
_______________________________________________
PHPTAL mailing list
[email protected]
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to