from XProc: W3C Recommendation / p:xquery
The p:xquery step applies an [XQuery 1.0] query
can I use xproc with XQuery 3.1?
Yes, you can use it. New XQuery implementation on top of MarkLogic, but eXist accept just old implementation. XProc
I think the XProc spec mentions [XQuery 1.0] simply because there was no XQuery 3.x at the time when the XProc 1.0 came out. (The same applies to the p:xslt step and support for XSLT 3.0.) It is difficult to claim support for future versions of specifications without knowing what they will look like and what impact they may have.
Having said that, however, I think XProc implementers take a pragmatic approach and usually support the latest versions of the specifications. For instance, Calumet with the xDB plug-in supports whatever XQuery version that xDB supports (3.1 as of xDB version 11).
Related
I struggled with this for hours before finding out that you have to use from_ instead of from when using gremlin javascript.
After digging through the source code I finally found out that the code is using from_ instead of from (see code). Since I'm a newbie this comes off as strange because its counterpart to is still to (and not to_, see code here)
I googled everywhere but couldn't find the reason why this works this way, and feel uneasy about using the underscore version since most of the times underscores denote private methods that users should not really trust.
Also, is there an official documentation page for gremlin javascript somewhere I'm missing? I'm concerned I may run into these problems in the future and there's not really an official documentation for the JavaScript version and I may need to go through the same struggle. I like gremlin, but if the JavaScript version is not stable and should not be used, I might as well look into other alternatives than Tinkerpop suites.
Gremlin Language Variants (GLVs) are given some latitude in terms of how they implement the Gremlin language so that it feels as close to the syntax and programming idioms of the native language and thus avoid too much pollution from Java. In other words, if you're using gremlin-javascript it should feel like your coding in JS and not Java. So, you will see slight differences among GLVs from time to time.
So, with respect to from_ specifically, we typically use an underscore when we have a conflict in a native language with a reserved keyword. In Java from is fully acceptable, but in other languages it is not. For Javascript, from is currently not a reserved word, but we are preparing for the eventual form of import ... from which is coming in the future.
As for documentation, I'm not aware of too much more than what you have already found on the TinkerPop web site. We hope to have more examples and information available in our next release.
I struggled with this for hours before finding out that you have to use from_ instead of from when using gremlin javascript.
After digging through the source code I finally found out that the code is using from_ instead of from (see code). Since I'm a newbie this comes off as strange because its counterpart to is still to (and not to_, see code here)
I googled everywhere but couldn't find the reason why this works this way, and feel uneasy about using the underscore version since most of the times underscores denote private methods that users should not really trust.
Also, is there an official documentation page for gremlin javascript somewhere I'm missing? I'm concerned I may run into these problems in the future and there's not really an official documentation for the JavaScript version and I may need to go through the same struggle. I like gremlin, but if the JavaScript version is not stable and should not be used, I might as well look into other alternatives than Tinkerpop suites.
Gremlin Language Variants (GLVs) are given some latitude in terms of how they implement the Gremlin language so that it feels as close to the syntax and programming idioms of the native language and thus avoid too much pollution from Java. In other words, if you're using gremlin-javascript it should feel like your coding in JS and not Java. So, you will see slight differences among GLVs from time to time.
So, with respect to from_ specifically, we typically use an underscore when we have a conflict in a native language with a reserved keyword. In Java from is fully acceptable, but in other languages it is not. For Javascript, from is currently not a reserved word, but we are preparing for the eventual form of import ... from which is coming in the future.
As for documentation, I'm not aware of too much more than what you have already found on the TinkerPop web site. We hope to have more examples and information available in our next release.
I wonder if there is a way to introspect XQuery modules and dynamically access functions. This would help me to implement the GOF strategy pattern as XQuery does not have support for multiple implementations for the same interface.
The problem, of course, is that there seems to be no support for introspection in XQuery except for checking for types of variables.
Any ideas on how this pattern can be implemented in XQuery? (I use MarkLogic 9)
thanks a lot,
K.
PS. Unfortunately, most XQuery resources I could find focus on small details of this or that functionality but I could not find one such resource that takes XQuery as a serious programming language on its own right and addresses such software design issues
XQuery 3.0+ and MarkLogic 9 support first-class functions. In many cases, you can rework common OO design patterns into functional programming equivalents using first-class functions and dependency injection.
Also, you can access in-scope functions via xdmp:functions().
There is a way to get reflection-like functionality in ML, but it's kind of a hack. Take a look at this library, which throws an exception, catches it, and uses the exception payload to inspect the stack:
https://github.com/marklogic/cq/blob/master/lib-debug.xqy
For more XQuery programming patterns and techniques, you might want to review the proceedings from various XML-oriented conferences like Balisage, XML Prague, and XML London. Also, searching GitHub repos for XQuery projects and reading code can be helpful.
When jQuery, Microsoft or some other software company says:"this function is deprecated".
For example, when there is a func1 that works fine in version 1.0 and is deprecated in version 2.0 that also introduces a new func2:
Should func1 also be included in version 2.0 for backwards compatibility?
Is func1 supposed to work without bugs in version 2.0? ( func2 is fine with versions 2 and 1)
Is func2 allowed not to work correctly in version 2.0?
What does deprecation really mean and does it mean the same in all organizations?
For ex. the live method in jQuery doesn't work in 1.7 in IE but it does in Chrome).
I think the Wikipedia-article on Deprecation answers this one pretty well:
In the process of authoring computer software, its standards or documentation, deprecation is a status applied to software features to indicate that they should be avoided, typically because they have been superseded. Although deprecated features remain in the software, their use may raise warning messages recommending alternative practices, and deprecation may indicate that the feature will be removed in the future. Features are deprecated—rather than immediately removed—in order to provide backward compatibility, and give programmers who have used the feature time to bring their code into compliance with the new standard.
Deprecated means they don't recommend using it, and that it isn't undergoing further development. But it should not work differently than it did in a previous version unless documentation explicitly states that.
Yes, otherwise it wouldn't be called "deprecated"
Unless stated otherwise in docs, it should be the same as before
No, but if there were problems in v1 they aren't about to fix them
If there are true answers to those questions, it would be different per software vendor and would be defined by the vendor. I don't know of any true industry standards that are followed with regards to this matter.
Historically with Microsoft, they'll mark something as deprecated and state they'll remove it in a future version. That can be several versions before they actually get rid of it though.
Deprecated in general means "don't use it".
A deprecated function may or may not work, but it is not guaranteed to work.
The simplest answer to the meaning of deprecated when used to describe software APIs is:
Stop using APIs marked as deprecated!
They will go away in a future release!!
Start using the new versions ASAP!!!
Some time back I was working on an algorithm that processed code, and required a reflections API. We were interested in its implementation for multiple languages, but the reflections API for a language would not work for any other language. So is there any thing like a "universal reflections API" that would work for all languages, or maybe for a few mainstream languages (.NET,Java,Ruby,Python)
If there isnt any, is it possible to build such a thing that can process classes from different languages.
How would you go about having a unified way to process OO code from multiple languages
I don't believe there is universal Reflection API. Any Reflection API depends on the metadata that the compiler generates for the language constructs and these can vary quite a lot from language to language, even though there is a common subset across multiple languages.
In .NET there is CodeDOM, which provides a way to generate a universal syntax tree and then serialize it as (C#, VB .NET etc...) code and/or compile it. Of course that's the mirror image of Reflection, but if anyone ever writes a tool to generate the AST directly from IL the functionality could start to overlap.
In any case its the closest thing I can think of.
A reflection API depends on the metadata generated for the code, so you can have a universal API for all languages on the JVM, or all languages on the CLR...but it wouldn't really be possible to make one that does Python, Java, and VB etc...
If you want a universal API, you need to step outside the language. See our DMS meta-tool for processing arbitrary languages, and answering arbitrary questions, including those you think of as reflection.
(Op asked for support for various languages: DMS has full parsers for C#, VB.net, Java, and Python. Ruby not yet in the list; we're working on it).