Hi Manuel,

On Thu, Aug 2, 2012 at 11:28 PM, Manuel H <m...@codeless.at> wrote:
>
> This is my first post on the list,

Welcome!

> But my current main problem is that i seem unable to loop through
> definitions. I would be glad for any help on this. My XML definitions
> are:

xml2ag -O joomla.def joomla.xml yields:
/* Parsing file joomla.xml */
AutoGen Definitions joomla-2.5.6.tpl;
XML-version = '1.0';
XML-URL = 'joomla.xml';
XML-standalone = true;
template = 'joomla-2.5.6.tpl';
defaults = {
  content = '';
  language = 'en-GB';
  category = {
    content = '';
    status = 'published';
  };
};
categories = {
  content = '';
  category = {
    content = '';
    title = 'News';
    text = 'Description';
    category = {
      content = '';
      title = 'Media';
    };
  };
  category = {
    content = '';
    title = 'Internals';
    text = 'Description';
  };
};

> My Template is:
>
> [+ AutoGen5 template sql +]
> [+ (get "template") +]
> [+ (get "defaults.language") +]
> [+ IF (len "categories") >= 1 +]
>         [+ # Loop through categories +]
>         [+ # FOR categories.category +]
>         [+ # FOR categories.category (for-from 0) (for-to (len
> "categories.category")) +]
>         [+ FOR categories.category (for-from 0) (for-to 2) +]

http://www.gnu.org/software/autogen/manual/html_node/AGMacro-syntax.html#AGMacro-syntax
says:

2. AutoGen FOR macros must be in one of three forms:
        
  FOR <name> [ <separator-string> ]
  FOR <name> (...Scheme expression list)
  FOR <name> IN <string-entry> [ ... ]
  where:
    ‘<name>’  must be a simple name.

In other words, you cannot use categories.category.
Instead, just use nested invocations of the first form:

[+ FOR categories +][+ FOR category +] ... [+ENDFOR+][+ENDFOR+]

Also, the conditional ``[+ IF (len "categories") >= 1 +]'' is
both unnecessary and incorrect.  The FOR won't iterate over
categories if there aren't any.  The correct spelling is:

    [+ IF (>= (len "categories") 1) +]

It has to be a valid Guile/scheme expression.

>                 [+ categories.category.title +]

If you are wanting the title for the current category, lose the
name qualifications.  The search for this three part name will fail
at the current ("category") level, try and fail at the "categories"
level and succeed at the top level.

>         [+ ENDFOR categories.category +]
> [+ ENDIF +]

> Thank you in advance!

You're welcome.  Good luck!  Cheers - Bruce

P.S. using another variant of the template:

$ cat joomla-2.5.6.tpl ; autogen joomla.def;cat joomla.sql
[+ AutoGen5 template sql +]
[+ (get "template")      +]
[+ (get "defaults.language") +]
[+ FOR categories        \+]
[+    FOR category       \+]
        [+ title          +]
[+    ENDFOR             \+]
[+ ENDFOR categories      +]
joomla-2.5.6.tpl
en-GB
        News
        Internals

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Autogen-users mailing list
Autogen-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/autogen-users

Reply via email to