You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sanket Pattekar <sa...@gmail.com> on 2006/08/07 09:02:44 UTC

Accessing XML File input module inside a flowscript

Hi,

Is it possible to access a XML File Input module inside a flowscript.
Is so how this can be done.

Thanks n Regards,
Sanket

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Converting string to array in jxtemplategenerator

Posted by Alberto Brosich <br...@units.it>.
I need to convert a string (words delimited with commas) in something 
that "jx:forEach" can iterates.
I found a nice example in documentation 
(http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html).

<jx:macro name="forTokens">
  <jx:parameter name="var"/>
  <jx:parameter name="items"/>
  <jx:parameter name="delims"/>
  <jx:forEach var="${var}" 
         items="${java.util.StringTokenizer(items, delims)}">
    <jx:evalBody/>
  </jx:forEach>
</jx:macro>

<forTokens var="letter" items="a,b,c,d,e,f,g" delims=",">
  letter = ${letter} <br/>
</forTokens>

I try it and something simpler:

<jx:forEach var="field" 
items="${java.util.StringTokenizer('name,lastname',',')}" 
varStatus="status">
   <rfc:row id="${status.count}">
        <rfc:field name="FIELDNAME">${field}</rfc:field>
   </rfc:row>
</jx:forEach>


Both doesn't work; field variable has never a value.

What's wrong? Is there another way?

Alberto

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Accessing XML File input module inside a flowscript

Posted by Niels van Kampenhout <n....@hippo.nl>.
Sanket Pattekar wrote:
> Hi,
> 
> Is it possible to access a XML File Input module inside a flowscript.
> Is so how this can be done.
> 
> Thanks n Regards,
> Sanket

Hi Sanket,

Yes that is possible. You need to import the ImportModule class in your 
flowscript:

importClass(Packages.org.apache.cocoon.components.modules.input.InputModule);

Then do something like this:

var module = cocoon.getComponent(InputModule.ROLE + 
"Selector").select("mymodule");
var value = module.getAttribute("/any/xpath", null, null);

Regards,
Niels ;-)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org