cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roy huang" <lingererhu...@hotmail.com>
Subject [Help][CForms]About insert-node
Date Mon, 28 Jun 2004 02:23:39 GMT
I have posted this in user list but no one answer,so post here again,sorry.
>>>>>>>>>>>>>>>
Hi,all:
    I'm writing a tools base on form-gui but editing data binding file.All's fine but one
problem make me stuck.
    In one binding file value may need convert like:

  <fb:value id="created" path="created">
   <fd:convertor datatype="date">
    <fd:patterns>
     <fd:pattern>yyyy-MM-dd</fd:pattern>
    </fd:patterns>
   </fd:convertor>
  </fb:value>

 and if no convert is needed it may look like:
  <fb:value id="created" path="created">
  </fb:value>

 Basing form-gui sample,I define my edit-form define like:
      <fd:struct id="value">
       <fd:label>Value</fd:label>
       <fd:widgets>
        <fd:new id="direction-class" />
        <fd:new id="id-class" />
        <fd:new id="path-class" />
        <fd:new id="datatype-class" />
        <fd:new id="convertor-class" />
       </fd:widgets>
      </fd:struct>

and binding define lookes like:

 <fb:class id="value-class">
  <fb:case id="value" path=".">
   <fb:insert-node>
    <fb:value/>
   </fb:insert-node>
   <fb:struct id="value" path="fb:value">
    <fb:value id="id" path="@id" />
    <fb:value id="direction" path="@direction" />
    <fb:value id="path" path="@path" />
    <fb:value id="datatype" path="fd:convertor/@datatype" />
    <fb:value id="convertor" path="fd:convertor/fd:patterns/fd:pattern"/>
   </fb:struct>
  </fb:case>
 </fb:class>

it can display well,but when I save it,error occoured:

org.apache.commons.jxpath.JXPathException: Exception trying to create xpath fd:convertor/@datatype;
Cannot create an attribute for path /fb:value[1]/fd:convertor/@datatype, operation is not
allowed for this type of node

I must change    
<fb:insert-node>
    <fb:value/>
</fb:insert-node>
to:
   <fb:insert-node>
    <fb:value>
        <fd:convertor/>
    </fb:value>
   </fb:insert-node>
to solve this problem,but this also make <fb:value> in the new databind define all have
<fd:convertor> child node even it doesn't need it.

My question is how to aviod the error and insert <fd:convertor> only when it is needed.

WDTY?

Roy Huang
Mime
View raw message