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] QNames in attribute values

[ Lists Home | Date Index | Thread Index ]

"Prefixes" are an artifactual problem. It does not exist where universal
names are modelled as first-class objects. With the appearance of the
query data model, there was hope that this might some day happen. The
mechanisms described by the Namespaces Recommendation are, in
themselves, sufficient to produce complete unambiguous models from
NS-valid XML. One can argue, that the parser oversteps where it interns
values beyong element identifiers and attribute names which are
specified to be in the universal-name domain. On the other hand, it
already does this with any NMTOKEN(S)-domain attributes which are
significant for validity. One can still hope.

CL-XML has always used interned first-class names. Which means that
document model integrity has never been an issue. This has always been
true of element identifiers and attribute names under dom-mutation. I'd
not yet looked at serializing "QNAME"-valued nodes, so just to see what
would happen, I extended CL-XML's DTD syntax to recognize QNAME as a
tokenized attribute type and specialized the serializer methods for that
class of attribute node.

The results demonstrate the benefits of first-class names. Note, in
particular, the absense of both namespace nodes and a prefix in the
second example.
NB. the wildcarded {*}qname name is necessary as the
namespace-name->namespace binding has document scope.
NB. the prefix "a" of the {data:,ns-a}qname attribute does not signify,
since the prefix is fixed at the point where the element identifier is serialized.


Michael Kay wrote:
> > Why must namespaces be restricted to only scoping element and
> > attribute
> > names? That seems to me to be unnecessarily restrictive.
> > Other artifacts
> > need name-scoping mechanisms, as well, and I don't see why we
> > should force
> > them to find another means of accomplishing this.
> I think the problem is (a) that a document that uses QNames in content is
> dependent on the namespace prefixes, and (b) that this dependency isn't
> explicit. The result of this is that when a processor (e.g. an XSLT
> processor) copies an element to a new place, it has to copy all the in-scope
> namespace nodes, because it has no way of knowing which of the namespace
> nodes are actually needed.

? (defParameter *doc-node-qnames* 
       "<!DOCTYPE doc [
    <!ELEMENT doc (a:x)* >
    <!ATTLIST doc xmlns CDATA 'data:,ns-top'>
    <!ELEMENT a:x EMPTY>
    <!ATTLIST a:x
              xmlns:a CDATA 'data:,ns-a'
              a:qname QNAME 'a:test'>

   <doc xmlns='data:,ns-top'
     <x xmlns='data:,ns-a'></x>
       :validate t))

? (write-node *doc-node-qnames* *trace-output* :encoding :us-ascii)

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<!DOCTYPE doc [
 <!ENTITY quot '&#34;' >
 <!ENTITY amp '&#38;' >
 <!ENTITY gt '>' >
 <!ENTITY lt '&#60;' >
 <!ENTITY apos '&#39;' >
 <!ELEMENT doc (nsp-163:x)* >
 <!ATTLIST doc 
   xmlns CDATA  'data:,ns-top' >
 <!ATTLIST doc 
   xmlns:nsp-163 CDATA 'data:,ns-a' >
 <!ATTLIST a:x 
   xmlns:a CDATA  'data:,ns-a'
   a:qname CDATA  'a:test' >
<doc xmlns='data:,ns-top' xmlns:a='data:,ns-a'>
     <a:x xmlns='data:,ns-a' xmlns:a='data:,ns-a' a:qname='a:test' />
#<DOC-NODE <no uri> #x9DBDD26>

? (write-node (elem-child (root *doc-node-qnames*) '{*}x)
              :encoding :us-ascii)
<a:x xmlns='data:,ns-a' xmlns:a='data:,ns-a' a:qname='a:test' />
#<ELEM-NODE #<UNAME {data:,ns-a}x> 2 #x9DBB61E>

? (describe (elem-get (elem-child (root *doc-node-qnames*) '{*}x) '{*}qname)
Wrapper: #<CCL::CLASS-WRAPPER UNAME #x93602AE>
Instance slots
LOCAL-PART: "test"
NAMESPACE: #<NAMESET-TOKENIZER data:,ns-a 3 (23) #x9DB923E>

? (let* ((uname-value (elem-get (elem-child (root *doc-node-qnames*) '{*}x)
         (elem-uname (intern-name "newElement" (namespace uname-value)))
         (element (make-elem-node :name elem-uname
                                  (list (make-qname-attr-node :name uname-value
                                                              :value uname-value
                                                              :children nil))
                                  '("this demonstrates the benefits"
                                    "of first-class names. it doesn't"
                                    "matter, whether prefixes are retained...")))
         (*print-pretty* t))
    (setf (prefix elem-uname) "aPrefix")
    (write-node element *trace-output* :encoding :us-ascii))
<aPrefix:newElement aPrefix:test='aPrefix:test' xmlns:aPrefix='data:,ns-a'>
 this demonstrates the benefits
 of first-class names. it doesn't
 matter, whether prefixes are retained...
#<ELEM-NODE #<UNAME {data:,ns-a}newElement> #x9DC866E>

? (let* ((uname-value (elem-get (elem-child (root *doc-node-qnames*) '{*}x)
       (elem-uname (intern-name "newElement" (namespace uname-value)))
       (element (make-elem-node :name elem-uname
                                (list (make-qname-attr-node :name uname-value
                                                            :value uname-value
                                                            :children nil))
                                '("... or not. if the model is complete,"
                                  "operations are closed and the
serialized form is NS-valid."
       (*print-pretty* t))
  (setf (prefix elem-uname) nil)
  (describe elem-uname)
  (describe element)
  (write-node element *trace-output* :encoding :us-ascii))

;(describe elem-uname)
Wrapper: #<CCL::CLASS-WRAPPER UNAME #x93602AE>
Instance slots
LOCAL-PART: "newElement"
NAMESPACE: #<NAMESET-TOKENIZER data:,ns-a 4 (23) #x9DA5BD6>

;(describe element)
#<ELEM-NODE {data:,ns-a}newElement #x9DBF9BE>
Instance slots
NAME: {data:,ns-a}newElement
CHILDREN: ("... or not. if the model is complete,"
           "operations are closed and the serialized form is NS-valid." "...")
ATTRIBUTES: (#<QNAME-ATTR-NODE {data:,ns-a}test #x9DBF96E>)

;(write-node element *trace-output* :encoding :us-ascii)
<nsp-163:newElement nsp-163:test='nsp-163:test' xmlns:nsp-163='data:,ns-a'>
 ... or not. if the model is complete,
 operations are closed and the serialized form is NS-valid.
#<ELEM-NODE #<UNAME {data:,ns-a}newElement> #x9DBF9BE>



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

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