XForms/Synonym Set Editor

Motivation

edit

You want to associate a synonym set with a single business term. A synonym set is a group of terms that have similar meaning or similar semantics. They are grouped together in a structure called a synonyms set. A term can be associated with one-and-only-one synonym set.

These tools are frequently used during the process of creating an enterprise-wide controlled vocabulary. These vocabularies are used for identifying data elements or expressing business rules in a consistent way across multiple organizations.

Method

edit

In this program we will have once instance that has an initial synonym set. We will have a button that reveals alternative synonyms using a switch/case. When you select a new synonym set it will copy the selected synonym set tree into the selected synonym set and close the case.

Sample Program Code

edit
<html 
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:xf="http://www.w3.org/2002/xforms" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:ev="http://www.w3.org/2001/xml-events" >
   <head>
        <title>Test of XForm to Associate Synonym Set to Business Term</title>
        <style type="text/css">
          @namespace xf url("http://www.w3.org/2002/xforms");
          body {font-family:Helvetica, sans-serif}
          .preferred {font-weight:bold;}
          .synonym xf|repeat * {display:inline}
          .url {color: blue; text-decoration:underline; margin: 0 2px;}
          .syn-list {background-color: sliver;}
       </style>
        <xf:model>
            <xf:instance xmlns="" id="current-synset">
                 <SynSet>
                      <synset-id>2</synset-id>
                      <synonym>
                           <preferred>false</preferred>
                           <syn-name>Middle Item</syn-name>
                      </synonym>
                      <synonym>
                           <preferred>false</preferred>
                           <syn-name>Central Item</syn-name>
                      </synonym>
                      <synonym>
                           <preferred>true</preferred>
                           <syn-name>Second Item</syn-name>
                      </synonym>
                      <synonym>
                           <preferred>false</preferred>
                           <syn-name>Following Item</syn-name>
                      </synonym>
                      <synonym>
                           <preferred>false</preferred>
                           <syn-name>After First Item</syn-name>
                      </synonym>
                      <synonym>
                           <preferred>false</preferred>
                           <syn-name>Following Item</syn-name>
                      </synonym>
                 </SynSet>
            </xf:instance>
             
            <xf:instance xmlns="" id="synonym-sets">
                 <SynSets>
                     <SynSet>
                          <synset-id>1</synset-id>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Origin Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>First Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>true</preferred>
                               <syn-name>Initial Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Stat Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Begin Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Originating Item</syn-name>
                          </synonym>
                     </SynSet>
                     <SynSet>
                          <synset-id>2</synset-id>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Middle Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Central Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>true</preferred>
                               <syn-name>Second Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Following Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>After First Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Following Item</syn-name>
                          </synonym>
                     </SynSet>
                     <SynSet>
                          <synset-id>3</synset-id>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Final Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Ending Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>true</preferred>
                               <syn-name>Last Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>End Item</syn-name>
                          </synonym>
                          <synonym>
                               <preferred>false</preferred>
                               <syn-name>Tail Item</syn-name>
                          </synonym>
                     </SynSet>
                 </SynSets>
            </xf:instance>
             
             <!-- the URL that the user selected and is executed in the load -->
            <xf:instance xmlns="" id="URL-container">
                <URL/>
            </xf:instance>
             
        </xf:model>
    </head>
    <body>
        <h3>Test of XForm to Associate Synonym Set to Term</h3>
        <xf:group class="synonym">
            <xf:label class="group-label">Synonyms for This Term:</xf:label>
            <xf:repeat nodeset="instance('current-synset')/synonym" id="synonym-repeat">
                <xf:trigger appearance="minimal" class="url">
                    <xf:label>
                        <xf:group ref=".[preferred='true']">
                            <xf:output ref="syn-name" class="preferred"/>
                        </xf:group>
                        <xf:group ref=".[preferred='false']">
                            <xf:output ref="syn-name"/>
                        </xf:group>
                    </xf:label>
                    <xf:hint>
                        <xf:output ref="syn-name"/>
                    </xf:hint>
                   <!-- we build a URI and load it if the user clicks on a link -->
                    <xf:action ev:event="DOMActivate">
                        <xf:setvalue ref="instance('URL-container')" value="concat('http://www.example.com/view-term.xq?name=', instance('current-synset')/synonym[index('synonym-repeat')=position()]/syn-name)"/>
                        <xf:load ref="instance('URL-container')"/>
                    </xf:action>
                </xf:trigger>
            </xf:repeat>
             
            <xf:switch>
                <xf:case id="init">
                    <xf:trigger>
                        <xf:label>Change Synonym Set</xf:label>
                        <xf:toggle case="list-synsets" ev:event="DOMActivate"/>
                    </xf:trigger>
                </xf:case>
                <xf:case id="list-synsets">
                    <h3>Set New Synonym Set:</h3>
                     <xf:repeat nodeset="instance('synonym-sets')/SynSet" id="set-repeat">
                        <xf:trigger>
                            <xf:label>Set</xf:label>
                             <xf:action ev:event="DOMActivate">
                                  <xf:insert nodeset="instance('current-synset')"
                                             origin="instance('synonym-sets')/SynSet[index('set-repeat')]" />
                                 <xf:toggle case="init" />
                             </xf:action>
                        </xf:trigger>
                          <xf:repeat nodeset="synonym">
                                   <xf:trigger appearance="minimal" class="url">
                                        <xf:label>
                                             <xf:group ref=".[preferred='true']">
                                                  <xf:output ref="syn-name" class="preferred"/>
                                             </xf:group>
                                             <xf:group ref=".[preferred='false']">
                                                  <xf:output ref="syn-name"/>
                                             </xf:group>
                                        </xf:label>
                                        <!-- we build a URI and load it if the user clicks on a link -->
                                        <xf:action ev:event="DOMActivate">
                                             <xf:setvalue ref="instance('URL-container')"
                                                  value="concat('http://www.example.com/view-term.xq?name=',  instance('current-synset')/synonym[index('synonym-repeat')=position()]/syn-name)"/>
                                             <xf:load ref="instance('URL-container')"/>
                                        </xf:action>
                                   </xf:trigger>
                          </xf:repeat>
                        <br/>
                    </xf:repeat>
                    <xf:trigger>
                        <xf:label>Close Synonym Sets List</xf:label>
                        <xf:toggle case="init" ev:event="DOMActivate"/>
                    </xf:trigger>
                </xf:case>
            </xf:switch>
        </xf:group>
    </body>
</html>


Discussion

edit
Next Page: W2 Tax Form | Previous Page: Outline Editor
Home: XForms