grtjn / marklogic-typescript-definitions

TypeScript Definition files for MarkLogic built-in functions, available as npm module
Apache License 2.0
9 stars 2 forks source link

Cannot Find Name 'xs' #17

Closed sjordan1975 closed 6 years ago

sjordan1975 commented 8 years ago

xs namespace is missing from typings file.

See attached: xs namespace

grtjn commented 8 years ago

Thnx!

@christyharagan what do you make of this?

christyharagan commented 8 years ago

Yup, again, just bad typing. I'll get a fix in.

christyharagan commented 7 years ago

Hang on a second... shouldn't that be:

fn.QName("")
sjordan1975 commented 7 years ago

@christyharagan Insert a document with the following:

declareUpdate();

xdmp.documentInsert('/test.xml', xdmp.unquote("<name>John Doe</name>"))

Then run the following query:

cts.search(cts.elementValueQuery(xs.QName("name")))

christyharagan commented 7 years ago

But I mean, isn't the QName function in the fn namespace, not xs.

xs.QName is the value, whereas fn.QName is the constructor.

sjordan1975 commented 7 years ago

I'm not sure about that. fn.QName is a function. xs.QName is a value ???:

https://docs.marklogic.com/fn/qname:

These built-in functions are XQuery functions defined to operate on qualified name (xs:QName) values. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

I think xs.QName is shorthand for fn.QName("",value) which can also be expressed simply as "value"

In QConsole, these are all equal:

cts.search(cts.elementValueQuery("name"))
cts.search(cts.elementValueQuery(xs.QName("name")))
cts.search(cts.elementValueQuery(fn.QName("","name")))
grtjn commented 7 years ago

fn.QName is a function that takes ns + name. xs.QName is a constructor that takes a string which is local name or prefixed name. Prefix should be known. Then again not sure if xs.QName is avail at all in sjs. I mean how would one declare namespaces..

christyharagan commented 7 years ago

Hmmm, you are right. Looking a bit deeper it's a builtin Type Constructor, and our documentation doesn't talk about builtin constructors, hence we don't generate them.

@grtjn @jmakeig : If we're going to be complete here, we should probably generate all xs. type constructors. Any ideas on where we get this? Should our docs be updated?

jmakeig commented 7 years ago

@grtjn @jmakeig: If we're going to be complete here, we should probably generate all xs. type constructors. Any ideas on where we get this? Should our docs be updated?

Yes. We should aim for complete coverage of the entire public API surface area—in both the docs and the typings. I think the first step will be some gap analysis. Is there a classification scheme we can start with?

grtjn commented 7 years ago

Not sure. Not even sure ML docs divides things in categories at all, other than perhaps by prefix, e.g. xdmp, cts, etc.

What do you mean by built-in?

jmakeig commented 7 years ago

“Built-in” means implemented in C++. The end-user doesn’t care where an API is implemented, but the details often matter for how we actually expose things.

grtjn commented 6 years ago

Fair point, but the api docs don't bother to describe the built-in types like xs:QName. We can only generate typedefs for what is provided in the apidocs. If you can get it added, then it will get included here as well.. :)

grtjn commented 6 years ago

This also explains why all xs: types are translated to a primitive or Object

grtjn commented 6 years ago

On second thought, seems like Christy did a lot of pre-work to manually add this. I'll look into making it more complete. xs.QName was already exposed in v0.3.0 of this types lib, but I'll try to add a few more..