UsingWeightBalancedTrees

Adressen

fiXml® Visite

logo

debug



Softeyes: fiXml Personalisierung

Sehr geehrter Benutzer, Formulare in der fiXml Umgebung erfordern gelegentlich für den geschäftlichen Verkehr Kontaktadressen anzugeben. Tragen Sie dazu bitte Name und Postanschrift für ihre elektronische Visitenkarte hier ein.

Beachten Sie beim Eintragen:

  • Diese Daten sind öffentlich zugänglich. Geben Sie nur an, was Sie auch auf Ihre Visitenkarte schreiben würden.
Name (Ansprechform)
Familie
Vorname
2. Name
Titel
Kürzel
Bild (OID?)
Geburtstag
Organisation
Strasse
Ort
Plz
Kürzel
Geburtstag
Organisation

bearbeiten

(let ((handle (lambda (node) (let ((ff (form-field (gi node) (current-node)))) (if (node-list-empty? ff) node ff))))) (make element gi: 'Description ns: (string->symbol "http://www.w3.org/1999/02/22-rdf-syntax-ns#") attributes: `((xmlns rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#") (xmlns "http://www.w3.org/2001/vcard-rdf/3.0#") (about ,(oid->string (msg 'dc-creator)))) (node-list-map (lambda (node) (cond ((match-element? 'n node) (make element gi: 'n (node-list-map handle (children node)))) ((match-element? 'adr node) (make element gi: 'adr (node-list-map handle (children node)))) ;; All form fields (else (handle node)))) ;; The children of the root of the style sheet. ((sxpath '(emptyEntry Description *)) (grove-root (current-node)))))) (wt-tree/dump (wt-tree/add (wt-tree/restore (make-wt-tree-type string<? (wt-marshall me msg identity literal)) (me "people")) (attribute-string 'about (node-list-first (xsl-variable "new-entry"))) (xsl-variable "new-entry")))

Source code:

<xsl:stylesheet xmlns:addrdb="urn:addrdb" xmlns:d="http://www.askemos.org/2005/NameSpaceDSSSL/" xmlns:mind="http://www.askemos.org/2000/CoreAPI#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--

This is how we define our data structure: write down an example entry.

-->
 <addrdb:emptyEntry>
  <rdf:Description xmlns="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" about="A00000000000000000000000000000001">
<!-- formatted name -->
   <fn></fn>
   <n>
    <surname></surname>
    <firstname></firstname>
    <middlename></middlename>
    <honorific></honorific>
   </n>
   <nickname></nickname>
   <photo resource="xpath value (prefered &apos;/oid&apos; ) "></photo>
   <bday></bday>
   <adr>
    <affilation></affilation>
    <street></street>
    <city></city>
    <zip></zip>
   </adr>
  </rdf:Description>
 </addrdb:emptyEntry>
<!--

Default the current (edit cursor) record to the reader if no "about"
field is in the input form.

