xquery

How to insert a new ELEMENT after a node in XQuery?

亡梦爱人 提交于 2019-12-25 03:29:12
问题 I want to insert a node using below code but if i will rerun the code i don't want my node to be repeated twice if all the elements are having same value- let $doc := fn:doc("abc.xml") (: abc.xml looks like-- <root> <value1>somevalue</value1> <value2>somevalue</value2> <value3>somevalue</value3> <value4>somevalue</value4> <Country>Australia</Country> <value6>somevalue</value6> <value7>somevalue</value7> <value8>somevalue</value8> <value9>somevalue</value9> <value10>somevalue</value10> </root>

Get element with min attribute

走远了吗. 提交于 2019-12-25 03:25:00
问题 With Xquery I want to get the row which has the min sortOrder. In the example below the row with id=3. <table> <row id="1"><attribute identifier="sortOrder">120</attribute><attribute identifier="mainContent">Test 3</attribute></row> <row id="2"><attribute identifier="sortOrder">130</attribute><attribute identifier="mainContent">Test 1</attribute></row> <row id="3"><attribute identifier="sortOrder">10</attribute><attribute identifier="mainContent">Test 2</attribute></row> </table> Anyone got a

BaseX: Slow XQuery

≯℡__Kan透↙ 提交于 2019-12-25 03:24:26
问题 I've got a BaseX XML database with ~20 XML files. These files are different in size and structure. The biggest file has got 524 MB. It consists of a parent ARTICLE tag with 267685 ART subtags. This is my XQuery: "/ARTICLE/ART[PRDNO=12345]" (pretty straightforward; proper namespaces omitted for clarity). PRDNO is a foreign key to the PRODUCT/PRD XML structure, there are multiple (in average ~10) products per article. Everything works as it is supposed to, but this query is quite slow - it

How to return the value that exists in SQL Server XPath?

折月煮酒 提交于 2019-12-25 03:01:40
问题 There is a question somewhere on Stackoverflow, although i cannot find it now, that reminded the poster that .value does not return the value that .exist s. That is because .value is always written as asking for the [1] item, where .exist looks everywhere. Example Given a hypothetical xml document containing two customers: <Customer> <Name>Ian Boyd</Name> <IDInfo> <IDType>1</IDType> </IDInfo> </Customer> <Customer> <Name>Kirsten</Name> <IDInfo> <IDType>3</IDType> <IDOtherDescription>Firearms

How to return the value that exists in SQL Server XPath?

若如初见. 提交于 2019-12-25 03:01:00
问题 There is a question somewhere on Stackoverflow, although i cannot find it now, that reminded the poster that .value does not return the value that .exist s. That is because .value is always written as asking for the [1] item, where .exist looks everywhere. Example Given a hypothetical xml document containing two customers: <Customer> <Name>Ian Boyd</Name> <IDInfo> <IDType>1</IDType> </IDInfo> </Customer> <Customer> <Name>Kirsten</Name> <IDInfo> <IDType>3</IDType> <IDOtherDescription>Firearms

FOR XML multiple control by attribute in tree concept

风流意气都作罢 提交于 2019-12-25 02:38:17
问题 I want to figure out one issue. I already had question about simple ordering issue but I want to order more detail. check below this link : SQL Server : FOR XML sorting control by attribute I made a example case. SQL Query. select ( select '123' AS '@id', ( select ( select 'test' AS '@testid' , '20' AS '@order' FOR XML path ('tree') , TYPE ), ( select 'test2' AS '@testid' , '30' AS '@order' FOR XML path ('tree-order') , TYPE ), ( select 'test' AS '@testid' , '10' AS '@order' FOR XML path (

Convert copy-of output to string and escape XML special characters (like less than (<) and greater than (>) symbols)

∥☆過路亽.° 提交于 2019-12-25 02:26:40
问题 I am trying this in an XQuery (assume that doc('input:instance') does indeed return a valid XML document) which is generated using XSLT let $a:= <xsl:text>"<xsl:copy-of select="doc('input:instance')//A" />"</xsl:text> let $p := <xsl:text>"<xsl:copy-of select="doc('input:instance')//P" />"</xsl:text> let $r := <xsl:text>"<xsl:copy-of select="doc('input:instance')//R" />"</xsl:text> But I get the error: xsl:text must not contain child elements How do I retrieve XML results using the XPath in

Modify XML to Order Mid-level Complextype Elements by Name

孤街浪徒 提交于 2019-12-25 01:05:44
问题 Edit: See This link for follow-up question I have a large FOR XML EXPLICIT query in SQL Server 2008 R2 that creates an xml file, but it is failing to validate against my XSD schema because some of the mid-level elements appear in the wrong order. Here is an example XML file to show what I mean: <Things> <Thing> <Racecars> <Racecar> <Colour>Red</Colour> <Rockets>Y</Rockets> </Racecar> <Racecar> <Colour>Blue</Colour> <Rockets>N</Rockets> </Racecar> </Racecars> </Thing> <Thing> <Numbers> <Number

querying an XML list in sql server using Xquery

瘦欲@ 提交于 2019-12-25 00:08:14
问题 I have a table in SQL server that is used to store submitted form data. The form fields for each submission are dynamic so the collected data is stored as name value pairs in an XML data column called [formdata] as in the example below... This works fine for collecting the required information but I now need to render this data to a flat file or an excel document for processing by human staff members and im wondering what the best way of doing this would be using Xquery so that the data is

search latest document from multiple collection

你说的曾经没有我的故事 提交于 2019-12-24 21:46:15
问题 There are 2 collections /test/123 and test/567 I want to return the latest document of both the collections. let $a := cts:collection-match("/test/*") for $t in $ a let $latest :=( for $doc in fn:collection( $t) order by $doc//timestamp descending return $doc)[1] return fn:concat($latest//id/text(),",",$latest//timestamp/text()) Is there a better to get the latest document from the collections I want the final output of query after searching both the collection to be in descending order for