Re: Namespace bindings

/ Jeni Tennison <jeni@jenitennison.com> was heard to say:
| Norman Walsh wrote:
|> Do we expect the following pipeline to work?

The consensus on the 9 Aug 2007 call was, "no".

| Yes, I think we should support this too.

The whole question of merging namespace bindings taken from variable
references used in XPath expressions used to compute option values was
viewed with great suspicion.

The option that no one on the call objected to was, "user loses".

An alternative option, raised by Alex just before the call ended,
might be sufficient and sufficiently simpler to win consensus.

His suggestion was to add a new attribute to p:option, call it
context. It contains an XPath select expression that must evaluate to
a node. The namespace bindings on that node are used as the namespaces
for evaluating the expression passed in select. If the 'context'
attribute isn't provided, the namespaces in-scope on the p:option
element are used.

So, case 1:

<p:pipeline xmlns:p="...">
  <p:option name="delete" value="html:div"
            xmlns:html="http://www.w3.org/1999/xhtml"/>

  <p:delete>
    <p:input port="source">
      <p:inline>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>...</head>
        <body>
          <h1>Delete My Divs</h1>
          <div>
            ...
          </div>
        </body>
      </p:inline>
    </p:input>

    <p:option name="match" select="$delete"
              xmlns:html="http://www.w3.org/1999/xhtml"/>
  </p:delete>
</p:pipeline>

In other words, don't do that. If you have control of the situation,
make the namespaces work.

and, in case 2, where local.xml contains:

  <commands>
    <delete xmlns:h="http://www.w3.org/1999/xhtml"
            match="h:div"/>
  </commands>

we do this

<p:pipeline xmlns:p="...">
  <p:load name="load-commands" href="local.xml"/>

  <p:delete>
    <p:input port="source">
      <p:inline>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>...</head>
        <body>
          <h1>Delete My Divs</h1>
          <div>
            ...
          </div>
        </body>
      </p:inline>
    </p:input>

    <p:option name="match" select="/commands/delete/@match"
              context="/commands/delete">
      <p:pipe step="load-commands" port="result"/>
    </p:option>
  </p:delete>
</p:pipeline>

At least I think I could explain that. I wonder if it's a useful
strategy.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | Nothing is more depressing than
http://nwalsh.com/            | consolations based on the necessity of
                              | evil, the uselessness of remedies, the
                              | inevitability of fate, the order of
                              | Providence, or the misery of the human
                              | condition. It is ridiculous to try to
                              | alleviate misfortune by observing that
                              | we are born to be miserable.--
                              | Montesquieu

Received on Thursday, 9 August 2007 18:24:18 UTC