|
From: Geert J. <gee...@da...> - 2013-05-08 21:24:10
|
Yes, your expression looks for element nodes within a string value. That won’t work. You would need to find a way to parse/unquote/unescape the value first. I am not sure mxquery has such a feature yet. A workaround for that could be to use JS to inject the value into the HTML DOM, and thén retrieve that through the b:dom function. Untested though.. Kind regards, Geert *Van:* ousta ousta [mailto:ous...@gm...] *Verzonden:* woensdag 24 april 2013 22:06 *Aan:* Ghislain *CC:* mxq...@li... *Onderwerp:* Re: [Mxquery-xqib] Using XQUERY in Javascript via variables it helps indeed however it seems somewhat difficult to achieve i was wondering if an alternative solution such as this was possible: I have my xml stored in an input hidden field HTML and i want to use a xquery against this xml (so not against a doc() but against a variable that will contain a string xml) is it possible? somehow ive tried to do like this (but it is not working) <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XQIB: Sample page</title> <meta charset="UTF-8"/> <script type="text/javascript" src="mxqueryjs.nocache.js"></script> <script type="application/xquery"> b:alert( let $x as element() := b:dom()//input[@name="Language"] for $y in $x/ArrayOfMediaAssetInfoLite return $y/data(@value) ) </script> </head> <body> <h1>Hello world page.</h1> <input type="hidden" name="Language" value="<?xml version="1.0" encoding="utf-16"?> <ArrayOfMediaAssetInfoLite xmlns:i=" http://www.w3.org/2001/XMLSchema-instance" > <MediaAssetInfoLite> <Title>object13_t</Title> <Uri> http://localhost/Assets/object13_t.jpg</Uri> </MediaAssetInfoLite> <MediaAssetInfoLite> <Title>pc0134a_collectItem</Title> <Uri> http://localhost/Assets/pc0134a_collectItem.png</Uri> </MediaAssetInfoLite> <MediaAssetInfoLite> <Title>pc0134a_display</Title> <Uri> http://localhost/Assets/pc0134a_display.png</Uri> </MediaAssetInfoLite> </ArrayOfMediaAssetInfoLite>" /> </body> </html> On Wed, Apr 24, 2013 at 6:03 PM, Ghislain <g...@28...> wrote: Hi, I think it could work if you write an XQuery function that takes an XQuery code string as well as an XML node as parameters, and you call this function from JS. However, to write it, you will need a library function that evaluates a string containing XQuery code. I am clarifying whether MXQuery has such a function, and if it can take XML input, and will get back to you when I know more. I hope it helps? Thanks for your interest in XQIB and kind regards, Ghislain On Apr 24, 2013, at 12:07 AM, ousta ousta <ous...@gm...> wrote: > I saw the sample using xqib.call to call some xquery code in javascript. > > My need would be somewhat different. I would have: > 1. some XQUERY code contained within a javascript var. > 2. a javascript var that contain an XML that i wanna use the xquery in 1. against. > > This will mean dynamically execute the xquery contain in my js var against the xml contained in another variable and then store the result in a js variable. > > What would be the best way to do this in xqib? > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr_______________________________________________ > Mxquery-xqib mailing list > Mxq...@li... > https://lists.sourceforge.net/lists/listinfo/mxquery-xqib |