OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Vocabulary Combination and optional namespaces

[ Lists Home | Date Index | Thread Index ]

Arjun Ray wrote:
> Paul Prescod <paul@prescod.net> wrote:
> | In fact, here's what I did: I wrote a Python program that worked with
> | RSS. Then I added the "xmlns attribute" [...] rewrote the program using
> | full namespaces. The changes were straightforward and added exactly one
> | line of code (the namespace declaration).
> [ ... python example ...]
> Now, picture if you will, the utility of "vocabulary specific views"
> instead of colonified names.  Let's suppose the dom object supported a
> method to impose such a filter to yield a subdom.  Then you could do
> something like this

let us suppose that the parser is built on a substrate which permits it and
the application to operate on both namespaces and names as first class objects:

(in-package :xmlp)

(import '(||::|item| ||::|title| ||::|words|) :xmlp)

(defun rewrite-with-title-word-count (model &optional (stream *standard-output*))
  (let ((items (.//* model '|item|)))
    (dolist (item items)
      (let* ((title (./ item '|title|))
             (words (length (split-string (first (children title)) " "))))
        (setf (children item)
              (nconc (children item)
                     (list (make-elem-node :name '|words|
                                           :children (list (write-to-string words)))))))))
  (write-node model stream))

? (rewrite-with-title-word-count
 <item><title>title one</title></item>
 <item><title>a longer title two</title></item>
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
 <item><title>title one</title><words>2</words></item>
 <item><title>a longer title two</title><words>4</words></item>
#<DOC-NODE <no uri> #x207B4E6>

? (let ((*namespace-dictionary* `(("http://www/rss"; . ,(find-package "")) ,*namespace-dictionary*)))
 <item xmlns='http://www/rss'><title>title one</title></item>
 <item xmlns='http://www/rss'><title>a longer title two</title></item>
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
 <item xmlns='http://www/rss'><title>title one</title><words>2</words></item>
 <item xmlns='http://www/rss'><title>a longer title two</title><words>4</words></item>
#<DOC-NODE <no uri> #x207FFE6>

no encoding properties are imposed on the application code.

simple forms of relabeling can be accomplished independant of both the
application code and the document parsing by operations on namespaces. in this
instance by
- asserting the identity of names in two namespaces
- providing an alias for the namespace which the application knew.



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS