You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by roy huang <li...@hotmail.com> on 2004/06/24 13:44:02 UTC

[Help][CForms]About insert-node

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