jeudi 17 mai 2018

Pattern or Format Match in XQuery MarkLogic

I am looking for given string, it has to be in () format, * should not have space, no two words before '('.

I am searching Mark Logic DB to see if given column value is in [^\s]+\((?!\s)[^()]+(?<!\s)\) format, if not replace it with this format.

I am still stuck at fetching data, could not write query to update

I am searching DB as

    let $query-opts := cts:search(doc(),
      cts:and-query((
        cts:directory-query(("/captis/documentData/"),"1"),  
            cts:element-query( 
                xs:QName("cd:clause"),  (: <clause> element inside extended for checking query id :)
                cts:and-query((
                    cts:element-attribute-value-query( xs:QName("cd:clause"), xs:QName("tag"), "Title" ),  (: only if the <clause> is of type "Title" :)
                    cts:element-attribute-value-query( xs:QName("cd:xmetadata"), xs:QName("tag"), "Author")

                ))
             )
        ))
for $d in $query-opts
return (
     for $x in $d//cd:document/cd:clause/cd:xmetadata[fn:matches(@tag,"Author")]/cd:metadata_string
     where fn:matches($x/string(), "[^\s]+\((?!\s)[^()]+(?<!\s)\)")
       return 
       (   <documents> {
      <documentId> {$d//cd:dms/cd:documentId/string()}</documentId>
     }</documents>
       )
     )

It's throwing up error invalid pattern

Aucun commentaire:

Enregistrer un commentaire