Hi David, thanks for lending a hand!

I apologize for hiding this fact in my initial inquiry, but I'm using
Request.setNewVariable
<https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/Request.html#setNewVariable(java.lang.String,%20com.marklogic.xcc.types.ValueType,%20java.lang.Object)>("foo",
ValueType.ELEMENT,
"<foo/>") to create the variable. Should I expect this to send a string or
an element()?

If before making the Request I call getVariables and interrogate
getValueType I am told the new variable is indeed "element()". Is this
response trustworthy?

Thanks,
Dave

On Sat, Jul 30, 2016 at 1:47 AM, David Lee <[email protected]> wrote:

> Your still sending a 'string'
>
> Use this instead.
>
>
>
>    String xmlString = "<element><child/></element>"
>
>    InputStream is = new ByteArrayInputStream( xmlString.toBytes("UTF-8"));
>
>    com.marklogic.xcc.types.XdmValue value = ValueFactory.newElement(is);
>
>
>
>
>
>
>
>
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Dave Liepmann
> *Sent:* Friday, July 29, 2016 7:20 AM
> *To:* [email protected]
> *Subject:* [MarkLogic Dev General] External variables as element() type
>
>
>
> Hi MarkLogic folks!
>
>
>
> I'd like to pass an XML element as an external variable to my query using
> MarkLogic XCC/J and have it be recognized as type element() when it arrives
> in XQuery.
>
>
>
> I set my-variable to "<foo/>" (or "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><foo></foo>", no difference) using setNewVariable on
> the Request, with "element()" for the ValueType. Then:
>
>
>
> xquery version \"1.0-ml\";
> declare variable $my-variable as element() external;
> xdmp:type(xdmp:unquote($my-variable))
>
>
>
> This returns "untypedAtomic". Is this expected behavior? I'd like to see
> it come through typed as an element(). Is there a better way, either in
> XQuery or in the Request, to set the type of an external variable?
>
>
>
> Thanks in advance,
>
> Dave Liepmann
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to