xquery

How to re-order JSON in BaseX for conversion to CSV?

岁酱吖の 提交于 2020-03-06 09:43:46
问题 I have JSON data which is just slightly backwards in that the "name" key should be first. The desired output as CSV : people alice,z10,y9,x7,atrib6 sue,home5,cell4 joe,phone3,phone2,phone1 It only matters that the "name" for the CSV is first, the rest of the order is arbitrary and meaningless. Through the BaseX GUI I can export this data as: ,z10,y9,x7,atrib6,alice home5,cell4,sue phone3,phone2,phone1,joe people by selecting CSV , although that leading comma looks odd. However, this is very

将分隔列表存储在数据库列中真的不好吗?

∥☆過路亽.° 提交于 2020-03-03 11:23:28
想象一个带有一组复选框的Web表单(可以选择任何一个或全部)。 我选择将它们保存在数据库表的一列中以逗号分隔的值列表中。 现在,我知道正确的解决方案是创建第二个表并正确规范化数据库。 实施简单的解决方案的速度更快,我想快速对该应用程序进行概念验证,而不必花费太多时间。 我认为节省时间和简化代码在我的情况下是值得的,这是一个合理的设计选择,还是我应该从一开始就对其进行标准化? 在更多情况下,这是一个小型内部应用程序,实际上替代了存储在共享文件夹中的Excel文件。 我也在问,因为我正在考虑清理程序并使其更易于维护。 我有些不满意,有些是这个问题的主题。 #1楼 我需要一个多值列,它可以实现为xml字段 可以根据需要将其转换为以逗号分隔的逗号 使用Xquery在sql服务器中查询XML列表 。 通过成为xml字段,可以解决一些问题。 使用CSV: 无法确保每个值都是正确的数据类型:无法阻止1,2,3,banana,5 使用XML: 可以将标记中的值强制为正确的类型 使用CSV: 无法使用外键约束将值链接到查找表; 无法强制执行参照完整性。 使用XML: 仍然是一个问题 使用CSV: 无法强制唯一性:无法阻止1,2,3,3,3,5 使用XML: 仍然是一个问题 使用CSV: 无法在不获取整个列表的情况下从列表中删除值。 使用XML: 可以删除单个项目 使用CSV:

How to use tumbling window to group XML elements by content?

梦想与她 提交于 2020-02-29 06:54:39
问题 How do I group based on whether there's a match to [0-9] for digits with a tumbling window ? desired output: ... <record> <name>joe</name> <data>phone1</data> <data>phone2</data> </record> ... current output, not grouped: <xml> <record> <person key="$s" data="name">phone1</person> </record> <record> <person key="$s" data="name">phone2</person> </record> <record> <person key="$s" data="name">phone3sue</person> </record> <record> <person key="$s" data="name">cell4</person> </record> <record>

add an XPath statement to a FLOWR to select “id” nodes from Twitter database

孤人 提交于 2020-02-08 10:17:10
问题 Looking at the "id" field for a twitter database: thufir@dur:~/flwor$ thufir@dur:~/flwor$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information. > > open twitter Database 'twitter' was opened in 218.67 ms. > > xquery //id <id type="number">1224165280068382720</id> <id type="number">60919433</id> <id type="number">1224160851797643264</id> <id type="number">60919433</id> .. <id type="number">14248074</id> Query executed in 268.13 ms. > how would I get the same result from a FLWOR

Oracle XMLQuery is corrupting the namespace

本秂侑毒 提交于 2020-02-04 04:51:51
问题 Oracle version 11.2 Below is a cut down version of an XMLQuery i'm running on an XMLType column. When I run the query, which simply parses and recreates the stored XML, the tsxm namespace ( that is not equal to the default namespace ) gets changed. This query does nothing and could easily be rewritten, but the real (much bigger) query uses this same methodology so this is why i'm posting the question in this format. If I change the tsxm namespace definition to be the same as the default

Oracle XMLQuery is corrupting the namespace

こ雲淡風輕ζ 提交于 2020-02-04 04:51:35
问题 Oracle version 11.2 Below is a cut down version of an XMLQuery i'm running on an XMLType column. When I run the query, which simply parses and recreates the stored XML, the tsxm namespace ( that is not equal to the default namespace ) gets changed. This query does nothing and could easily be rewritten, but the real (much bigger) query uses this same methodology so this is why i'm posting the question in this format. If I change the tsxm namespace definition to be the same as the default

Parse XML file to get all Namespace information

瘦欲@ 提交于 2020-02-01 05:28:26
问题 I want to be able to get all namespace information from a given XML File. So for example, if the input XML File is something like: <ns1:create xmlns:ns1="http://predic8.com/wsdl/material/ArticleService/1/"> <ns1:article xmlns:ns1="xmlns:ns1='http://predic8.com/material/1/"> <ns1:id>1</ns1:id> <description>bar</description> <name>foo</name> <ns1:price> <amount>00.00</amount> <currency>USD</currency> </ns1:price> <ns1:price> <amount>11.11</amount> <currency>AUD</currency> </ns1:price> </ns1

Read XML nodes as rows in SQL Server

扶醉桌前 提交于 2020-01-30 11:21:12
问题 I have the following XML stored in a XML column of a table: <MessageResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <MessageContainer> <DocumentType xmlns="urn:www:bebe:de:b2b:v01">Testdata</DocumentType> <Payload xmlns="urn:www:bebe:de:b2b:v01"> <Testdata xmlns:ns0="un:unece:260:data:ron_data:v1"> <PayloadResponseEvent> <Identification>2970729807</Identification> <StatusType listAgencyIdentifier="6">accepted</StatusType>

How to use XQuery to simulate STRING_AGG() (grouped string concatenation)?

牧云@^-^@ 提交于 2020-01-25 00:17:08
问题 I have XML data which I need to convert to relational form. I use XQuery cause I don't know the number of address nodes. I'd like to get the whole address/adresses separeted by a comma. I guess I need to use LET clause but I'm still receiving an error. Here's my code: declare @xml as xml = '<root> <Row> <proceeding> <signatures>V GU 86/18</signatures> <signatures>V GUp 9/19</signatures> <signatures>V GUp 8/19</signatures> </proceeding> <entity> <info> <cleaned_name>Kate Smith</cleaned_name> <

uniqness insertion in native xml database

五迷三道 提交于 2020-01-24 13:00:08
问题 I am developing a project based on XML. I use the Sedna database to store my collection (which contains XML files, and their XSD schema files). I define the primary/unique keys in those schemes, but till now I can insert duplicate values (via XQuery update insert command) into primary key field. 回答1: To guarantee uniqueness constraint you should create BEFORE INSERT FOR EACH NODE trigger on proper path. In the trigger action the $NEW transitive variable can be used to fetch the new key and