[
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*
(document-parser
"<!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'
xmlns:a='data:,ns-a'>
<x xmlns='data:,ns-a'></x>
</doc>"
:validate t))
*DOC-NODE-QNAMES*
? (write-node *doc-node-qnames* *trace-output* :encoding :us-ascii)
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<!DOCTYPE doc [
<!ENTITY quot '"' >
<!ENTITY amp '&' >
<!ENTITY gt '>' >
<!ENTITY lt '<' >
<!ENTITY apos ''' >
<!ELEMENT doc (nsp-163:x)* >
<!ATTLIST doc
xmlns CDATA 'data:,ns-top' >
<!ATTLIST doc
xmlns:nsp-163 CDATA 'data:,ns-a' >
<!ELEMENT a:x EMPTY >
<!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>
#<DOC-NODE <no uri> #x9DBDD26>
? (write-node (elem-child (root *doc-node-qnames*) '{*}x)
*trace-output*
: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)
*trace-output*)
{data:,ns-a}test
Class: #<STANDARD-CLASS UNAME>
Wrapper: #<CCL::CLASS-WRAPPER UNAME #x93602AE>
Instance slots
PREFIX: "a"
LOCAL-PART: "test"
NAMESPACE: #<NAMESET-TOKENIZER data:,ns-a 3 (23) #x9DB923E>
? (let* ((uname-value (elem-get (elem-child (root *doc-node-qnames*) '{*}x)
'{*}qname))
(elem-uname (intern-name "newElement" (namespace uname-value)))
(element (make-elem-node :name elem-uname
:attributes
(list (make-qname-attr-node :name uname-value
:value uname-value
:children nil))
:children
'("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...
</aPrefix:newElement>
#<ELEM-NODE #<UNAME {data:,ns-a}newElement> #x9DC866E>
? (let* ((uname-value (elem-get (elem-child (root *doc-node-qnames*) '{*}x)
'{*}qname))
(elem-uname (intern-name "newElement" (namespace uname-value)))
(element (make-elem-node :name elem-uname
:attributes
(list (make-qname-attr-node :name uname-value
:value uname-value
:children nil))
:children
'("... 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)
{data:,ns-a}newElement
Class: #<STANDARD-CLASS UNAME>
Wrapper: #<CCL::CLASS-WRAPPER UNAME #x93602AE>
Instance slots
PREFIX: NIL
LOCAL-PART: "newElement"
NAMESPACE: #<NAMESET-TOKENIZER data:,ns-a 4 (23) #x9DA5BD6>
;(describe element)
#<ELEM-NODE {data:,ns-a}newElement #x9DBF9BE>
Class: #<STANDARD-CLASS ELEM-NODE>
Wrapper: #<CCL::CLASS-WRAPPER ELEM-NODE #x9ADBEBE>
Instance slots
DOCUMENT: NIL
ORDINALITY: NIL
PARENT: NIL
DEF: NIL
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>)
NAMESPACES: NIL
XML-QUERY-DATA-MODEL::VALID: #<Unbound>
;(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.
...
</nsp-163:newElement>
#<ELEM-NODE #<UNAME {data:,ns-a}newElement> #x9DBF9BE>
?
|