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

Re: XMap: A Mechanism for Mapping Names


mapping names

three questions before i leave you to formulate the gory details:

you wrote:
> 
> 
> Structurally, the three part morphology
> 
>     xmlmap :  n1  n2
>         n1 :  URI
>         n2 :  e1 l1 e2 l2 ....
> 
> is an association of the URI with the list (interpretable as a hash), like
> in Perl:
> 
>      { ...
>        URI  =>  { e1 => l1
>                   e2 => l2
>                   ...
>                 }
>      }
> 

1. how to encode the mapping specification?

what is the advantage of

resolver == URI -> local-name -> external-name

over

resolver == local-name -> (URI x external-name)

since the local name must be unique in any given context. this would suggest an alternative morphology, and thereby, encoding:

xmlmap : n1 n2
n1 : (URI1 e1 l1) (URI2 e2 l2)

whereby the URIs may be identical



2. ontology, taxonomy, or name set

> |>| please do it in advance.  please do not repeat the sins of "namespaces".
> |>
> |>I have no idea what you're talking about.
> |
> | the uncertainty as to whether what matters is the set of names or where
> | they come from and or are used.
> 
> The sins of Namespaces are on the heads of its (their?) advocates.  It
> always matters where the names we use *in processing* came from.  Names
> actually occuring in markup can be arbitrary.  They are merely a scaffold
> for the arch.

why does "where the names came from" matter for a renaming transformation?


3.
> |>| does the "element" scope entail contained elements?
> |>
> |> I "guess" so, but then again, maybe not.  Seriously, I have no idea why
> |> your notion of "scope" matters to you.
> |
> | it matters because, to the extent that XMap is intended to subsume
> | namespaces in XML, under certain conditions it will behave the same,
> | which means that  while performing the transformation which XMap
> | describes, the pairs in the control attributes are equivalent to variable
> | bindings and the transformation itself is equivalent to beta-conversion.
> 
> I don't see how. I'd say XMap is an analog of alpha renaming.

it is alpha-conversion only if one posits an implicit binding for each name. an implementation looks a lot more like beta-conversion.

taking the analog to the original example expression, reformulated in the alternative encoding:

<img src="some.gif"
           xmlmap="yy"
           yy="{http://www.w3.org/1999/xlink}href {}src
               {http://www.w3.org/1999/xlink}type {}foo
               {http://www.w3.org/1999/xlink}role {}bar
               {http://www.w3.org/1999/xlink}title {}quux"
           foo="simple"
           bar="http://example.org/some/role"
           quux="Sleeping Kitty"
           >

this can be represented with a model which has the following, simple, readable abstract syntax as

? (defParameter *form_* '(({}img ({}src . "some.gif")
                               ({}xmlmap . "{}yy")
                               ({}yy . "{http://www.w3.org/1999/xlink}href {}src
                                        {http://www.w3.org/1999/xlink}type {}foo
                                        {http://www.w3.org/1999/xlink}role {}bar
                                        {http://www.w3.org/1999/xlink}title {}quux")
                               ({}foo . "simple")
                               ({}bar . "http://example.org/some/role")
                               ({}quux . "Sleeping Kitty"))
                        "some content or other"))
*FORM_*

;; which permits the following definition for XMap, (i hope this isn't wrapping too badly, and
;; neglect the special case for GI mapping and the question of scoping)

? (defGeneric XMap (form)
  (:method ((form list))
           (labels ((read-names (string)
                      (let ((names nil) (name nil))
                        (with-input-from-string (stream string)
                          (loop (unless (setf name (read stream nil nil)) (return (nreverse names)))
                                (push name names)))))
                    (make-alist (mapping)
                      (when mapping (acons (second mapping) (first mapping) (make-alist (cddr mapping))))))
             (xmla:with-abstract-element ((gi &rest attributes) &rest content) form
               (xmla:with-abstract-attributes ((xmlmap-attr {}xmlmap)) attributes
                 ;; collect the mappings from the attributes
                 (let ((mappings
                        (make-alist
                         (apply #'append (mapcar #'read-names
                                                 (mapcar #'(lambda (attr-name)
                                                             (xmla:get-abstract-property-value attributes attr-name))
                                                         (read-names xmlmap-attr)))))))
                   (setf form (apply #'xmla:make-element gi (copy-alist attributes) (mapcar #'XMap content)))
                   (if mappings  ;; perform the transformation if a mapping spec is present
                     (nsublis mappings form)
                     form))))))
  (:method ((form t)) form))
#<STANDARD-GENERIC-FUNCTION XMAP #x63EAE96>

;; which, when applied to the example form, yields

? (pprint (xmap *form_*))

(({}img ({http://www.w3.org/1999/xlink}href . "some.gif") ({}xmlmap . "{}yy")
  ({}yy . "{http://www.w3.org/1999/xlink}href {}src
                                        {http://www.w3.org/1999/xlink}type {}foo
                                        {http://www.w3.org/1999/xlink}role {}bar
                                        {http://www.w3.org/1999/xlink}title {}quux")
  ({http://www.w3.org/1999/xlink}type . "simple") ({http://www.w3.org/1999/xlink}role . "http://example.org/some/role")
  ({http://www.w3.org/1999/xlink}title . "Sleeping Kitty"))
 "some content or other")

;; or alternatively, reserialized

? (write-node (xmap *form_*) *trace-output*)
<img nsp-1:href='some.gif' xmlmap='{}yy' yy='{http://www.w3.org/1999/xlink}href {}src
                                        {http://www.w3.org/1999/xlink}type {}foo
                                        {http://www.w3.org/1999/xlink}role {}bar
                                        {http://www.w3.org/1999/xlink}title {}quux' nsp-1:type='simple'
     nsp-1:role='http://example.org/some/role'
     nsp-1:title='Sleeping Kitty' xmlns:nsp-1='http://www.w3.org/1999/xlink'>some content or other</img>
NIL

...

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.