简体   繁体   English

删除MarkLogic函数中的“fn:”?

[英]Drop the “fn:” in MarkLogic functions?

Is there a way with MarkLogic to not have to prefix every single fn: function with that prefix? 有没有一种方法可以让MarkLogic不必为每个fn:前缀添加前缀的函数? I've seen lots of codes on the Internet that show me that I don't need it. 我在互联网上看到很多代码告诉我我不需要它。

Things can get rather verbose, you know? 你知道,事情会变得相当冗长吗? fn:not(fn:contains(...)) , instead of not(contains(...)) fn:not(fn:contains(...)) ,而not(contains(...))

Thoughts? 思考?

Thanks! 谢谢!

Like you, I prefer not to type fn: in front of all my fn:functions. 和你一样,我不想在我所有的fn:函数前输入fn:

In normal XQuery main modules you don't need the fn: prefix because that's the default function namespace and used for all unprefixed functions. 在普通的XQuery主模块中,您不需要fn:前缀,因为这是默认的函数名称空间,并用于所有未加前缀的函数。 You do however need fn: in library modules because they change their default function namespace to that of the library module namespace. 得视需要fn: ,因为他们改变缺省函数命名空间到库模块命名空间的库模块。 This means the library functions can call each other without any prefix. 这意味着库函数可以相互调用而无需任何前缀。

But you can change it back! 但你可以改回来! Here's the header code to do the switch back. 这是切换回的标题代码。

xquery version "1.0-ml";
module namespace util = "http://markmail.org/util";
declare default function namespace "http://www.w3.org/2005/xpath-functions";

Or if you're on the older 0.9-ml: 或者,如果您使用的是旧版0.9毫升:

xquery version "0.9-ml"
module "http://markmail.org/util"
declare namespace util = "http://markmail.org/util"
default function namespace = "http://www.w3.org/2003/05/xpath-functions"

It puts the module in a given namespace, assigns util to that namespace, then assigns the default back to the normal fn: one. 它将模块放在给定的命名空间中,将util分配给该命名空间,然后将默认值分配给正常的fn: one。

After this switch, function calls and definitions without a prefix will default to the fn: prefix; 在此切换之后,没有前缀的函数调用和定义将默认为fn: prefix; that means all functions in the util library should explicitly use a util: prefix. 这意味着util库中的所有函数都应该显式使用util:前缀。 (Personally, I think that's cleaner anyway.) (就个人而言,无论如何,我认为这更干净。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM