[AWS] [Template Parser] How to use Cursor_Tag
Mathieu Benard
mat.benard at gmail.com
Fri May 7 15:04:45 CEST 2010
Pascal :
This looks like a matrix, no?
>
> If MSG_NAME is a vector : "v1" & "v2"
>
> and WORD_NAME a vector of vector:
> "n1.1" & "n1.2"
> "n2.1" & "n2.2"
>
> Then:
>
> @@TABLE@@
> <message name="@_MSG_NAME_@">....
> @@TABLE@@
> <word name="@_WORD_NAME_@">....
> @@END_TABLE@@
> @@END_TABLE@@
>
> will be transformed as:
>
> <message name="v1">....
> <word name="n1.1">....
> <word name="n1.2">....
> <message name="v2">....
> <word name="n2.1">....
> <word name="n2.2">....
>
> Isn't this what you want?
>
Yes, actually it's what I wanted. I tried and it works perfectly. However,
the complete structure is a bit more complexe and my example was not
exhaustive. The structure is actually a tree. Thus, messages contain words,
but words contain fields and so on. So, there are a lot of composition
levels to deal with.
> Actually, I don't know how I could find the good words matching a given
> > message. Moreover, a given word could belong to many different messages.
>
> Not sure I understand this.
>
You're right, it was not clear at all. Actually, I just wanted to say that
one instance of word may appear in several messages.
Ex :
<message name="m1">
<word name="w1">
<message name="m2">
<word name="w1">
Thus, in the vector tag, word w1 will be duplicated and I 'd like to find a
way to avoid this redundancy. I don't know if it's clearer now, but anyway,
with your example it works well.
Thomas :
If you intend to create very complex XML structures, I'll advice you
> to use XML/Ada instead:
>
> http://libre.adacore.com/libre/tools/xmlada/
>
> templates_parser is a great template engine, but for very complex
> output you might find it's simple vector/matrix tags and @@TABLE@@
> construction a bit "lacking".
>
Actually, the goals of my project are not limited to generate xml files
but also ada source code, test code and even documentation based on
templates.
To achieve this, I have two inputs : an xml file which contains data and
templates files.
I already use XMLada (SAX api) to retrieve data from the xml input, but I
have to use my own internal data structure in order to instanciate
templates, this reason make the use of the Templates_Parser adequated.
Finally, I can achieve my goals with vector/matrix tags, but I think that
cursor_tag would be more efficient, if they allow to iterate on data
structure (ada record).
Thanks for the answers,
Regards,
--
Mathieu Bénard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/aws/attachments/20100507/ab9fa427/attachment.html
More information about the AWS
mailing list