(est-rdf-encode-feature-name): Map domain to xmlns-prefix; refer
authorMORIOKA Tomohiko <tomo.git@chise.org>
Mon, 26 Aug 2013 07:31:48 +0000 (16:31 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Mon, 26 Aug 2013 07:31:48 +0000 (16:31 +0900)
feature `rdf-namespace-prefix' and `rdf-namespace-uri'; return
'(<XMLNS-PREFIX> <XMLNS-URI> <PREDICATE>) instead of '(<XMLNS-PREFIX>
. <PREDICATE>).
(est-rdf-display-object-desc): Modify for
`est-rdf-encode-feature-name'.

est-rdf-view.el

index eaafab7..62e21c7 100644 (file)
@@ -8,7 +8,8 @@
 (defun est-rdf-encode-feature-name (feature-name)
   (let ((str (symbol-name feature-name))
        base domain
-       ret is-not-top)
+       ret is-not-top
+       xmlns-prefix xmlns-uri)
     (if (string-match "@" str)
        (setq base (substring str 0 (match-beginning 0))
              domain (substring str (match-end 0)))
                                     (t (char-to-string c)))
                             (setq is-not-top t)))
                         base ""))
-    ;; (if (eq (aref ret 0) ?.)
-    ;;     (setq ret (concat "meta" ret)))
-    (cons (if domain
-             (concat "est."
-                     (mapconcat #'identity
-                                (split-string domain "/")
-                                "."))
-           "est")
+    (if domain
+       (setq xmlns-prefix
+             (or xmlns-prefix
+                 (concat "est."
+                         (mapconcat #'identity
+                                    (split-string domain "/")
+                                    "."))))
+      (setq xmlns-prefix (or (char-feature-property
+                             feature-name 'rdf-namespace-prefix)
+                            'est)
+           xmlns-uri (char-feature-property
+                      feature-name 'rdf-namespace-uri)))
+    (list xmlns-prefix
+         (or xmlns-uri
+             (format "http://www.chise.org/est/rdf.cgi?domain=%s/"
+                     xmlns-prefix))
          (www-uri-encode-feature-name (intern ret)))))
 
 (defun est-rdf-format-object (obj)
@@ -77,7 +86,7 @@
        logical-feature-name
        object-spec logical-object-spec
        rdf-feature-name rdf-feature-name-space
-       rdf-feature-name-base rdf-feature-name-domain
+       rdf-feature-name-base rdf-feature-name-domain rdf-feature-name-uri
        feature-type rdf-container
        value ret
        metadata-feature-target metadata-feature-type
          (setq value (www-get-feature-value object logical-feature))
          (setq ret (est-rdf-encode-feature-name logical-feature))
          (setq rdf-feature-name-domain (car ret)
-               rdf-feature-name-base (cdr ret))
-         (setq rdf-feature-name (format "%s:%s" (car ret)(cdr ret)))
+               rdf-feature-name-uri (nth 1 ret)
+               rdf-feature-name-base (nth 2 ret))
+         (setq rdf-feature-name (format "%s:%s"
+                                        rdf-feature-name-domain
+                                        rdf-feature-name-base))
          (setq rdf-feature-name-space
-               (format "xmlns:%s=\"http://www.chise.org/est/rdf.cgi?domain=%s/\""
-                       (car ret)
-                       (car ret)))
+               (format "xmlns:%s=\"%s\""
+                       rdf-feature-name-domain
+                       rdf-feature-name-uri))
          (setq feature-type (www-feature-type logical-feature))
          (if (and (consp value)
                   (cdr value))
            (setq metadata-feature-target
                  (intern (substring logical-feature-name
                                     0 (1+ (match-beginning 0)))))
+            ;; (setq metadata-feature-type
+            ;;       (intern (substring logical-feature-name
+            ;;                          (1+ (match-beginning 0)))))
            (setq metadata-feature-type
                  (intern (substring logical-feature-name
-                                    (1+ (match-beginning 0)))))
+                                    (+ (match-beginning 0) 2))))
            (setq ret (est-rdf-encode-feature-name metadata-feature-target))
            (princ
             (format "<rdf:Description
  rdf:about=\"#%s...%s\">\n"
-                    (car ret)(cdr ret)))
+                    (car ret)(nth 2 ret)))
            (setq ret (est-rdf-encode-feature-name metadata-feature-type))
            (setq rdf-feature-name-domain (car ret)
-                 rdf-feature-name-base (cdr ret))
-           (setq rdf-feature-name (format "%s:%s" (car ret)(cdr ret)))
+                 rdf-feature-name-uri (nth 1 ret)
+                 rdf-feature-name-base (nth 2 ret))
+           (setq rdf-feature-name (format "%s:%s"
+                                        rdf-feature-name-domain
+                                        rdf-feature-name-base))
            (setq rdf-feature-name-space
-                 (format
-                  "xmlns:%s=\"http://www.chise.org/est/rdf.cgi?domain=%s/\""
-                  (car ret)
-                  (car ret)))
+                 (format "xmlns:%s=\"%s\""
+                         rdf-feature-name-domain
+                         rdf-feature-name-uri))
            )
           (t
            (setq metadata-feature-type nil)