W3C home > Mailing lists > Public > xproc-dev@w3.org > October 2011

Re: Namespace problems in XPath expression with label attribute

From: Georges Schmitz <georges.schmitz@arcor.de>
Date: Tue, 25 Oct 2011 00:52:10 +0200
Message-ID: <4EA5EC1A.8000404@arcor.de>
To: Florent Georges <fgeorges@fgeorges.org>
CC: vojtech.toman@emc.com, xproc-dev@w3.org
Hi Vojtech, hi Florent,

well, I inspected the wrong place of my result document produced with 
calumet (which was pretty large), and I wasn't completly right nor 
wrong, because calumet produces *some* output with elements bound to a 
namespace, but *not* the one I expect. Please see the examples below.

A) The PIPELINE could be as simple as this one:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" 
xmlns:ns2="http://www.empic.aero/ns/empic-eap/oas"
     version="1.0" name="clean-up-ratings">
<p:input port="source" primary="true">
<p:empty/>
</p:input>
<p:output port="result"/>

<p:label-elements match="ns2:rating-entry" attribute="synchro-id" 
label="concat('eap-145','-', parent::ns2:rating-entry/ns2:code, '-', 
ns2:code)" replace="true" name="init-synchro-id"/>

</p:declare-step>

B) the INPUT document

<rating-system-export xmlns:ns2="http://www.empic.aero/ns/empic-eap/oas">
<ns2:rating-root >
<ns2:name>EASA 145</ns2:name>
<ns2:rating-entry >
<ns2:code>A</ns2:code>
<ns2:text xml:lang="en">Aircraft</ns2:text>
<ns2:rating-entry >
<ns2:code>A1</ns2:code>
<ns2:text xml:lang="en">Aeroplane above 5700 kg</ns2:text>
<ns2:rating-entry >
<ns2:code>DUMMY</ns2:code>
<ns2:text xml:lang="en">Will state aeroplane/ series or type and/or the 
maintenance task(s)</ns2:text>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-root>
</rating-system-export>

C) CALUMET OUTPUT:

<rating-system-export xmlns:ns2="http://www.empic.aero/ns/empic-eap/oas">
<ns2:rating-root>
<ns2:name>EASA 145</ns2:name>
<ns2:rating-entry synchro-id="eap-145--">
<ns2:code>A</ns2:code>
<ns2:text xml:lang="en">Aircraft</ns2:text>
<ns2:rating-entry synchro-id="eap-145-A-">
<ns2:code>A1</ns2:code>
<ns2:text xml:lang="en">Aeroplane above 5700 kg</ns2:text>
<ns2:rating-entry synchro-id="eap-145-A1-">
<ns2:code>DUMMY</ns2:code>
<ns2:text xml:lang="en">Will state aeroplane/ series or type and/or the 
maintenance task(s)</ns2:text>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-root>
</rating-system-export>

==>> the direct child element "ns2:code" is not evaluated, the last 
synchro-id attribute should be "eap-145-A1-DUMMY", but "DUMMY" is missing.

D) NO OUTPUT with CALABASH, exception instead:

25.10.2011 00:43:49 com.xmlcalabash.util.DefaultXProcMessageListener error
SCHWERWIEGEND: 
cleanup-lang-and-customer.xpl:10:149:err:XD0023:Expression could not be 
evaluated
25.10.2011 00:43:49 com.xmlcalabash.drivers.Main error
SCHWERWIEGEND: It is a dynamic error if an XPath expression is 
encountered which cannot be evaluated (because it is syntactically 
incorrect, contains references to unbound variables or unknown functio
ns, or for any other reason).
25.10.2011 00:43:49 com.xmlcalabash.drivers.Main error
SCHWERWIEGEND: Underlying exception: 
net.sf.saxon.s9api.SaxonApiException: Prefix ns2 has not been declared

E) replace "ns2" with "*" in the label attribute of the pipeline

    label="concat('eap-145','-', parent::*:rating-entry/*:code, '-',
    *:code)"

and run it again with calabash gives me finally the expected result (but 
using the * wildcard is not satisfying and furthermore it doesn't work 
with calumet):

<rating-system-export xmlns:ns2="http://www.empic.aero/ns/empic-eap/oas">
<ns2:rating-root>
<ns2:name>EASA 145</ns2:name>
<ns2:rating-entry synchro-id="eap-145--A">
<ns2:code>A</ns2:code>
<ns2:text xml:lang="en">Aircraft</ns2:text>
<ns2:rating-entry synchro-id="eap-145-A-A1">
<ns2:code>A1</ns2:code>
<ns2:text xml:lang="en">Aeroplane above 5700 kg</ns2:text>
<ns2:rating-entry synchro-id="eap-145-A1-DUMMY">
<ns2:code>DUMMY</ns2:code>
<ns2:text xml:lang="en">Will state aeroplane/ series or type and/or the 
maintenance task(s)</ns2:text>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-entry>
</ns2:rating-root>
</rating-system-export>

Hope these examples are detailed enough to identify the problems in both 
tools.

Greetings,
Georges
Received on Monday, 24 October 2011 22:52:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 24 October 2011 22:52:49 GMT