[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Vocabulary Combination and optional namespaces


combination words

Arjun Ray wrote:
> 
> Paul Prescod <paul@p...> 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
 (document-parser
"<document>
 <item><title>title one</title></item>
 <item><title>a longer title two</title></item>
 </document>"))
==>
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<document>
 <item><title>title one</title><words>2</words></item>
 <item><title>a longer title two</title><words>4</words></item>
 </document>
#<DOC-NODE <no uri> #x207B4E6>

? (let ((*namespace-dictionary* `(("http://www/rss" . ,(find-package "")) ,*namespace-dictionary*)))
  (rewrite-with-title-word-count
   (document-parser
    "<document>
 <item xmlns='http://www/rss'><title>title one</title></item>
 <item xmlns='http://www/rss'><title>a longer title two</title></item>
 </document>")))
==>
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<document>
 <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>
 </document>
#<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.

...

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.