[rkward-devel] you can now (try to) generate rkwarddev scripts from plugin XML code

meik michalke meik.michalke at uni-duesseldorf.de
Sun Oct 4 19:54:50 UTC 2015


hi,

to whom it may concern: i've added a first version of the new plugin2script() 
methods to rkwarddev in git. there's still a few quirks, but it is generally 
working better than i expected, and much sooner so, too. an example:

  test.checkboxes <- rk.XML.row(
    rk.XML.col(
      list(
        rk.XML.cbox(label="foo", value="foo1", chk=TRUE),
        rk.XML.cbox(label="bar", value="bar2")
      )
    )
  ))
# this generates the following XML code -- already present XML files
# can be imported with parseXMLTree()
  <row id="row_clmndc1212">
    <column id="clm_chckbxdc12">
      <checkbox id="chc_foo" label="foo" value="foo1" checked="true" />
      <checkbox id="chc_bar" label="bar" value="bar2" />
    </column>
  </row>

# now we turn this back into rkwarddev script code
  rkwarddevScript <- plugin2script(test.checkboxes)

# see the generated script code
  cat(rkwarddevScript)
# gives you:
  rkdev.row.row_clmndc1212 <- rk.XML.row(
    rkdev.column.clm_chckbxdc12 <- rk.XML.col(
      rkdev.checkbox.chc_foo <- rk.XML.cbox(
        label="foo",
        value="foo1",
        chk=TRUE,
        id.name="chc_foo" 
      ),
      rkdev.checkbox.chc_bar <- rk.XML.cbox(
        label="bar",
        value="bar2",
        id.name="chc_bar"
      ),
      id.name="clm_chckbxdc12"
    ),
    id.name="row_clmndc1212"
  )

# we can evaluate the generated code to check whether original
# XML and the newly generated one are identical
  eval(parse(text=rkwarddevScript))
  identical(rkdev.row.row_clmndc1212, test.checkboxes)
  [1] TRUE

amongst the outstanding bugs are <logic> stuff, dealing with "<stretch />" and 
a multiple comma issue in tabbook <tab>s. but since this thing is only 
intended to give you a quick starting point for rkwarddev scripts this is 
already something i can live with.

i've already parsed and re-generated the full "read CSV" plugin XML 
successfully (after one minor change to the XML, parseXMLTree() doesn't like 
"\" in the XML code). great fun ;-)


viele grüße :: m.eik

-- 
  dipl. psych. meik michalke
  institut f"ur experimentelle psychologie
  abt. f"ur diagnostik und differentielle psychologie
  heinrich-heine-universit"at d-40204 d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20151004/c43c99d5/attachment.sig>


More information about the rkward-devel mailing list