[JET2] Generating multiple files from an input model [message #29338] |
Fri, 27 July 2007 11:41 |
Joaquin Cañadas Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hello,
I need to generate multiple files from an input model, one for each
"concept" in the input model. For example, my input model is as follows:
<?xml version="1.0" encoding="ASCII"?>
<KnowledgeModel name="MyKM">
<concepts name="Person">
<attributes name="firstName"/>
<attributes name="address"/>
</concepts>
<concepts name="Product">
<attributes name="code"/>
<attributes name="productName"/>
</concepts>
</KnowledgeModel>
I would like to generate several files (*.java), one for each concept in
the input model (Person.java, Product.java, and so on). The main.jet
template use a <ws:file ...> tag to set the target file, but, it is
possible to set the target file dynamically when the input model is
being processed? I mean, something like that:
<c:iterate select="/KnowledgeModel/concepts" var="curConcept">
<%-- name of target file:
<c:get select="$curConcept/@name"/> + ".java" --%>
<%-- I pseudocoded "+" as a concatenation operation --%>
<%-- create the target file --%>
<%-- write code in the target file --%>
</c:iterate>
Thank you
Joaquín
|
|
|
Re: [JET2] Generating multiple files from an input model [message #29376 is a reply to message #29338] |
Fri, 27 July 2007 12:06 |
Joaquin Cañadas Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hello again,
my problem is perfectly explained in the tutorial Create more -- better
-- code in Eclipse with JET:
http://www-128.ibm.com/developerworks/opensource/library/os- ecl-jet/
Sorry !
Joaquín
Joaquín Cañadas escribió:
> Hello,
> I need to generate multiple files from an input model, one for each
> "concept" in the input model. For example, my input model is as follows:
>
> <?xml version="1.0" encoding="ASCII"?>
> <KnowledgeModel name="MyKM">
> <concepts name="Person">
> <attributes name="firstName"/>
> <attributes name="address"/>
> </concepts>
> <concepts name="Product">
> <attributes name="code"/>
> <attributes name="productName"/>
> </concepts>
> </KnowledgeModel>
>
> I would like to generate several files (*.java), one for each concept in
> the input model (Person.java, Product.java, and so on). The main.jet
> template use a <ws:file ...> tag to set the target file, but, it is
> possible to set the target file dynamically when the input model is
> being processed? I mean, something like that:
>
> <c:iterate select="/KnowledgeModel/concepts" var="curConcept">
> <%-- name of target file:
> <c:get select="$curConcept/@name"/> + ".java" --%>
> <%-- I pseudocoded "+" as a concatenation operation --%>
> <%-- create the target file --%>
> <%-- write code in the target file --%>
> </c:iterate>
>
> Thank you
> Joaquín
|
|
|
Powered by
FUDForum. Page generated in 0.04002 seconds