W3C home > Mailing lists > Public > www-forms@w3.org > October 2003

Conditional node handling

From: Stuart Brown <sbrown@extenza.com>
Date: Wed, 8 Oct 2003 14:54:32 +0100
Message-ID: <F0FDC1207BD1D7118F8A00508B8BA22B2451AD@sbis-uk-1.uk.swetsblackwell.com>
To: "'www-forms@w3.org'" <www-forms@w3.org>

This is my first foray into XForms, and I'm trying to do some conditional
value assignment.

The form loads two sets of instance data: one is the eventual output
(extenza.xml), which describes one journal article; and one contains details
of all the possible journals so that the selection of a journal will
populate all the relevant pieces of data in extenza.xml from the selected
journal in journals.xml.

<xf:model id="extenza">
  <xf:instance id="extenza" src="extenza-template.xml"/>
  <xf:instance id="journals" src="journals.xml"/>

The relevant bits of the source XML look as follows:

<Extenza xmlns="http://www.extenza.com/xml-def">
      <!-- ISSN -->
      <!-- CODEN -->
      <!--  Other stuff -->

    <title>My Journal</title>
    <title>Another Journal</title>
  <!-- And others -->

The problem is that I want, on selection of a journal in the first case of
the form, to set the ISSN and CODEN to the respective <IDValue> elements in
the source XML.  However, not all journals have a CODEN, and in the event of
this I want to remove the second occurrence of <SerialTitleIdentifier> in
the instance data for output (or, alternatively, to have it absent in the
source XML, and insert the second occurrence in the positive case of a
CODEN).  I am currently working on having used a <select1> option to
populate the <TitleText> element with the journal title, and then in the
action to move to the next case of the form, <setvalue> is used to assign
the remaining data.

  <xf:case id="journalSelect">
    <!-- Select the journal and bind its title to the TitleText in extenza
    <xf:select1 appearance="minimal" instance="extenza"
      <xf:label>Select journal:</xf:label>
      <xf:itemset nodeset="instance('journals')/journal">
        <xf:label ref="title"/>
        <xf:value ref="title"/>
      <!-- On the trigger to move to the next case I assign the remaining
values -->
      <xf:action ev:event="DOMActivate">
        <!-- Set the ISSN -->
        <xf:setvalue instance="extenza"
DValue" value="instance('journals')/journal[title =
        <!-- ** Here I want to check if there is a <coden> child of the
selected <journal> and, if there is, assign similar to above, and if there
isn't to remove the second occurrence of <SerialTitleIdentifier> from the
instance ** -->
        <xf:toggle case="confirm1"/>
  <xf:case id="confirm1">
    <!-- Next step... --->

I can't find anything about how to do this on lists or in Micah Dubinko's

Any suggestions?  Am I going about this entirely the wrong way in the first
place?  A generic explanation of this kind of processing would be very
gratefully appreciated, as there are a lot more of this kind of problem
going to crop up for me (later in the form, for instance, I want to bind a
value to one of two elements depending on whether it is an integer or NaN).



Stuart Brown
Electronic Production Manager

Extenza e-Publishing Services
a Division of Swets & Zeitlinger
32 Blacklands Way
Abingdon Business Park
Abingdon, Oxon
OX14 1SX
t: +44 (0) 1235 857739
f: +44 (0) 1235 857752
e: sbrown@extenza.com
w: www.extenza-eps.com <www.extenza-eps.com> 
Received on Wednesday, 8 October 2003 10:01:00 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:09 UTC