Suggested function name is wrong when a default namespace is

Having trouble installing Oxygen? Got a bug to report? Post it all here.
fsteimke
Posts: 80
Joined: Tue Jan 01, 2013 3:19 pm

Suggested function name is wrong when a default namespace is

Post by fsteimke »

Hi,

i have a user defined function called db:empty-element($e). It is defined in a file where the namespace db is defined as xmlns:db="http://docbook.org/ns/docbook". This is also the default namespace in this file, set by the xpath-default-namespace attribute.

This File is xs:included in another file. Here we have the same namespace definition for db, which is also the default namespace.

I'd like to use the function which is defined in the included file. So i type select='db:emp<TAB>' but here is no suggestion. There is a suggestion, hoewever, when i type select='emp<TAB>. This is completed to select='empty-element(()'. This leads immediatly to an error since the compiler can`t find a function called empty-element. I have to correct it to 'db:empty-element()'.

conclusion: completion has to deal with the namespace-prefix for user-definied functions although a default-namespace is defined.

Sincerely,
Frank Steimke
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: Suggested function name is wrong when a default namespac

Post by adrian »

Hi,

What version of Oxygen are you using (Help > About)?

I'm guessing (from the mentioned xpath-default-namespace) that you're referring to a user defined function in XSL 2.0.
xpath-default-namespace only works for element names or type names, but not function names:
http://www.w3.org/TR/xslt20/#unprefixed-qnames
So, despite the 'xpath-default-namespace' (default namespace for XPath), it shouldn't propose the function name without the namespace prefix.

I've tested what you described with these samples:
module.xsl

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:db="myns"
xpath-default-namespace="myns">
<xsl:function name="db:empty-element">

</xsl:function>
</xsl:stylesheet>
main.xsl:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:db="myns"
xpath-default-namespace="myns">
<xsl:include href="module.xsl"/>
<xsl:template name="start">
<xsl:value-of select="db:empty-element()"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
In this case, in the xsl:value-of/@select, it proposes db:empty-element(). I don't see an empty-element() proposal (without the namespace prefix). If I type 'emp', I do get an empty() proposal, but that's an XPath function.
Could you please provide a sample XSL where you obtained that?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
fsteimke
Posts: 80
Joined: Tue Jan 01, 2013 3:19 pm

Re: Suggested function name is wrong when a default namespac

Post by fsteimke »

Hi Adrian,

i am using oxygen 16.1 build 2014100319 on windows 7. And yes, i am referring to user-defined functions.

I tried to boil it down to a simple example and i failed, as you did. So i tried to reproduce it with my production files and that worked. Same error as i wrote in my first mail.

I am working with a hierarchy of scripts, all of them have the same namespace (which is the DocBook 5 Namespace) as xpath-default-namespace. A prefix db: is defined in all of these scripts for this Namespace. All of them have XSL Version 3.

abruf-core (Level 0): defines a function db:empty-element in the db namespace.
abruf-kositdb (Level 1) includes abruf-core. Everything fine, function db:empty-element() is suggested.
abruf-commons (Level 2) includes abruf-kositdb: Does it wrong, as i have described in my first mail. empty-element() is suggested, without prefix, and leads to an error.

However, i tried several times, and i am pretty sure that i have seen that level 2 has been ok, but level 3 (abruf2übersicht, which imports abruf-commons) was not. Maybe a problem with caches?

As i said, i was unable to boil it down, even with a hierarchy of simple scripts.

Sincerely,
Frank Steimke
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: Suggested function name is wrong when a default namespac

Post by adrian »

Hi,

I tested with XSL 3.0 and 2 levels of includes, but still can't reproduce what you're describing. My guess is there's something else in your context that affects this.

If you isolate the 3 mentioned XSL files of the hierarchy from the rest, do you still reproduce the issue?
If possible (and if the problem still reproduces with the files isolated from the rest), please send us those 3 files to support@oxygenxml.com.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply