xquery

XQuery fn:replace not behaving as expected

微笑、不失礼 提交于 2019-12-24 20:12:44
问题 I have an Excel worksheet in XML format which contains <Cell ss:StyleID="s127"><Data ss:Type="String">Replace Me</Data></Cell> I want to replace @A01-Replace with a different string. I'm using the XQuery's replace function like so: let $excel := doc("document.xml") let $test := "another string" return replace($excel, "Replace Me", $test) Before calling replace, the variable $excel is valid XML upon output. However, when I output $excel after I call the replace function, all of the XML tags

how to wrap xquery results in elements?

吃可爱长大的小学妹 提交于 2019-12-24 19:42:59
问题 How do I wrap each result in a <book_result> element? the xquery itself: <new_cat>{ for $x in catalog/book order by $x/title return ($x/title, $x/author) }</new_cat> which runs fine, but the title and author aren't wrapped in a new book: thufir@dur:~/basex/microsoft$ thufir@dur:~/basex/microsoft$ basex -i w3school_data title_author.xq <new_cat> <title>Creepy Crawlies</title> <author>Knorr, Stefan</author> <title>Lover Birds</title> <author>Randall, Cynthia</author> <title>MSXML3: A

how to set xquery context document in java using saxon 9.2he?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 19:23:09
问题 how do I execute a simple this xquery, such as this for $elem in /root/element() return $elem on an xml file using java without using fn:doc? I keep getting XPDY0002: The context item for axis step child::element(xml, xs:anyType) is undefined --the rundown: I need a simple solution to load an xml file, load an xquery and process 回答1: here is the simplest way I found to do it however I was hoping to use XQStaticContext to "bind" the contextDocument to the expression. XQDataSource ds = new

return latest document based on a element in marklogic

血红的双手。 提交于 2019-12-24 12:12:12
问题 There is a collection with 4 documents. I want to retrieve the document with latest timestamp. The below query helps to sort in descending order but I want the latest modified document for $doc in fn:collection("/test") order by $doc//timestamp descending return $doc//id/text(),",",$doc//timestamp/text()) Output 1234, 2018-03-05T11:29:42.722Z 5678,2018-03-05T11:29:42.715Z 8976,2018-02-05T11:28:42.710Z 8976,2018-02-04T11:28:42.716Z 回答1: Your for loop is already generating a sequence, so all

eXist-db - basic Lucene query returns empty sequence

烈酒焚心 提交于 2019-12-24 11:57:51
问题 In eXist-db 4.4 I am attempting to implement a basic Lucene query structure, but it is returning no results. In /db/apps/deheresi/data I have a collection of tei-xml documents which have the same structure, and I want to apply my query only to the text content found within the element tei:seg and its descendants. A typical sample would be: <TEI> <text> [...] <seg type="dep_event" subtype="event" xml:id="MS609-0001-1"> <pb n="1r"/> <lb break="n" n="1"/> <date type="deposition_date" when="1245

Read XML data into hierarchical tables

橙三吉。 提交于 2019-12-24 11:07:25
问题 I have XML data that is used to store quiz results. I need to convert this into two tables, one containing the questions, and the other containing the answers, but crucially, have a relation between them. Currently this relation only exists in the XML structure (there are no ID values, etc.). After a day of research and testing out different approaches, I've got as far as extracting the two parts, but cannot figure out how to create the hierarchy: declare @xml xml = N'<quizresult> <question>

What would be the XQuery expression to count the number of seconds between two dateTimes?

安稳与你 提交于 2019-12-24 10:47:13
问题 SQL query: SELECT ROUND((CAST(DATEATTRIBUTE2 AS DATE) - CAST(DATEATTRIBUTE1 AS DATE)) * 86400) AS result FROM TEST_TABLE; Both DATEATTRIBUTE1 and DATEATTRIBUTE2 are of TIMESTAMP type. I have tried and come up with the following XQuery : fn:days-from-duration(fn:subtract-dateTimes-yielding-dayTimeDuration( $P_REQUEST/ns1:DATEATTRIBUTE2,$P_REQUEST/ns1:DATEATTRIBUTE1))*86400 But this fails for cases when the dates are same but there is difference in time.E.g. When DATEATTRIBUTE1 is 2017-02-23T01

eXist-DB / XQuery - XSL transform unable to set up transformer: no protocol

你离开我真会死。 提交于 2019-12-24 10:22:42
问题 Environment: eXist-db 4.2.1 , XQuery 3.1, XSLT 2.0 I am firing off a transformation of an XML document in eXist-DB - XQuery which produces the following error: exerr:ERROR Unable to set up transformer: no protocol: /db/apps/deheresi/styles/ms609__testxsl-withmodes.xsl [at line 265, column 26] I haven't been able to locate this error in online documentation or searches. It's triggered by this XQuery: declare function document:doc-xsl-docview($node as node(), $model as map(*), $currentdoc as xs

eXist DB and Xquery : xincludes or collections (TEI-XML)?

一曲冷凌霜 提交于 2019-12-24 10:08:05
问题 I have a corpus in TEI-XML which uses a 'master' corpus XML document that then contains, via xi:include , thousands of other documents. Each of these documents themselves contain xi:include s to master lists of named entities (people, places, etc linked by xml:id s) . All of this works very well in XSLT (and in my IDE Oxygen for fast encoding). I am now embarking on building a website using eXist-DB applications. I am rewriting everything directly in Xquery (to replace XSLT), and I have hit

XQuery - output series of HTML elements with separator

南楼画角 提交于 2019-12-24 05:57:30
问题 In XQuery 3.1 I am constructing an HTML table. In one <td> element I'm outputting a series of <a ref=""> . So, currently this simple for : <td> { for $b in collection($globalvar:URIdata)/tei:TEI/tei:text//tei:seg[@type="dep_event" and @corresp = $a/data(@corresp) and @xml:id != $a/data(@xml:id)] order by $b/data(@xml:id) return <a href="{concat($globalvar:URLdoc,$b/ancestor::tei:TEI/tei:text/@xml:id)}">{$b/data(@xml:id)}</a> } </td> Outputs this: <td> <a href="http://localhost:8081/exist/apps