views:

20

answers:

3

I am using Agavi with Doctrine. The master template fails to load at times with a AgaviParseException listing out all instance of  . I'm using the latest stable versions of all technologies.

A: 

Use   for non-breaking space. You need to have valid XHTML in your template probably. Refer to this chart for reference.

Ashish
The chart is handy and this solves it.
A: 

While I'm not too familiar with the tools you are using, it seems to me that the XML entity for   cannot be found. You can either include the XML entity, or you should use   instead. The reason is: there are only five predefined XML entities, all others you need to include when doing XML or XHTML (while browsers are generally more lenient).

They are part of the following for XHTML:

PUBLIC 
   "-//W3C//ENTITIES Latin 1 for XHTML//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"

and mark the following quote about XHTML when parse by an XML parser:

If the document is read by an XML parser that does not or cannot read external entities, then only the five built-in XML character entities (see above) can safely be used, although other entities may be used if they are declared in the internal DTD subset.

However, if the typo above is on purpose, it may also mean that you miss the ; at the end of the &nbsp.

Abel
Ah, good to know, well then, include the entity or the external reference to get it parsed more easily and keep using ` ` instead of the unreadable ` ` or ` ` (these two are equal)
Abel
Do not do this. It will cause libxml to resolve entities against this external DTD, which means that unless you have a correctly set up XML catalog in your system, it will pull the DTD over the network every time it parses the document. Bad idea.
dzuelke
@dzuelke: That's new to me and not caching it is against the XML implementation recommendations. Many systems just recognize the external entity already and resolve it to a pre-installed local file (recommended approach by XML committee, apparently doesn't work with PHP). Note that the XML definition does not say that the location must be downloaded at all, it's a placeholder, not necessarily a real location (but unfortunately that's often misunderstood, even by many implementations).
Abel
PS: on a side note, my answer suggests to implement the entity, by pointing to its definition. But if you have many named entities, resolving by hand is not feasible, in which case you should include the entities file.
Abel
A: 

I don't know what the exact problem is (please always post exception messages and other helpful information when asking questions like these), but there is really only one way for this problem to occur.

It is not the Master template failing to load, it is the form handling system that is unable to parse the complete generated output (so it can re-fill a form for you, or insert error messages from validation) in the faster and simpler XML parsing mode. In XML parsing mode (which you'd usually use for XHTML), it doesn't validate against a DTD by default, so it only knows the standard XML entities (&, ", ', < and >). HTML parsing mode doesn't have that problem. You could force Agavi to use it, but it auto-detects usage of HTML or XHTML and selects the correct mode, so that probably would not be a good idea, especially since libxml's HTML parsing can be a bit wonky at times (libxml is used by PHP's DOM implementation; most restrictions or bugs in parsing and handling of the forms are due do libxml - look at AgaviFormPopulationFilter.class.php if you want to get an idea of the workarounds that are already in place to deal with different versions of libxml and their behavior, like inserting double XML prologs when saving, breaking CDATA sections, or other weird stuff).

Anyway, I assume you are using UTF-8 in your documents, so there really is no need to use any entities for characters like "©" or "«" - you can insert them literally instead of using © and so forth. The only exception of course is a non-breaking space, which is a bit hard to see and distinguish in an editor, but as pointed out in other comments, you can use the numeric equivalent   here.

dzuelke
By the way, the Agavi users mailing list is also a good place to ask questions like these (http://www.agavi.org/support).
dzuelke