xquery

Checking absence of attribute with cts:query

杀马特。学长 韩版系。学妹 提交于 2020-01-24 08:50:06
问题 I have an XML fragment where I want to have different queries based in the existence of the id attribute: <author order="1" id="99999999" initials="A." given-names="Able" surname="Baker" fullname="Able Baker"/> I have tried: let $first-query := if ($first) then cts:or-query(( cts:element-attribute-word-match(xs:QName("author"), xs:QName("given-names"), $first || "*", ("collation=http://marklogic.com/collation/codepoint")), cts:element-attribute-word-match(xs:QName("author"), xs:QName(

Replacing strings in various XML files

烂漫一生 提交于 2020-01-20 08:31:52
问题 Given the following xml file with the knowledge that the structure and contents can change: <something> <parent> <child>Bird is the word 1.</child> <child>Curd is the word 2.</child> <child>Nerd is the word 3.</child> </parent> <parent> <child>Bird is the word 4.</child> <child>Word is the word 5.</child> <child>Bird is the word 6.</child> </parent> </something> I would like a way to use xquery (and even xslt) to replace all instances of a supplied string with another. For example, replace

TSQL query for tree view control and remove empty elements from an xml file

寵の児 提交于 2020-01-16 07:31:47
问题 Query for treeview control, sometimes contains empty elements which throws an exception (when there are no attributes in an element) due to data-binding of the control the text values is set to "GrandChildOfFirstRow" I did get rid of them in my query via xquery but is there an alternative way to doing this or a better smarter way to get rid of those empty elements, (I need the left outer join for proper records for this query) or is it possible to combine the xquery code into shorter code:

Long path xquery in SQL Server

纵然是瞬间 提交于 2020-01-16 05:26:06
问题 Below is my code in SSMS. and is working fine. But problem is my @p1='variable1/variable2' , and I am not able to get the result. Thank you. DECLARE @SSRXML xml = '<root> <variable1> <variable2> <variable3> <name>Alvin</name> <country>Singapore</country> </variable3> </variable2> </variable1> </root>' DECLARE @p1 VARCHAR(MAX) = 'variable1'; SELECT @SSRXML.query('//root/*[local-name()=sql:variable("@p1")]' ) 回答1: If you query xml instance with variable path, you may try dynamic sql: DECLARE

eXist-db passing parameters to templates through controller.xql (URL mapping)

岁酱吖の 提交于 2020-01-15 10:00:26
问题 I am working with eXist-db 4.2.1 and Xquery 3.1 using the eXist's default installation of controller.xql and view.xq . I have a document.html to which I pass any incoming url structured with /doc/some-requested-doc-id at the end to produce a dynamically-created page based on some-requested-doc-id . So, the incoming url can be either http://localhost:8080/exist/apps/deheresi/doc/MS609-0001 or http://localhost:8080/exist/apps/deheresi/doc/MS609-0001.xml and they are treated the same... In the

eXist-db passing parameters to templates through controller.xql (URL mapping)

做~自己de王妃 提交于 2020-01-15 10:00:07
问题 I am working with eXist-db 4.2.1 and Xquery 3.1 using the eXist's default installation of controller.xql and view.xq . I have a document.html to which I pass any incoming url structured with /doc/some-requested-doc-id at the end to produce a dynamically-created page based on some-requested-doc-id . So, the incoming url can be either http://localhost:8080/exist/apps/deheresi/doc/MS609-0001 or http://localhost:8080/exist/apps/deheresi/doc/MS609-0001.xml and they are treated the same... In the

SQL XML Import: XQuery [value()]: “)” was expected

£可爱£侵袭症+ 提交于 2020-01-15 03:14:26
问题 I am trying to insert data into a table in SQL from XML data. The XML file was created from Microsoft Excel, which gives it this header: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> I am using this query to parse it

Cannot read contents when XML has 2 wrappers

五迷三道 提交于 2020-01-14 19:19:04
问题 This code works fine when you remove the <data> wrapper, from the XML and the nodes, but when you add it, like below, i get 0 results. -- Declare XML variable DECLARE @data XML; -- Element-centered XML SET @data = N' <data xmlns="test.xsd"> <subdata> <customer> <id>1</id> <name>Allied Industries</name> </customer> <customer> <id>2</id> <name>Trades International</name> </customer> </subdata> </data>'; -- Using the query() method SELECT T.customer.query('id').value('.', 'INT') AS customer_id,

What are the differences between JSONiq and XQuery 3.1?

喜夏-厌秋 提交于 2020-01-14 08:06:29
问题 Both JSONiq and XQuery 3.1 extend XQuery 3.0 with support for JSON. How do they differ? 回答1: Overall motivation XQuery 3.1 was designed with the goal to support additional data structures (maps, arrays) in memory. These structures are mapped to JSON for input and output. XQuery 3.1 has been a W3C recommendation since March 2017. JSONiq was designed with the goal of querying and updating JSON in settings such as document stores. It was also designed by members of the XML Query working group

SQL XQuery command to recursively get descendants of same type

吃可爱长大的小学妹 提交于 2020-01-14 04:26:37
问题 I'm new to XQuery in SQL but I'm understanding the basics of getting nodes and the values of the queries. My issue now is handling a hierarchy of unknown depth. The relationship is Contract -> Project -> Lines ; and looks something like this: <ZEstimateContract xmlns="http://schemas.datacontract.org/2004/07/Zeller.Gp" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1"> <Name xmlns="http://schemas.datacontract.org/2004/07