Michael Blakeley | 1 Sep 2011 05:20
Favicon

Re: [MarkLogic Dev General] explicit relevance ordering

I think it's better to order by empty-sequence:

  for $x in cts:search(...)
  order by ()
  return $x

Using the profiler in cq, I can measure a small but consistent difference between this and 'order by
cts:score($x)', with no change in ordering. If you do find you need cts:score, be sure to add 'descending'.

-- Mike

On 31 Aug 2011, at 15:00 , Mike Sokolov wrote:

> I have been assuming that this:
> 
> for $x in cts:search(...)
> return some-expression-involving($x)
> 
> is completely equivalent to this:
> 
> for $x in cts:search(...)
> order by cts:score() descending
> return some-expression-involving($x)
> 
> but is that true?
> 
> -- 
> Michael Sokolov
> Engineering Director
> www.ifactory.com
(Continue reading)

Geert Josten | 1 Sep 2011 08:14
Picon

Re: [MarkLogic Dev General] Inconsistent order returned by order by clause

Hi Jake,

On a side note, you sometimes want to pass result sets around, and process them elsewhere, effectively
forcing you to use braces like you mentioned. That would still mess around your order. If the order is
important enough, you can enforce ordering by adding the nodes in order to a wrapper element, and select
them from there. It won't perform well with large sets, but I thought it might be worth mentioning.

let $articles :=
    ( <article><dateline>2011-08-21</dateline></article>
    , <article><dateline>2011-04-21</dateline></article>
    , <article><dateline>2011-02-21</dateline></article>
    , <article><dateline>2011-10-03</dateline></article>
    , <article><dateline>2011-05-03</dateline></article>
    , <article><dateline>2011-04-22</dateline></article>
    )

