[Zope3-Users] emacs with metal and tal namespaces

Perry Smith pedz at easesoftware.com
Sun Oct 29 11:20:42 EST 2006


On Oct 24, 2006, at 1:51 PM, Fred Drake wrote:

> On 10/24/06, Perry Smith <pedz at easesoftware.com> wrote:
>> I am using nxml-mode in GNU emacs to edit the zcml files as well  
>> as page
>> template files.  I picked up the schema for zcml.  All that works  
>> fine.  Has
>> anyone done a schema for the metal and tal name spaces?
>
> I'm not aware of one being done.  This would be a welcome  
> contribution.

I got up today ready to tackle this.  But, I may have succeeded by  
finding a trivial solution or I may have utterly failed.

To quickly get to the gist, if you add the namespace definitions in  
the first tag, then the nxml-mode in emacs is content.  I have an  
example of this at the end of this note.

I bumped into two problems that stumped me.  First, it is general  
practice to do:

<metal:arbitrary_tag define-macro="page">
   ...
</metal:arbitrary_tag>

Second, metal and tal constructs are attributes that are placed  
inside any tag.

The schema specifications imply that things are very strict.  Zope  
and the key to the tag attributes is that these attributes can be put  
into the xml documents, effectively violate the base schemas, but  
since no one is checking, they produce the desired results.  (Also, I  
have not looked but probably by the time the document is sent out,  
all the tal and metal attributes have been stripped.)

So, to really do this properly, each schema that the tal or metal are  
going to be used in would need to be modified to allow the tal and  
metal attributes.  The RNC syntax does have a funny include construct  
that allows overriding constructs that are defined in the included  
file.  But, that only means that it would be possible to create a  
maintenance nightmare if someone wanted to do that.

Fortunately, the emacs checker is as simple as all the other  
checkers.  I discovered that I only need to change this:

<metal:block
     define-macro="page">
   <html
       xmlns="http://www.w3.org/1999/xhtml"
       xml:lang="en"
       lang="en">
  ...
   </html>
</metal:block>

(which emacs does not like) To this:

<metal:block
     xmlns:metal="http://xml.zope.org/namespaces/metal"
     xmlns:tal="http://xml.zope.org/namespaces/tal"
     define-macro="page">
   <html
       xmlns="http://www.w3.org/1999/xhtml"
       xml:lang="en"
       lang="en">
  ...
   </html>
</metal:block>

Which is probably a good idea anyhow.  Maybe the first example is  
frowned upon.  I got it from various tutorials.  But, as we can see,  
the namespace of metal and tal is never defined in the examples that  
I've been looking at.

I hope this helps.
Perry Smith
Ease Software, Inc.
pedz at easesoftware.com
http://www.easesoftware.com

SATA Products for IBMs RS/6000, pSeries, and AIX systems



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20061029/76b8ed95/attachment.htm


More information about the Zope3-users mailing list