XDMP Function: String to XML - xquery

Is there any method defined in marklogic function library, by which we can convert (or try to convert) a string (xs:string type) to an xml 'document' type? In my problem, I shall normally get an xml sent through request parameters. now I have to parse this xml as a document. So I have to take it as a string and parse it. What is the solution for this case?

I think xdmp:unquote is what you are looking for.

In XQuery 3.0 simply use the standard XPath 3.0 function parse-xml().

xdmp:eval("<ok/>")
or
xdmp:value("<ok/>")
Both of them can be use for your problem.
Regards

Related

Using U-SQL MultiLevelJsonExtractor gives Error: Path returned multiple tokens

I am using the MultiLevelJsonExtractor forked on Git by kotvisbj, When I put a Path that contains an array (body.header.items[*] or body.header.items) into the JsonPaths parameter string, I get a "Error: Path returned multiple tokens". Is there a way to extract the paths in code so I can get an array like when using the Root? I tried to explain this the best way I could, I don't have excellent c# skills, it's been a few years.
I think it would be best to ask the owner of the branch to see if he can advise you. I assume that his code expects a single token only and not an array of tokens.
You can probably achieve what you need by using code similar to this: U-SQL - Extract data from json-array

Change xml hex entity into string while loading into marklogic server

hexadecimal entity are converted into string while loading XML data into marklogic server please suggest the right solution for this. without using XLST charmap
There is now way to to this automatically.
In xquery in order to have hexadecimal show up you need to use the &# then the x like this
"©"
You could write a function that looks at the content that your loading in and finds all the hexadecimal already in there and converts them to this format.

"Canonical Path" Function in XQuery?

Is there an standard XQuery function that will return a 'canonical' path for a node?
I mean something like:
/root/element/sub-element[0]
Since XQuery 3.0 there is fn:path($node), which does exactly that. If it is not supported by your query processor, you can also use FunctX's functx:path-to-node-with-pos($node), which unfortunately does not play well with namespaces.
Yes, in the predicate of a path expression using XQuery you can do something like:
doc("books.xml")/bookstore/book[substring(title,1,5)='Harry']
Hope that helps!

What is the easiest way to parse XML in ActionScript3/Flex?

What is the easiest way to parse XML in ActionScript3/Flex ?
By using e4X syntax.
Here are a few links to documentation that may help you:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2#top
http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e71.html
http://www.ecma-international.org/publications/standards/Ecma-357.htm
We have an XML parser and tutorial here:
http://forea.ch/blog/2010/05/17/utils-parsing-xml/
We also have an XML creator, so you just create the data objects that your application needs and don't have to worry about XML if, for example, you're using XML for configuration data.
If you want to parse a XML to a Object .
you can use FLEXXB .its a wonderful lib.

How to avoid type conversion in flex from string to number?

I am returning 12345678910111213171819 from java to flex, with in xml tags using http serivce. The result format is object.
but when I display the text it automatically converted or treated as number
so it displays like 1.234567891011121317181 x e^21 ....
How to avoid this?
Thanks in advance.
Regards,
Sankara narayanan Ekambaranathan.
Can't you simply coerce it with String()?
var returnedObject:String = String(123463457695);
Well the easiest solution is just a little workaround to the issue:
Instead of sending the open data like
12345678910111213171819
Convert the data into Base 64 Encoding While transmitting
MTIzNDU2Nzg5MTAxMTEyMTMxNzE4MTk=
In Flex Convert back the data using the standard Base 64 Decoder provided with flex
to convert it back into String instead of number format during XML parsing ;)
I faced the same problem on one of my projects.
After a lot of googling and investigation I fixed it by changing result format to XML and manually parsing the XML with explicit type conversions.
Another (actually, more correct) way is to define a schema for the response and somehow apply it to the XML decoder but I haven't found an easy way to do it.

Resources