return
(
<wrapper>{
for $art in $articles
order by xs:date($art/dateline) descending
return $art
}</wrapper>/*
)/dateline

Kind regards,
Geert

-----Oorspronkelijk bericht-----
Van: general-bounces@...
(Continue reading)

Abhishek53 S | 1 Sep 2011 08:41
Favicon

Re: [MarkLogic Dev General] Issue with element-attribute-value with query


Danny

Thanks for pointing to the right direction...attribute value positions index was missing..Its done. :)

Abhishek Srivastav
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: abhishek53.s-/cgKlWMm3F8@public.gmane.org
Website: http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                       Business Solutions
                       Outsourcing
____________________________________________


From: Danny Sokolsky <Danny.Sokolsky <at> marklogic.com>
To: General MarkLogic Developer Discussion <general-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org>
Date: 08/30/2011 09:49 PM
Subject: Re: [MarkLogic Dev General] Issue with element-attribute-value        with        query
Sent by: general-bounces-ld4jwAGwUXTgXEvjvSGRgI2Be7XsqA8u@public.gmane.orgcom




Try enabling the “word positions” and “element word positions” index options in your database (this will cause a reindex).
 
-Danny
 
From: general-bounces <at> developer.marklogic.com [mailto:general-bounces-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org] On Behalf Of Abhishek53 S
Sent: Tuesday, August 30, 2011 8:17 AM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Issue with element-attribute-value with query
 

Gajanan

Yes it is returning the document from which element-attribute-values are coming..Now if this is the case I need element-attribute-value with "filtered" kind of approach..The default options of element-attribute-value with not provide this. Is there any way to achieve the same by changing the query portion of  element-attribute-query.


Thanks for reply.

Abhishek Srivastav
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: abhishek53.s-/cgKlWMm3F8@public.gmane.org
Website: http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                      Business Solutions
                      Outsourcing
____________________________________________

From: Gajanan Chinchwadkar <Gajanan.Chinchwadkar-efBvD/aTHCF8UrSeD/g0lQ@public.gmane.org>
To: General MarkLogic Developer Discussion <general-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org>
Date: 08/30/2011 08:37 PM
Subject: Re: [MarkLogic Dev General] Issue with element-attribute-value        with        query
Sent by: general-bounces-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org

 





Abhishek,
 
Can you try running the cts:search  as “unfiltered” and see if it throws out something? If it does, then perhaps the results you are seeing are correct.
 
The documentation for cts:element-attribute-values  says: The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
 
Gajanan
 
From: general-bounces-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org [mailto:general-bounces-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org] On Behalf Of Abhishek53 S
Sent: Tuesday, August 30, 2011 7:52 AM
To: General MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Issue with element-attribute-value with query
 

Hi Folks

I am having some issue with getting element-attribute values with some additional query into the query option.

The query below is returning 0 records -- which is fine

cts:search(fn:doc(),
      cts:and-query((
                     cts:element-query(xs:QName("as-project-spec"),
                         cts:and-query((
                              cts:element-attribute-value-query(xs:QName("as-project-spec"),xs:QName("div"),"00000"),
                              cts:element-word-query(xs:QName("content"),"kolkata")
                          ))
                      )
                 ))
)


Where as the query below is simply returning me some values from the value lexicons -- ideally it should not

cts:element-attribute-values(
                 xs:QName("as-project-spec"),
                 xs:QName("div"),
                 (),
                 (),
                 cts:and-query((
                     cts:element-query(xs:QName("as-project-spec"),
                         cts:and-query((
                              cts:element-attribute-value-query(xs:QName("as-project-spec"),xs:QName("div"),"00050"),
                              cts:element-word-query(xs:QName("content"),"kolkata")
                          ))
                      )
                 ))
          )

Though it is mentioned that this will return the values matching the fragments.Ideally as 0 fragments are matching the query ..element-attribute-values should not return any value.

Let me know If I a wrong somewhere.

Thanks & Regards
Abhishek Srivastav
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: abhishek53.s-/cgKlWMm3F8@public.gmane.org
Website: http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                     Business Solutions
                     Outsourcing
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
General mailing list
General-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General-ld4jwAGwUXTgXEvjvSGRgMKenhbt+owO@public.gmane.org
http://developer.marklogic.com/mailman/listinfo/general


<div>
<br>Danny
<br><br>Thanks for pointing to the right direction...attribute
value positions index was missing..Its done. :)
<br><br>
Abhishek Srivastav<br>
Tata Consultancy Services<br>
Cell:- +91-9883389968<br>
Mailto: abhishek53.s@...<br>
Website: <a href="http://www.tcs.com/">http://www.tcs.com</a><br>
____________________________________________<br>
Experience certainty. &nbsp; &nbsp; &nbsp; &nbsp;IT Services<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Business Solutions<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;Outsourcing<br>
____________________________________________
<br><br><br><table width="100%">
<tr valign="top">
<td>From:
</td>
<td>Danny Sokolsky &lt;Danny.Sokolsky <at> marklogic.com&gt;
</td>
</tr>
<tr valign="top">
<td>To:
</td>
<td>General MarkLogic Developer Discussion
&lt;general@...&gt;
</td>
</tr>
<tr valign="top">
<td>Date:
</td>
<td>08/30/2011 09:49 PM
</td>
</tr>
<tr valign="top">
<td>Subject:
</td>
<td>Re: [MarkLogic Dev General] Issue with
element-attribute-value &nbsp; &nbsp; &nbsp; &nbsp;with &nbsp;
&nbsp; &nbsp; &nbsp;query
</td>
</tr>
<tr valign="top">
<td>Sent by:
</td>
<td>general-bounces@...com</td>
</tr>
</table>
<br><br><br><br>Try enabling the &ldquo;word positions&rdquo;
and &ldquo;element word positions&rdquo; index options in your database (this will
cause a reindex).
<br>&nbsp;
<br>-Danny
<br>&nbsp;
<br>From: general-bounces <at> developer.marklogic.com
[<a href="mailto:general-bounces@...">mailto:general-bounces@...</a>]
On Behalf Of Abhishek53 S<br>
Sent: Tuesday, August 30, 2011 8:17 AM<br>
To: General MarkLogic Developer Discussion<br>
Subject: Re: [MarkLogic Dev General] Issue with element-attribute-value
with query
<br>&nbsp;
<br><br>
Gajanan <br><br>
Yes it is returning the document from which element-attribute-values are
coming..Now if this is the case I need element-attribute-value with "filtered"
kind of approach..The default options of element-attribute-value with not
provide this. Is there any way to achieve the same by changing the query
portion of &nbsp;element-attribute-query.
<br><br><br>
Thanks for reply. <br><br>
Abhishek Srivastav<br>
Tata Consultancy Services<br>
Cell:- +91-9883389968<br>
Mailto: abhishek53.s@...<br>
Website: <a href="http://www.tcs.com/">http://www.tcs.com</a><br>
____________________________________________<br>
Experience certainty. &nbsp; &nbsp; &nbsp; &nbsp;IT Services<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; Business Solutions<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; Outsourcing<br>
____________________________________________
<br>
<p>
</p>
<table width="100%">
<tr valign="top">
<td width="9%">From:

</td>
<td width="90%">Gajanan Chinchwadkar &lt;Gajanan.Chinchwadkar@...&gt;

</td>
</tr>
<tr valign="top">
<td>To:

</td>
<td>General MarkLogic Developer Discussion &lt;general@...&gt;

</td>
</tr>
<tr valign="top">
<td>Date:

</td>
<td>08/30/2011 08:37 PM

</td>
</tr>
<tr valign="top">
<td>Subject:

</td>
<td>Re: [MarkLogic Dev General] Issue with element-attribute-value
&nbsp; &nbsp; &nbsp; &nbsp;with &nbsp; &nbsp; &nbsp; &nbsp;query

</td>
</tr>
<tr valign="top">
<td>Sent by:

</td>
<td>general-bounces@...</td>
</tr>
</table>
<br>&nbsp;
<div align="center">
<br>
</div>
<br><br><br><br>
Abhishek, <br>&nbsp;<br>
Can you try running the cts:search &nbsp;as &ldquo;unfiltered&rdquo; and see if it
throws out something? If it does, then perhaps the results you are seeing
are correct. <br>&nbsp;<br>
The documentation for cts:element-attribute-values &nbsp;says: The
values do not need to match the query, but they must occur in fragments
selected by the query. The fragments are not filtered to ensure they match
the query, but instead selected in the same manner as <a href="http://pubs.marklogic.com:9876/5.0doc/docapp.xqy#display.xqy?fname=&amp;category=%23unfiltered">"unfiltered"
cts:search</a>
operations. <br>
 &nbsp;<br>
Gajanan <br>&nbsp;<br>
From: general-bounces@... [<a href="mailto:general-bounces@...">mailto:general-bounces@...</a>]
On Behalf Of Abhishek53 S<br>
Sent: Tuesday, August 30, 2011 7:52 AM<br>
To: General MarkLogic Developer Discussion<br>
Subject: [MarkLogic Dev General] Issue with element-attribute-value
with query <br>
 &nbsp;<br><br>
Hi Folks <br><br>
I am having some issue with getting element-attribute values with some
additional query into the query option.
<br><br>
The query below is returning 0 records -- which is fine
<br><br>
cts:search(fn:doc(), <br>
 &nbsp; &nbsp; &nbsp; cts:and-query((
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;cts:element-query(xs:QName("as-project-spec"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;cts:and-query((
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cts:element-attribute-value-query(xs:QName("as-project-spec"),xs:QName("div"),"00000"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cts:element-word-query(xs:QName("content"),"kolkata")
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; )) <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; ) <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;))
<br>
) <br><br><br>
Where as the query below is simply returning me some values from the value
lexicons -- ideally it should not
<br><br>
cts:element-attribute-values(
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xs:QName("as-project-spec"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xs:QName("div"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cts:and-query((
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;cts:element-query(xs:QName("as-project-spec"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;cts:and-query((
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cts:element-attribute-value-query(xs:QName("as-project-spec"),xs:QName("div"),"00050"),
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cts:element-word-query(xs:QName("content"),"kolkata")
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; )) <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; ) <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;))
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )
<br><br>
Though it is mentioned that this will return the values matching the fragments.Ideally
as 0 fragments are matching the query ..element-attribute-values should
not return any value. <br><br>
Let me know If I a wrong somewhere.
<br><br>
Thanks &amp; Regards<br>
Abhishek Srivastav<br>
Tata Consultancy Services<br>
Cell:- +91-9883389968<br>
Mailto: <a href="mailto:abhishek53.s@...">abhishek53.s@...</a><br>
Website: <a href="http://www.tcs.com/">http://www.tcs.com</a><br>
____________________________________________<br>
Experience certainty. &nbsp; &nbsp; &nbsp; &nbsp;IT Services<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Business Solutions<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;Outsourcing<br>
____________________________________________
<br>
=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain <br>
confidential or privileged information. If you are <br>
not the intended recipient, any dissemination, use, <br>
review, distribution, printing or copying of the <br>
information contained in this e-mail message <br>
and/or attachments to it are strictly prohibited. If <br>
you have received this communication in error, <br>
please notify us by reply e-mail or telephone and <br>
immediately and permanently delete the message <br>
and any attachments. Thank you<br>
_______________________________________________<br>
General mailing list<br>
General@...<br><a href="http://developer.marklogic.com/mailman/listinfo/general">http://developer.marklogic.com/mailman/listinfo/general</a><br>_______________________________________________<br>
General mailing list<br>
General@...<br><a href="http://developer.marklogic.com/mailman/listinfo/general">http://developer.marklogic.com/mailman/listinfo/general</a><br>
<br><br>
</div>
Geert Josten | 1 Sep 2011 08:51
Picon

Re: [MarkLogic Dev General] MarkLogic and xsltforms (xf:submission)

Hi Morgan,

 

You need to keep in mind that xsltforms runs at browser side, so uri to data goes through your MarkLogic HTTP app server first. It means that /test/data.xml will resolve to a file among the modules, and the PUT action won’t update it. You need to put a small xquery in between to make it work. Something like:

 

xquery version "1.0-ml";

 

declare variable $uri := xdmp:get-request-field("uri");

declare variable $body := xdmp:get-request-body('xml');

 

xdmp:set-response-encoding("utf-8"),

xdmp:set-response-content-type("application/xml"),

 

xdmp:log(("data.xqy", xdmp:get-request-method(), $uri, $body)),

 

if (xdmp:get-request-method() = "GET") then

               doc($uri)

else

               xdmp:document-insert($uri, $body)

 

You would also have to change your model to:

 

      <xf:model>
         <xf:instance id="data-instance" src="
data.xqy?uri=/test/data.xml" xmlns="" />
         <xf:submission id="read-from-file" method="get"
             action="
data.xqy?uri=/test/data.xml" replace="instance" instance="data-instance" />
         <xf:submission id="save-to-file" method="put"
             action="
data.xqy?uri=/test/data.xml" replace="instance" instance="data-instance" />
      </xf:model>

You can also look into url rewriting, which will allow you to alter the behavior of your HTTP app server to handle uri ending on .xml as REST calls, e.g. have the url rewrite script add ‘data.xqy?uri=’ in front of such urls..

 

Kind regards,

Geert

 

 

Van: general-bounces <at> developer.marklogic.com [mailto:general-bounces <at> developer.marklogic.com] Namens mcundiff1 <at> comcast.net
Verzonden: woensdag 31 augustus 2011 18:13
Aan: General MarkLogic Developer Discussion
Onderwerp: [MarkLogic Dev General] MarkLogic and xsltforms (xf:submission)

 

I am attempting to use MarkLogic and xsltforms to load data from an xml file (stored in a MarkLogic database) into the form, edit the data in the form, and then save the edited xml file back to the MarkLogic database.

I have created the database and the HTTP server. The form correctly reads the data from the database file ('/test/data.xml') and loads it into the form in the browser.

The part that does not work is saving the edited file back to the MarkLogic database (<xf:submission method="put"/>). Can someone explain to me how to enable the submission? Does it depend on webdav? What are the setup steps?

The xquery is below.

Thanks,
Morgan Cundiff

----------------------------

xquery version "1.0-ml";
declare namespace xdmp="http://marklogic.com/xdmp";

let $page :=
(xdmp:set-response-content-type("application/xml"),
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xf="http://www.w3.org/2002/xforms"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <head>
      <title>Submission with get and put</title>
      <xf:model>
         <xf:instance id="data-instance" src="/test/data.xml" xmlns="" />
         <xf:submission id="read-from-file" method="get"
             action="/test/data.xml" replace="instance" instance="data-instance" />
         <xf:submission id="save-to-file" method="put"
             action="/test/data.xml" replace="instance" instance="data-instance" />
      </xf:model>
   </head>
   <body>
      <p>Demonstration of using XForms to get and put data to ML database using the submission element.</p>
      <xf:input ref="Element1">
         <xf:label>Element 1:</xf:label>
      </xf:input>
      <br />
      <xf:input ref="Element2">
         <xf:label>Element 2:</xf:label>
      </xf:input>
      <br />
      <xf:input ref="Element3">
         <xf:label>Element 3:</xf:label>
         <br />
      </xf:input>
      <xf:submit submission="read-from-file">
         <xf:label>Reload</xf:label>
      </xf:submit>
      <xf:submit submission="save-to-file">
         <xf:label>Save</xf:label>
      </xf:submit>
   </body>
</html>)


let $xslt-pi := processing-instruction xml-stylesheet {'type="text/xsl" href="xsltforms/xsltforms.xsl"'}



return ($xslt-pi, $page)

-------------------------------------

<div><div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi Morgan,<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">You need to keep in mind that xsltforms runs at browser side, so uri to data goes through your MarkLogic HTTP app server first. It means that /test/data.xml will resolve to a file among the modules, and the PUT action won&rsquo;t update it. You need to put a small xquery in between to make it work. Something like:<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">xquery version "1.0-ml";<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">declare variable $uri := xdmp:get-request-field("uri");<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">declare variable $body := xdmp:get-request-body('xml');<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">xdmp:set-response-encoding("utf-8"),<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">xdmp:set-response-content-type("application/xml"),<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">xdmp:log(("data.xqy", xdmp:get-request-method(), $uri, $body)),<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">if (xdmp:get-request-method() = "GET") then<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc($uri)<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">else<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xdmp:document-insert($uri, $body)<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">You would also have to change your model to:<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span class="object"><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:model&gt;</span></span><span lang="EN-US"><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:instance id="data-instance" src="</span></span><span lang="EN-US">data.xqy?uri=</span><span class="object"><span lang="EN-US">/test/data.xml" xmlns="" /&gt;</span></span><span lang="EN-US"><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submission id="read-from-file" method="get"</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action="</span></span><span lang="EN-US">data.xqy?uri=</span><span class="object"><span lang="EN-US">/test/data.xml" replace="instance" instance="data-instance" /&gt;</span></span><span lang="EN-US"><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submission id="save-to-file" method="put"</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action="</span></span><span lang="EN-US">data.xqy?uri=</span><span class="object"><span lang="EN-US">/test/data.xml" replace="instance" instance="data-instance" /&gt;</span></span><span lang="EN-US"><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:model&gt;</span><br><br></span><span lang="EN-US"><p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">You can also look into url rewriting, which will allow you to alter the behavior of your HTTP app server to handle uri ending on .xml as REST calls, e.g. have the url rewrite script add &lsquo;data.xqy?uri=&rsquo; in front of such urls..<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US">Kind regards,<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US">Geert<p></p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN-US"><p>&nbsp;</p></span></p>
<div><div><p class="MsoNormal"><span>Van:</span><span> general-bounces <at> developer.marklogic.com [mailto:general-bounces <at> developer.marklogic.com] Namens mcundiff1 <at> comcast.net<br>Verzonden: woensdag 31 augustus 2011 18:13<br>Aan: General MarkLogic Developer Discussion<br>Onderwerp: [MarkLogic Dev General] MarkLogic and xsltforms (xf:submission)<p></p></span></p></div></div>
<p class="MsoNormal"><p>&nbsp;</p></p>
<div><p class="MsoNormal"><span>I am attempting to use MarkLogic and xsltforms to load data from an xml file (stored in a MarkLogic database) into the form, edit the data in the form, and then save the edited xml file back to the MarkLogic database.<br><br>I have created the database and the HTTP server. The form correctly reads the data from the database file ('/test/data.xml') and loads it into the form in the browser.<br><br>The part that does not work is saving the edited file back to the MarkLogic database (&lt;xf:submission method="put"/&gt;). Can someone explain to me how to enable the submission? Does it depend on webdav? What are the setup steps?<br><br>The xquery is below.<br><br>Thanks,<br>Morgan Cundiff <br><br>----------------------------<br><br><span class="object">xquery version "1.0-ml";</span><br><span class="object">declare namespace xdmp="http://marklogic.com/xdmp";</span><br><br><span class="object">let $page :=</span><br><span class="object">(xdmp:set-response-content-type("application/xml"),</span><br><span class="object">&lt;html</span><br><span class="object">&nbsp; xmlns="http://www.w3.org/1999/xhtml"</span><br><span class="object">&nbsp; xmlns:xf="http://www.w3.org/2002/xforms"</span><br><span class="object">&nbsp; xmlns:xs="http://www.w3.org/2001/XMLSchema"</span><br><span class="object">&nbsp; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;</span><br><span class="object">&nbsp;&nbsp; &lt;head&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;title&gt;Submission with get and put&lt;/title&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:model&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:instance id="data-instance" src="/test/data.xml" xmlns="" /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submission id="read-from-file" method="get"</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action="/test/data.xml" replace="instance" instance="data-instance" /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submission id="save-to-file" method="put"</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action="/test/data.xml" replace="instance" instance="data-instance" /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:model&gt;</span><br><span class="object">&nbsp;&nbsp; &lt;/head&gt;</span><br><span class="object">&nbsp;&nbsp; &lt;body&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Demonstration of using XForms to get and put data to ML database using the submission element.&lt;/p&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:input ref="Element1"&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:label&gt;Element 1:&lt;/xf:label&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:input&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:input ref="Element2"&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:label&gt;Element 2:&lt;/xf:label&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:input&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:input ref="Element3"&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:label&gt;Element 3:&lt;/xf:label&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:input&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submit submission="read-from-file"&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:label&gt;Reload&lt;/xf:label&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:submit&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:submit submission="save-to-file"&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xf:label&gt;Save&lt;/xf:label&gt;</span><br><span class="object">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xf:submit&gt;</span><br><span class="object">&nbsp;&nbsp; &lt;/body&gt;</span><br><span class="object">&lt;/html&gt;)</span><br><br><br><span class="object">let $xslt-pi := processing-instruction xml-stylesheet {'type="text/xsl" href="xsltforms/xsltforms.xsl"'} </span><br><br><br><br><span class="object">return ($xslt-pi, $page)</span><br><br><span class="object">-------------------------------------</span><br><br><p></p></span></p></div>
</div></div>
Florent Georges | 1 Sep 2011 12:10

Re: [MarkLogic Dev General] Inconsistent order returned by order by clause

Michael Blakeley wrote:

  Hi,

> The final XPath step '.../dateline' reorders the results into
> node order, as specified by the W3C.  A sequence of constructed
> nodes has indeterminate node order, so you will see
> unpredictable results.

  More precisely, nodes from different trees have implementation-
dependent, but stable, document order.  So it must be the same
every time you use it.  Off course, an implementation can say it
is stable during a single one evaluation of the query.  Same for
the relative order of the attributes.

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
Gary Larsen | 1 Sep 2011 13:41

Re: [MarkLogic Dev General] determine the first result in an orderby

Once again I am bailed out with everyone's help in this mail list.

Thanks!
gary

-----Original Message-----
From: general-bounces@...
[mailto:general-bounces@...] On Behalf Of Michael
Blakeley
Sent: Wednesday, August 31, 2011 5:34 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] determine the first result in an
orderby

If the $p is ancillary to the results, why not just use one of these?

(
  for  $x at $p in cts:search(doc(), $cq2, 'unfiltered')/content/lookupInfo
  order by string-length($x/searchPathEnc) descending
  return <x><pos>{$p}</pos>{$x/searchPathEnc}</x>
)[1]

Or

subsequence(
  for  $x at $p in cts:search(doc(), $cq2, 'unfiltered')/content/lookupInfo
  order by string-length($x/searchPathEnc) descending
  return <x><pos>{$p}</pos>{$x/searchPathEnc}</x>,
  1, 1)

-- Mike

On 31 Aug 2011, at 13:01 , Gary Larsen wrote:

> I'm also struggling with an order by problem today.  What I need is the
first of the sorted results from this query:
>  
> for  $x at $p in cts:search(doc(), $cq2,
'unfiltered')/content/lookupInfoorder by string-length($x/searchPathEnc)
descending return
> <x><pos>{$p}</pos>{$x/searchPathEnc}</x> 
> 
> <x>
>     <pos>2</pos>
>
<searchPathEnc>%2Fcontent%2Fpackage%5B%40name%3D%27Demo%27%5D</searchPathEnc
>
> </x>
> <x>
>     <pos>1</pos>
>     <searchPathEnc>%2Fcontent</searchPathEnc>
> </x>
> 
> I would expect that the first result would have a position value of 1 but
that's not the case.  Is there a way to determine (or get directly) the
first of the ordered results?
>  
> Sorry if this is just my lack of XQuery knowledge,
> gary
>  
> _______________________________________________
> General mailing list
> General@...
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@...
http://developer.marklogic.com/mailman/listinfo/general

Mike Sokolov | 1 Sep 2011 15:39
Favicon

Re: [MarkLogic Dev General] explicit relevance ordering

Thanks, Mike

On 08/31/2011 11:20 PM, Michael Blakeley wrote:
> I think it's better to order by empty-sequence:
>
>    for $x in cts:search(...)
>    order by ()
>    return $x
>
> Using the profiler in cq, I can measure a small but consistent difference between this and 'order by
cts:score($x)', with no change in ordering. If you do find you need cts:score, be sure to add 'descending'.
>
> -- Mike
>
> On 31 Aug 2011, at 15:00 , Mike Sokolov wrote:
>
>    
>> I have been assuming that this:
>>
>> for $x in cts:search(...)
>> return some-expression-involving($x)
>>
>> is completely equivalent to this:
>>
>> for $x in cts:search(...)
>> order by cts:score() descending
>> return some-expression-involving($x)
>>
>> but is that true?
>>
>> -- 
>> Michael Sokolov
>> Engineering Director
>> www.ifactory.com
>>
>> _______________________________________________
>> General mailing list
>> General@...
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>      
> _______________________________________________
> General mailing list
> General@...
> http://developer.marklogic.com/mailman/listinfo/general
>    
bek | 1 Sep 2011 19:58
Picon

[MarkLogic Dev General] MLS support for whole disk encryption systems

If my data on disk needs to be encrypted (not hashed), does MLS support/thrive/tolerate a product like PGP
Total Disk Encryption?  I don't see any references outside of different comments on hashing data from xdmp functions.

Cheers
bek
Geert Josten | 1 Sep 2011 20:27
Picon

Re: [MarkLogic Dev General] MLS support for whole disk encryption systems

Hi Bek,

Data files themselves should be already encrypted, but it won't make much sense encrypting the data within
the databases itself if it needs to be searchable. There are still some options though. You could encrypt
sensitive character data leaving xml structure intact, and you could add a digital signature so you can
always check whether it has been tampered with. Apart from all this, I'd just secure the host machines themselves..

Kind regards,
Geert

-----Oorspronkelijk bericht-----
Van: general-bounces@...
[mailto:general-bounces@...] Namens bek
Verzonden: donderdag 1 september 2011 19:58
Aan: general@...
Onderwerp: [MarkLogic Dev General] MLS support for whole disk encryption systems

If my data on disk needs to be encrypted (not hashed), does MLS support/thrive/tolerate a product like PGP
Total Disk Encryption?  I don't see any references outside of different comments on hashing data from xdmp functions.

Cheers
bek
_______________________________________________
General mailing list
General@...
http://developer.marklogic.com/mailman/listinfo/general
Neil | 1 Sep 2011 21:07
Picon

[MarkLogic Dev General] Invalid URI Format Error?

Hi,

 

I am getting a strange error when I try to access some document via a particular collection.

 

This works OK, and returns the document I want:

 

  fn:doc("/DOCS/0001012-0000002-0000064-XXXX-YYY-ZZ02_2010-05-17_17-43-14-109-2.6.xml")

 

So the problem is not with the URI of that document.

 

Yet the error I get when I try to access that same document via a collection that it belongs to implied a URI format problem:

 

  [1.0-ml] XDMP-URI: (err:FODC0004) fn:collection((fn:doc("/DOCS/0001012-0000002-0000064-XXXX-YYY-ZZ02_2010-05-17_17-43-14-109-2.6.xml"), fn:doc("..."), fn:doc("..."), ...)) -- Invalid  
URI format: "ALL OF THE TEXT CONTENT OF THE SAME DOCUMENT (the first document being returned) IS SHOWN HERE"

 

This appears to be finding the documents that I want. So what is going on here? Does the collection() function have a problem with the document URIs, even though other functions do not?

 

The collection itself is a URI like this: “BATCH-0001012-0000002-XXXXXXXXXX.xml”. Is there anything wrong with that URI either? Anyway, that works when I do this:

 

    fn:count(   fn:collection("BATCH-0001012-0000002-XXXXXXXXXX.xml" )/ROOT  )

 

I access some of the same documents using a different collection, and I do not get the error in that circumstance.

 

Neil.

 

<div><div class="WordSection1">
<p class="MsoNormal">Hi,<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">I am getting a strange error when I try to access some document via a particular collection.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">This works OK, and returns the document I want:<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">&nbsp; fn:doc("/DOCS/0001012-0000002-0000064-XXXX-YYY-ZZ02_2010-05-17_17-43-14-109-2.6.xml")<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">So the problem is not with the URI of that document.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Yet the error I get when I try to access that same document via a collection that it belongs to implied a URI format problem:<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">&nbsp; [1.0-ml] XDMP-URI: (err:FODC0004) fn:collection((fn:doc("/DOCS/0001012-0000002-0000064-XXXX-YYY-ZZ02_2010-05-17_17-43-14-109-2.6.xml"), fn:doc("..."), fn:doc("..."), ...)) -- Invalid&nbsp;&nbsp; <br>URI format: "ALL OF THE TEXT CONTENT OF THE SAME DOCUMENT (the first document being returned) IS SHOWN HERE"<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">This appears to be finding the documents that I want. So what is going on here? Does the collection() function have a problem with the document URIs, even though other functions do not?<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">The collection itself is a URI like this: &ldquo;BATCH-0001012-0000002-XXXXXXXXXX.xml&rdquo;. Is there anything wrong with that URI either? Anyway, that works when I do this:<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp; fn:count(&nbsp;&nbsp; fn:collection("BATCH-0001012-0000002-XXXXXXXXXX.xml" )/ROOT&nbsp; )<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">I access some of the same documents using a different collection, and I do not get the error in that circumstance.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Neil.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
</div></div>

Gmane