- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Tue, 07 Aug 2007 10:17:40 +0100
- To: public-xml-processing-model-wg@w3.org
Norman Walsh wrote:
> Do we expect the following pipeline to work?
>
> <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"/>
> </p:delete>
> </p:pipeline>
>
> Where "work" means that the pipeline runs and produces:
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>...</head>
> <body>
> <h1>Delete My Divs</h1>
> </body>
Yes, I think we have to support this.
> Suppose local.xml contains:
>
> <commands>
> <delete xmlns:h="http://www.w3.org/1999/xhtml"
> match="h:div"/>
> </commands>
>
> Do we expect this to work?
>
> <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">
> <p:pipe step="load-commands" port="result"/>
> </p:option>
> </p:delete>
> </p:pipeline>
Yes, I think we should support this too.
Here's a proposed wording:
Each option value has a set of namespace bindings associated with it.
The namespace bindings used depend on the way in which the option is
specified, as follows:
(a) if the option is specified with the value attribute, the namespace
bindings are the set of namespace bindings on the <p:option> element itself.
(b) otherwise, if the select attribute contains a single variable
reference, the namespace bindings are set of namespace bindings from the
referenced option.
(c) otherwise, if the result of evaluating the select attribute is a
node, the namespace bindings are the in-scope namespaces from that node.
(d) otherwise, the namespace bindings are the union of:
i) the namespace bindings on the <p:option> element
ii) the namespace bindings of all options referenced in the select
attribute
It is a dynamic error (ERR:XXXXX) if there's more than one
namespace binding for a given prefix with different namespace URIs.
---
A variation on the above would be to exclude the default namespace from
the set of namespace bindings that are associated with the option. If
the default namespace *isn't* excluded (as above), you'll get more
errors under (d) than you would if it *were* excluded. But if they *are*
excluded, then QNames won't work in the normal-for-XSD way. I'm inclined
to stick with it as it is above: if you get to (d) then you're going to
have to take great care with namespaces anyway.
(I don't know if QNames in XProc usually work in the normal-for-XSD way,
using the default namespace for unprefixed names, or the
normal-for-XPath way, using no namespace for unprefixed names? For
example, what if the value of the type attribute on <p:pipeline> doesn't
have a prefix? I don't recall seeing any statement about this, but maybe
I missed it.)
Also, suppose local.xml contains:
<commands>
<delete xmlns:h="http://www.w3.org/1999/xhtml"
match="h:div"/>
</commands>
In this case, the following pipeline *won't* work:
<p:pipeline xmlns:p="..." xmlns:html="http://www.w3.org/1999/xhtml">
<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="concat('html:body/', /commands/delete/@match)">
<p:pipe step="load-commands" port="result"/>
</p:option>
</p:delete>
</p:pipeline>
because the only namespaces passed into the match option are the ones on
the <p:option> (it falls under (d) above).
But you can make it work by defining an intermediate option like this:
<p:pipeline xmlns:p="..." xmlns:html="http://www.w3.org/1999/xhtml">
<p:load name="load-commands" href="local.xml"/>
<p:group>
<p:option name="local-match" select="/commands/delete/@match">
<p:pipe step="load-commands" port="result"/>
</p:option>
<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>
</html>
</p:inline>
</p:input>
<p:option name="match"
select="concat('html:body/', $local-match)" />
</p:delete>
</p:group>
</p:pipeline>
because in this case the $local-match will have the namespace bindings
from local.xml, and the match passed into the <p:delete> will union
these with the ones on the <p:option>.
Cheers,
Jeni
--
Jeni Tennison
http://www.jenitennison.com
Received on Tuesday, 7 August 2007 09:17:45 UTC