How do i generate a random UUID in xquery - xquery

Can anyone help me with this one? I want to be able to generate a random UUID in x-query. Is there any function to do this?
thanks!

Using Saxon, you should be able to link to Java to generate the UUIDs like this:
XSLT
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uuid="java:java.util.UUID">
XQuery
declare namespace uuid = "java:java.util.UUID";
Then call the function uuid:randomUUID() anywhere in the stylesheet or XQY script.

fn-bea:uuid() is also an option for those who use BEA's xQuery implementation.
For example, when writing xQuery for Oracle Service Bus (OSB) Framework.

Related

Need a way to backport serialize() to xquery1.0

I'd like to put an xml node as CDATA in the output document and I have to use xquery1.0
How can I backport serialize()?
I have Saxon-HE-9.5.1-8.jar as XQuery processor provided by wso2-mi
I don't know details about Saxon 9.5 but it is not an old, pure XQuery 1.0 processor but somewhere between the two versions; so perhaps trying
xquery version "3.0";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'xml';
declare option output:cdata-section-elements 'foo';
works.

How to include a Qt Core c++ class for use in QtScript user function in SQLiteStudio 3.1.1?

I'm trying to write a user-defined function within SQLiteStudio (v3.1.1). This function needs to decode a field stored in base64.
I think I can achieve what I want to using the QByteArray class from Qt Core like so:
QByteArray text = QByteArray::fromBase64(base64EncodedString);
return text.data();
But how can I include/import the QByteArray class, so I can access it's methods inside my user-defined function? Is this even possible within SQLiteStudio?
I'm not sure if it is possible in SQLiteStudio, but you should be able to use SQLS' own base64_decode(arg) function.

Add namespace declaration to xml element using xquery

I would like to ask about the way to add namespace declaration into an xml element of BaseX database using xquery.
for example I have the following xml
<mynode xmlns:b2t=".."></mynode>
And I want ta add one more namespace for example xmlns:b3t=""
in order to get an xml like this
<mynode xmlns:b2t=".." xmlns:b3t=".."></mynode>
XQuery Update provides no means to add namespace declarations in an existing document. However, namespace declarations will automatically be included if you insert elements or attributes with namespaces.

How do I get the HTTP POST body in MarkLogic XQuery?

I'm trying to use the exist-db request:get-data() method to get the post data of a request. However, I'm getting the error:
XDMP-UNDFUN: (err:XPST0017) Undefined function request:get-data()
I did declare the namespace in my header. I don't understand why I still can't use request:get-data() or any of the other request: functions
declare namespace request="http://exist-db.org/xquery/request";
declare option exist:serialize "method=xml media-type=text/xml indent=yes";
let $post-data := request:get-data()
return $post-data
I think you're looking for xdmp:get-request-body.
Sam pointed you to the function you need, but I wanted to respond to another part of your question:
I did declare the namespace in my header. I don't understand why I still can't use request:get-data() or any of the other request: functions
Each XQuery processing engine implements standard functions, but there is other functionality needed that is not defined by the standard. For MarkLogic, you'll use standard functions with the fn: prefix.
Each XQuery engine then defines additional functions that will be needed. For Exist DB, some of those are in the "http://exist-db.org/xquery/request" namespace, while MarkLogic uses "http://marklogic.com/xdmp" for a lot of its extension functions.
When you're looking for the MarkLogic equivalent of an Exist DB-specific function, search on http://docs.marklogic.com -- start with the function name, and if that doesn't work, search for the terms that describe what you're trying to do.

MSAA COM-based?

I'm wondering if MSAA is COM-based, then one should be able to use CreateObject("Accessibility") to create an instance and call its methods. I had no success doing that. I have "OLEACC.DLL" in SYSTEM32 and it's registered with Windows. But the CreateObject fails.
Any thoughts?
I would like to use functions like AccessibleObjectFromPoint() to get the IAccessible object of the control at the given point.
Has anybody had such an experience?
Any input would be highly appreciated,
Thanks,
Kamil
MSAA is COM based. However, there is no co-creatable class exposed, it exposes only interfaces. That's the reason you can't do CreateObject().
The MSAA-exposed APIs, like AccessibleObjectFromPoint and AccessibleObjectFromWindow are dll-exported C++ methods. You can use them from C++ by linking the proper lib or doing LoadLibrary/GetProcAddress with the function name. From C#, you can get the P/nvoke declaration for these from Pinvoke.net. For example, here's the DllImport for AccessibleObjectFromWindow.

Resources