Namespaces (Was: Re: [Xpath-ng] Thoughts on work products)

David Rosenborg darolst at pantor.com
Fri Nov 29 15:02:45 MST 2002


Hi Robin,

> > I'm afraid not, because prefixes can appear in attribute values and text
> > content.
>
> Wouldn't those be quoted then?
>
> namespace("pref", "http://:foo");
> namespace("hlk", "http://hlink");
> ...
> $var = create-element("pref:foo");
> add-attribute($var, "hlk:href", "bar");
> ...
>
> But maybe we're not on the same page when referring to "node construction".

Um, yes, I suppose we are thinking differently here. The constructors I have in
mind are more like the XQuery constructors (and RELAX NG for that matter):

namespace pref = "http://foo"
namespace hlk = "http://hlink"

$var := element pref:foo { attribute hlk:href { "bar" } }

Specifying qualified names for elements and attributes is no problem. The
problem is
to explicitly specifying that namespace declarations should appear on an
element.
I'll try to illustrate it with the following real world example:

I have an XSLT stylesheet that transforms a RELAX NG schema
into an XSLT stylesheet containing just whitespace stripping rules
based on whether the elements can contain character data or not.

Given the following RELAX NG schema

default namespace = "http://example.org/ns/doc"
element doc { element body { element p { text }* } }

the output is:

<xsl:transform ...>
  <xsl:strip-space elements="*"/>
  <xsl:preserve-space xmlns:ns1="http://example.org/ns/doc" elements="ns1:p"/>
</xsl:transform>

The key point here is how to ensure that the prefix I use in the *value* of the
elements attribute gets declared on the xsl:preserve-space element.

Now, this was an XSLT example but the same issue will appear
if we have node constructors in XPath NG. In XSLT 2.0 there
is a <xsl:namespace ...> instruction which creates a namespace node.
Hence my original concern: how do we do this for node constructors
if we remove the notion of namespace nodes?

> Unrelated issue: what do we use as comments? // and /**/ seem inappropriate
at
> best :) # is used for fragment IDs, but might be contextually disambiguated.
I'm
> just interested because I wanted to insert a comment above and couldn't.

{-- I could live with the XPath 2.0 syntax --}

-- But I think dropping the braces is even better, simply less clutter --

Cheers,
David




More information about the Xpath-ng mailing list