From: ···@usa.net
Subject: reading objects with colons
Date: 
Message-ID: <8hjae1$8jl$1@nnrp1.deja.com>
http://www.lisp.org/HyperSpec/Body/glo_p.html says that "package marker"
defaults to ":" in the standard readtable, but there appears to be no
way to change that.
So, how do I read objects which have embedded colons in them?
These objects are symbols conceptually, so, ideally, the action I would
like CL to take on reading from string "xsl:value-of" is
 - (make-package "XSL")
 - (intern "VALUE-OF" "XSL")
 - (export '(xsl::value-of) "XSL")
 - return xsl:value-of
Of course, this cannot be the default behavior, but every now and then I
would like to have it.
I use read-delimited-list, so it appears that I really do want to modify
the behavior of read here.

What would you suggest?

Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.

From: Barry Margolin
Subject: Re: reading objects with colons
Date: 
Message-ID: <mBa%4.29$fi2.408@burlma1-snr2>
In article <············@nnrp1.deja.com>,  <···@usa.net> wrote:
>http://www.lisp.org/HyperSpec/Body/glo_p.html says that "package marker"
>defaults to ":" in the standard readtable, but there appears to be no
>way to change that.
>So, how do I read objects which have embedded colons in them?
>These objects are symbols conceptually, so, ideally, the action I would
>like CL to take on reading from string "xsl:value-of" is

If it's not really Lisp syntax, then you probably shouldn't be using READ.
Trying to shoe-horn everything into READ is just going to frustrate you;
it's not designed to be a fully malleable parser.

You'll probably have to use READ-LINE and do your own parsing if there
isn't some simple readtable change that does what you want.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: ···@usa.net
Subject: Re: reading objects with colons
Date: 
Message-ID: <8hlp6t$3sa$1@nnrp1.deja.com>
Okay, I fugured this out.
http://clocc.sourceforge.net
clocc/src/cllib/xml.lisp can now handle XML namespaces!


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Pierre R. Mai
Subject: Re: reading objects with colons
Date: 
Message-ID: <874s75tgiv.fsf@orion.dent.isdn.cs.tu-berlin.de>
···@usa.net writes:

> Okay, I fugured this out.
> http://clocc.sourceforge.net
> clocc/src/cllib/xml.lisp can now handle XML namespaces!

Beware though that XML namespaces are _not_ the namespace prefixes in
identifiers.  In the following fragment, abc:foo and abc:foo are not
the same, but abc:foo and def:foo are identical:

<abc:foo xmlns:abc="bla">
  <abc:foo xmlns:abc="blub">
    <def:foo xmlns:def="bla"/>
  </abc:foo>
</abc:foo>

The above would translate to the following GIs (using ad-hoc fragment
notation to separate namespace and identifier):

<bla#foo><blub#foo><bla#foo></bla#foo></blub#foo></bla#foo>

At least that is my understanding of the XMLNS spec.  Though I fail to
understand how this won't fuck up all XML 1.0 parsers/applications.
That's why I gave up on XML namespaces...

Regs, Pierre.

-- 
Pierre Mai <····@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
From: ···@usa.net
Subject: Re: reading objects with colons
Date: 
Message-ID: <8hmeh9$k6t$1@nnrp1.deja.com>
In article <··············@orion.dent.isdn.cs.tu-berlin.de>,
  ····@acm.org (Pierre R. Mai) wrote:
> ···@usa.net writes:
>
> > Okay, I fugured this out.
> > http://clocc.sourceforge.net
> > clocc/src/cllib/xml.lisp can now handle XML namespaces!
>
> Beware though that XML namespaces are _not_ the namespace prefixes in
> identifiers.  In the following fragment, abc:foo and abc:foo are not
> the same, but abc:foo and def:foo are identical:
>
> <abc:foo xmlns:abc="bla">
>   <abc:foo xmlns:abc="blub">
>     <def:foo xmlns:def="bla"/>
>   </abc:foo>
> </abc:foo>
>
> The above would translate to the following GIs (using ad-hoc fragment
> notation to separate namespace and identifier):
>
> <bla#foo><blub#foo><bla#foo></bla#foo></blub#foo></bla#foo>

are you saing that

<foo:bar xmlns:foo="baz"/>

is completely identical to

<baz:bar/>

and they need not be distinguished in any way?

> At least that is my understanding of the XMLNS spec.  Though I fail to
> understand how this won't fuck up all XML 1.0 parsers/applications.

well, I don't think it will be all that hard to make xml.lisp handle
this mess...

> That's why I gave up on XML namespaces...

is anyone using them?


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Pierre R. Mai
Subject: Re: reading objects with colons
Date: 
Message-ID: <87n1kxrvr0.fsf@orion.dent.isdn.cs.tu-berlin.de>
···@usa.net writes:

> are you saing that
> 
> <foo:bar xmlns:foo="baz"/>
> 
> is completely identical to
> 
> <baz:bar/>

No, unless you bind the prefix baz to the namespace baz in some
enclosing element and that binding has not been shadowed.  In fact XML
prefix to namespace bindings are lexically scoped, in the same way
that variables are in CL.

What I do claim is that

<foo:bar xmlns:foo="baz"/>
is completely identical to
<oof:bar xmlns:oof="baz"/>
and that is again identical to the inner element of
<baz:goof xmlns:baz="baz">
  <baz:bar/>
</baz:goof>

i.e. that prefixes are arbitrary (in a way like nicknames, with the
exception that nicknames must be globally unique, whereas prefixes can
be lexically shadowed und reused at will).  What matters is the
namespace, i.e the URI to which the prefix is bound by the
xmlns:prefix="URI" attribute.  See the XML NS recommendation and
an article by James Clark at http://www.jclark.com/xml/xmlns.htm
for further information on this topic.

Note also that the empty prefix (i.e. the one on unqualified
identifiers of the form foo) can be bound in the same way that other
prefixes are bound, so that

<p xmlns="baz"><p xmlns="bar"><p xmlns="baz"></p></p></p>

means

<baz#p><bar#p><baz#p></baz#p></bar#p></baz#p>

again using my ad-hoc fragment notation for expanded identifiers.

> > That's why I gave up on XML namespaces...
> 
> is anyone using them?

To my knowledge only very few people use namespace aware parsers
and/or applications, most people either don't use namespaces at all,
or they treat them like XML 1.0 parsers/applications would, by
ignoring the xmlns:... attributes, and treating the prefix as part of
the identifier, thereby requiring globally unique prefixes, and
ignoring the namespaces they are bound to.

IMHO XML namespaces are a perfect example of how XML expands on the
errors of SGML, while throwing away the good bits of it...

Regs, Pierre.

-- 
Pierre Mai <····@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]