Changeset 145 for trunk/src/xml


Ignore:
Timestamp:
11/22/09 18:16:47 (15 years ago)
Author:
lgiessmann
Message:

added the support for reification in the xtm 2.0 importer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/xml/xtm/importer_xtm2.0.lisp

    r92 r145  
    99
    1010(in-package :xml-importer)
     11
     12(defun set-reifier (reifiable-elem reifiable-construct)
     13  "Sets the reifier-topic of the passed elem to the passed construct."
     14  (declare (dom:element reifiable-elem))
     15  (declare (ReifiableConstructC reifiable-construct))
     16  (let ((reifier-uri (get-attribute reifiable-elem "reifier")))
     17    (when (and (stringp reifier-uri)
     18               (> (length reifier-uri) 0))
     19      (add-reifier reifiable-construct reifier-uri))
     20    reifiable-construct))
     21
    1122
    1223(defun from-identifier-elem (classsymbol elem start-revision)
     
    128139      (loop for variant-elem across (xpath-child-elems-by-qname name-elem *xtm2.0-ns* "variant")
    129140         do (from-variant-elem variant-elem name start-revision :xtm-id xtm-id))
    130       name)))
     141      (set-reifier name-elem name))))
    131142
    132143
     
    181192      (error "VariantC: one of resourceRef and resourceData must be set"))
    182193       
    183        (make-construct 'VariantC
    184                        :start-revision start-revision
    185                        :item-identifiers item-identifiers
    186                        :themes themes
    187                        :charvalue (getf variant-value :data)
    188                        :datatype (getf variant-value :type)
    189                        :name name)))
     194       (let ((variant (make-construct 'VariantC
     195                                      :start-revision start-revision
     196                                      :item-identifiers item-identifiers
     197                                      :themes themes
     198                                      :charvalue (getf variant-value :data)
     199                                      :datatype (getf variant-value :type)
     200                                      :name name)))
     201         (set-reifier variant-elem variant))))
    190202                           
    191203
     
    212224    (unless occurrence-value
    213225      (error "OccurrenceC: one of resourceRef and resourceData must be set"))
    214     (make-construct 'OccurrenceC
    215                     :start-revision start-revision
    216                     :topic top
    217                     :themes themes
    218                     :item-identifiers item-identifiers
    219                     :instance-of instance-of
    220                     :charvalue (getf occurrence-value :data)
    221                     :datatype (getf occurrence-value :type))))
     226    (let ((occurrence (make-construct 'OccurrenceC
     227                                      :start-revision start-revision
     228                                      :topic top
     229                                      :themes themes
     230                                      :item-identifiers item-identifiers
     231                                      :instance-of instance-of
     232                                      :charvalue (getf occurrence-value :data)
     233                                      :datatype (getf occurrence-value :type))))
     234      (set-reifier occ-elem occurrence))))
    222235   
    223236   
     
    323336             role-elem
    324337             *xtm2.0-ns*
    325              "topicRef")) :xtm-id xtm-id)))
     338             "topicRef")) :xtm-id xtm-id))
     339         (reifier-uri
     340          (let ((value (get-attribute role-elem "reifier")))
     341            (if (and (stringp value)
     342                     (> (length value) 0))
     343                value
     344                nil))))
    326345;      (unless (and player instance-of)
    327346;        (error "Role in association not complete"))
     
    332351             *xtm2.0-ns*
    333352             "topicRef"))))
    334       (list :instance-of instance-of :player player :item-identifiers item-identifiers))))
     353      (list :reifier-uri reifier-uri
     354            :instance-of instance-of
     355            :player player
     356            :item-identifiers item-identifiers))))
    335357
    336358
     
    340362                              (xtm-id *current-xtm*))
    341363  "Constructs an AssociationC object from an association element
    342 association = element association { reifiable, type, scope?, role+ }"
     364   association = element association { reifiable, type, scope?, role+ }"
    343365  (declare (dom:element assoc-elem))
    344366  (declare (integer start-revision))
     
    367389                *xtm2.0-ns* "role"))))
    368390      (setf roles (set-standard-role-types roles)); sets standard role types if there are missing some of them
    369      
    370       (add-to-topicmap tm
    371             (make-construct 'AssociationC
    372                             :start-revision start-revision
    373                             :item-identifiers item-identifiers
    374                             :instance-of instance-of
    375                             :themes themes
    376                             :roles roles)))))
     391      (let ((assoc (add-to-topicmap
     392                    tm
     393                    (make-construct 'AssociationC
     394                                    :start-revision start-revision
     395                                    :item-identifiers item-identifiers
     396                                    :instance-of instance-of
     397                                    :themes themes
     398                                    :roles roles))))
     399        (map 'list #'(lambda(assoc-role)
     400                       (map 'list #'(lambda(list-role)
     401                                      (when (and (eql (instance-of assoc-role)
     402                                                      (getf list-role :instance-of))
     403                                                 (eql (player assoc-role)
     404                                                      (getf list-role :player))
     405                                                 (getf list-role :reifier-uri))
     406                                        (add-reifier assoc-role (getf list-role :reifier-uri))))
     407                            roles))
     408             (roles assoc))
     409        (set-reifier assoc-elem assoc)))))
    377410
    378411
Note: See TracChangeset for help on using the changeset viewer.