-->
 <xsl:variable name="current">
  <d:copy-of select="
 (let* ((about-field (form-field &apos;about (current-node)))
        (about (if (node-list-empty? about-field)
                   (oid-&gt;string (msg &apos;dc-creator))
                   (data about-field))))
   
   (or (and about
            (and-let* ((v (wt-tree/lookup
             (wt-tree/restore
              (make-wt-tree-type string&lt;? (wt-marshall me msg identity literal))
              (me &quot;people&quot;))
             about #f)))
              (fetch v adopt: #t)))
       (let ((template (node-list-first ((sxpath &apos;(emptyEntry *)) (grove-root (current-node)))) ))
         (make element gi: (gi template) ns: (ns template)
           attributes:
          `((about ,(oid-&gt;string (msg &apos;dc-creator)))
             . ,(filter (lambda (a) (not (eq? (cadr a) &apos;about)))
                        (copy-attributes template)))
          (children template)))))
"></d:copy-of>
 </xsl:variable>
 <xsl:template match="request[@type=&quot;read&quot;]">
  <xsl:choose>
<!--

If the next destination step indicates the oid of some entry, forward
to the entry.

-->
   <d:when test="(pair? (msg &apos;destination))">
    <d:copy-of select="(fetch (me (car (msg &apos;destination))))"></d:copy-of>
   </d:when>
<!--

Standard debug interface for development and maintainence available
for the creator only.

-->
   <d:when test="(and (is-meta-form? msg) (service-level))">
    <d:copy-of select="(message-body (metaview me msg))"></d:copy-of>
   </d:when>
   <xsl:otherwise>
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title>Adressen</title>
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></meta>
      <link href="/Ade6d2d759d9502d5e071947527272fe8" rel="icon" type="image/x-icon"></link>
      <link href="/Ade6d2d759d9502d5e071947527272fe8" rel="shortcut icon" type="image/x-icon"></link>
     </head>
     <body bgcolor="white">
      <table border="0" style="border:none" width="100%">
       <tr>
        <td valign="top">
         <h1><a href="/A6e91a613b858043b717121386f615871/fiXml">fiXml</a><sup>®</sup> Visite</h1>
        </td>
        <td valign="top">
         <a href="/A6e91a613b858043b717121386f615871/">
          <img align="right" alt="logo" border="0" src="/A3d1779dc7f7ca7022998427aa3578765"></img>
         </a>
        </td>
       </tr>
      </table>
<!-- Again the creator only will get this link. -->
      <d:if test="(service-level (me &apos;dc-creator))">
       <p>
        <d:a d:href="
(read-locator (msg &apos;location-format)
  (list body: &quot;xmlns=mind&quot; (me &apos;get &apos;id)))
">debug</d:a>
       </p>
      </d:if>
      <d:form method="get" d:action="read-locator
 msg &apos;location-format
 msg &apos;location">
       <p>
        <input name="search" type="text"></input>
        <input type="submit" value="Suche"></input>
       </p>
      </d:form>
      <xsl:choose>
       <d:when test="
(&gt; (string-length (data (form-field &apos;search (current-node)))) 2)
">
<!-- Search results only with at leat 3 characters of search string. -->
        <p>
<!--
wt-tree is documented in SLIB.

pcre creates a match function for a perl regualr expression.

fetch gets the entry from the link, which is matched by the search and
if a match is found, it's inserted into the result.

OK, this is going to create a huge walk and will likely not work
for large data bases.

 -->
         <d:for-each select="
  (let ((search (pcre (data (form-field &apos;search (current-node))))))
    (wt-tree/fold
     (lambda (name v i)
       (let ((v (fetch v adopt: #t)))
         (if (search v) (cons v i) i)))
     &apos;()
     (wt-tree/restore
      (make-wt-tree-type string&lt;? (wt-marshall me msg identity literal))
      (me &quot;people&quot;))))
">
<!--  The link is prepared to display the detailed entry. -->
          <d:a d:href="(read-locator (msg &apos;location-format)
  (list body: (string-append &quot;about=&quot; (attribute-string &apos;about (current-node)))  (me &apos;get &apos;id)))">
           <d:copy-of select="((sxpath &apos;(fn)) (current-node))"></d:copy-of>
          </d:a>
          <br></br>
         </d:for-each>
        </p>
       </d:when>
<!--

The owner of an entry gets an input form for first time entry.

-->
       <d:when test="

(and
 (not (eq? (msg &apos;dc-creator) (public-oid)))

 (let ((about (attribute-string &apos;about
                (document-element (xsl-variable &quot;current&quot;)))))
  (or (eq? (string-&gt;oid about) (msg &apos;dc-creator))
      (and (service-level)
           (equal? &quot;edit&quot;
                   (data (form-field &apos;mode (current-node))))))))

;; (service-level (string-&gt;oid (attribute-string &apos;about (document-element (xsl-variable &quot;current&quot;) ))))

">
        <h1>Softeyes: fiXml Personalisierung</h1>
        <p>Sehr geehrter Benutzer, Formulare in der fiXml Umgebung
erfordern gelegentlich für den geschäftlichen Verkehr Kontaktadressen anzugeben.
Tragen Sie dazu bitte Name und Postanschrift für ihre elektronische
Visitenkarte hier ein.</p>
        <p>Beachten Sie beim Eintragen:</p>
        <ul>
         <li>Diese Daten sind öffentlich zugänglich.  Geben Sie nur an, was Sie
auch auf Ihre Visitenkarte schreiben würden.</li>
        </ul>
        <d:form method="post" d:action="write-locator
 msg &apos;location-format
 msg &apos;location">
         <table bgcolor="silver" border="0">
          <tr>
           <td>Name (Ansprechform)</td>
           <td>
            <d:input name="fn" type="text" d:value="(data ((sxpath &apos;(fn)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Familie</td>
           <td>
            <d:input name="surname" type="text" d:value="(data ((sxpath &apos;(n surname)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Vorname</td>
           <td>
            <d:input name="firstname" type="text" d:value="(data ((sxpath &apos;(n firstname)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>2. Name</td>
           <td>
            <d:input name="middlename" type="text" d:value="(data ((sxpath &apos;(n middlename)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Titel</td>
           <td>
            <d:input name="honorific" type="text" d:value="(data ((sxpath &apos;(n honorific)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Kürzel</td>
           <td>
            <d:input name="nickname" type="text" d:value="(data ((sxpath &apos;(nickname)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Bild (OID)</td>
           <td>
            <d:input name="photo" type="text" d:value="(data ((sxpath &apos;(photo)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Geburtstag</td>
           <td>
            <d:input name="bday" type="text" d:value="(data ((sxpath &apos;(bday)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Organisation</td>
           <td>
            <d:input name="affilation" type="text" d:value="(data ((sxpath &apos;(adr affilation)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Strasse</td>
           <td>
            <d:input name="street" type="text" d:value="(data ((sxpath &apos;(adr street)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Ort
</td>
           <td>
            <d:input name="city" type="text" d:value="(data ((sxpath &apos;(adr city)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>Plz</td>
           <td>
            <d:input name="zip" type="text" d:value="(data ((sxpath &apos;(adr zip)) (xsl-variable &quot;current&quot;)))"></d:input>
           </td>
          </tr>
          <tr>
           <td>
            <d:input type="submit" value="eintragen"></d:input>
            <d:input name="action" type="hidden" value="save"></d:input>
           </td>
           <td>
            <small>
             <code>
              <d:copy-of select="(attribute-string &apos;about (document-element (xsl-variable &quot;current&quot;) ))"></d:copy-of>
             </code>
            </small>
           </td>
          </tr>
         </table>
        </d:form>
       </d:when>
<!--

Show the name for everybody else.

-->
       <xsl:otherwise>
        <table bgcolor="silver" border="0">
         <tr>
          <td colspan="2">
           <d:copy-of select="
(make element
  gi: &apos;a
  attributes: `((href ,(data (attribute-string &apos;about (document-element (xsl-variable &quot;current&quot;) )))))
(literal
 (data ((sxpath &apos;(n honorific)) (xsl-variable &quot;current&quot;)))
 &quot; &quot;
 (data ((sxpath &apos;(fn)) (xsl-variable &quot;current&quot;))))
)
"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td>Kürzel</td>
          <td>
           <d:copy-of select="
  (children ((sxpath &apos;(nickname)) (xsl-variable &quot;current&quot;)))
"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td>Geburtstag</td>
          <td>
           <d:copy-of select="(children ((sxpath &apos;(bday)) (xsl-variable &quot;current&quot;)))"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td>Organisation</td>
          <td>
           <d:copy-of select="(children ((sxpath &apos;(adr affilation)) (xsl-variable &quot;current&quot;)))"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td></td>
          <td>
           <d:copy-of select="(children ((sxpath &apos;(adr street)) (xsl-variable &quot;current&quot;)))"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td></td>
          <td>
           <d:copy-of select="
(node-list
  (children ((sxpath &apos;(adr zip)) (xsl-variable &quot;current&quot;)))
  (literal &quot; &quot;)
  (children ((sxpath &apos;(adr city)) (xsl-variable &quot;current&quot;))))
"></d:copy-of>
          </td>
         </tr>
         <tr>
          <td colspan="2">
           <small>
            <code>
             <d:copy-of select="(attribute-string &apos;about (document-element (xsl-variable &quot;current&quot;) ))"></d:copy-of>
            </code>
           </small>
          </td>
         </tr>
        </table>
        <d:if test="(service-level)">
         <p>
          <d:a d:href="
(read-locator (msg &apos;location-format)
  (me &apos;get &apos;id) body: &quot;mode=edit&quot; )
">bearbeiten</d:a>
         </p>
        </d:if>
       </xsl:otherwise>
      </xsl:choose>
     </body>
    </html>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="request[@type=&quot;write&quot;]">
  <xsl:variable name="new-entry">
   <d:copy-of select="#CONTENT">
     (let ((handle (lambda (node)
                     (let ((ff (form-field (gi node) (current-node))))
                       (if (node-list-empty? ff) node ff)))))
      (make element
        gi: 'Description ns: (string-&gt;symbol "<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;)">http://www.w3.org/1999/02/22-rdf-syntax-ns#")</a>
        attributes: `((xmlns rdf "<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;)">http://www.w3.org/1999/02/22-rdf-syntax-ns#")</a>
                      (xmlns "<a href="http://www.w3.org/2001/vcard-rdf/3.0#&quot;)">http://www.w3.org/2001/vcard-rdf/3.0#")</a>
                      (about ,(oid-&gt;string (msg 'dc-creator))))
        (node-list-map
         (lambda (node)
           (cond
            ((match-element? 'n node)
             (make element gi: 'n
               (node-list-map handle (children node))))
            ((match-element? 'adr node)
             (make element gi: 'adr
               (node-list-map handle (children node))))
            ;; All form fields
            (else (handle node))))
         ;; The children of the root of the style sheet.
         ((sxpath '(emptyEntry Description *)) (grove-root (current-node))))))
     </d:copy-of>
  </xsl:variable>
  <xsl:choose>
<!--

Support the standard debug interface.

-->
   <d:when test="(and (is-meta-form? msg) (service-level (me &apos;dc-creator)))">
    <d:copy-of select="(message-body (metactrl me msg))"></d:copy-of>
   </d:when>
<!--

Check the ownership of the entry.

-->
   <d:when test="(not (or (service-level (string-&gt;oid (attribute-string &apos;about (node-list-first (xsl-variable &quot;new-entry&quot;) )))) (error &quot;privat property&quot;)))"></d:when>
<!--

OK, change the entry.

-->
   <xsl:otherwise>
    <mind:reply>
     <d:copy-of select="(grove-root (current-node))"></d:copy-of>
     <mind:link name="people">
      <d:copy-of select="#CONTENT">
(wt-tree/dump
  (wt-tree/add
   (wt-tree/restore
     (make-wt-tree-type string&lt;? (wt-marshall me msg identity literal))
     (me "people"))
   (attribute-string 'about (node-list-first (xsl-variable "new-entry")))
   (xsl-variable "new-entry")))
</d:copy-of>
     </mind:link>
    </mind:reply>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
</xsl:stylesheet>

Diese Seite findet man von: overview, .




Letzte Modifikation: Thu, 20 Apr 2006 19:12:57 +0200

Autor(en): jfw,

Dokument Nummer A67bb0753e1676f81983e0ecf3a15b391 geliefert an public um Fri, 22 Aug 2008 00:15:51 +0200