xquery

Oracle 11GR2 deprecated XPath 1.0 functions

According to this whitepaper: http://www.oracle.com/technetwork/database/features/xmldb/xmlqueryoptimize11gr2-168036.pdf Starting 11gR2, Oracle has deprecated many older proprietary mainly XPath 1.0 based operators in favor of standards based XQuery syntax, as listed in Table 1 below. OLD ORACLE PROPRIETARY SYNTAX --> NEW XQUERY SQL/X...

Query XML Type Column in SQL Server 2008

Hi I have created a table that has a strongly type XML column in SQL2008 database. I'm having trouble understanding the documentation or samples that show how I can do a simple query to select the rows that have a value of true for a particular element. The closest I can get without having errors thrown is: SELECT Person.* FROM [Profi...

how to use if else in xquery assignment

Hi, I am trying to use a if condition to assign a value to a variable in an xquery. I am not sure how to do this. This is what I tried: declare namespace libx='http://libx.org/xml/libx2'; declare namespace atom='http://www.w3.org/2005/Atom'; declare variable $entry_type as xs:string external; let $libx_node := if ($entry_type = 'p...

Using variable to TSQL + XQuery

All, I have the following code: --xml is already declared and populated with an xml document SELECT ent.query('TradeId').value('.','VARCHAR(10)') TradeId FROM @xml.nodes('//table/trade[1]') Col(ent) How can I have the expression //table/trade[1] as a variable so I can increase the [1] in a loop ? For example I wo...

Xquery node values where node starts with same text

How to create xquery to select node values where node name starts with some text. for example document <doc> <cpv1>Value1</cpv1> <cpv2>Value2</cpv2> <cpv3>Value3</cpv3> <zzz>Hello world!</zzz> </doc> It should get Value1,Value2,Value3 ...

XQuery distinct values with where clause problem

Hi I'm very new to XQuery so excuse me if I am somehow missing something. I am trying to extract data where certain sub-nodes of an element are DISTINCT, as well as where a certain sibling node's is equal to some predefined string for $product in fn:distinct-values(document('cpwdoc')/root/package/properties/value[@key="product"]) wher...

XPath/XQuery: Select a root node with its attributes without childs

I have an xml: <Customer id=""> <Name /> <Address /> </Customer> I would like to select ONLY a root node with its attributes without its child nodes: <Customer id=""/ > Is such thing possible with XPath? ...

XQuery wrap result in computed node

Hi I am trying to do some simple pagination in XQuery. I would like my root element of the returned XML to have (as attributes) various properties about the pagination (current page etc). However I can't seem to find a way to add these dynamic attributes to my root element. I've tried playing with the element name {expr} and attribute ...

how to retrieve parent node using xquery?

Hi, I am using xml and xqueries.I usually use an xpath expression relative to a parent node to retrieve its child node. But, I am not sure how to do the opposite meaning if I have a child node, how do I retrieve its parent node. <node id="50> <childnode1 childid="51" /> <childnode2 childid="52" /> </node> If I have the node <chi...

Debugger for XQuery that uses Saxon

Can anyone suggest a debugger for XQuery? I would prefer one that is either online or works within Eclipse, and I prefer something that uses Saxon. So far, all I've found is XQDT (which has little documentation and does not work with Saxon) and a few stand-alone commercial apps. All I want to do is understand why my XQuery isn't selecti...

Using XPath/XQuery to create child nodes in a SQL column

I have a sql table with an xml column named CasingRules, which would contain data such as: <root> <Item> <RegularExpression>^Mc[A-Z,a-z]*</RegularExpression> <Format>ULU</Format> </Item> <Item> <RegularExpression>^Mac[A-Z,a-z]*</RegularExpression> <Format>ULLU</Format> </Item> </root> I'm trying to use MS SQL's...

xquery word wrap

I need to word wrap long string to 100 characters using XQuery. In other words, to change some spaces to newlines so that the non-patological lines will be shorter than 100 characters. Is there an easy way? ...

XQuery in the free version of Saxon

I'd like to know whether someone has any experience with XQuery as it is supported in the free version of Saxon. Can it generally be presumed to be complete and usable? ...

Using TSQL, XQuery results return > 1 IDs which I need to search within a query

I have a column in an SQL Server 2005 DB which contains an XML stored as a string. Within that XML is the following element tree <DriverDetails> <DriverDetail> <ID>2334</ID> <PRN>1</PRN> </DriverDetail> <DriverDetail> <ID>2335</ID> <PRN>2</PRN> </DriverDetail> <DriverDetail> <ID>2336</ID> <PRN>3</PRN> ...

XQuery: Compare one value to multiple values like SQL "in" command

Hello, I need to compare one value to multiple other values (a query resulting in more than one element), therefore, if a value is included in some other values. In SQL there's the "IN" operator for that, but what about XQuery? Thanks for any hint :-) ...

TSQL stored procedure and XQuery?

Hello, I want to write a stored procedure that queries XML files after I have input a certain string pattern to look for. I'm already stuck at the input parameters, consider the following XML-document. <root> <container> <element>A</element> <option>1</option> </container> <container> <element>B</element> ...

Updating variables in XQuery - possible or not?

Hello, I'm a little bit confused concerning variable updates in XQuery: On [1] it says: Variables can't be updated. This means you can't write something like let $x := $x+1. This rule might seem very strange if you're expecting XQuery to behave in the same way as procedural languages such as JavaScript. But XQuery isn't that kind of...

Removing node using xquery

Hi, I am trying to remove a child node from a parent node using xquery. Say, I have an entry shown below in my xml: <entry> <id>36</id> <title>Engineering Village Author Tool</title> <updated>2009-09-30T12:55:42Z</updated> <libx:libapp> <libx:entry xmlns:libx="http://libx.org/xml/libx2" src...

Parse json from Xquery

I am working on the XML proyect and I have a problem when I try to connect a json file in my Xquery. I explain you my problem with more details. I do not know how to read a json file in Xquery, I got a URL(this URL has a json file) in Xquery, and that URL is the next: http://discomap.eea.europa.eu/ArcGIS/rest/services/Admin/EuroBounda...

XQuery statement that groups results

Hi I have an XML structure that I need to query using XQuery. As far as I have been able to find, this may not even be possible, but since I am so new to XQuery I thought I may ask. I need to query the XML below and return something that looks like: <product> <title>Acer Liquid</title> <image>ACER-LIQUID.jpg</image> <networks> <n...