xquery

How to query for rows along with their xml representation?

I need something like select * from tb_listings for xml auto But I need every row to be separate, and not one big xml document. I have tried something like the following: select id, (select * from tb_listings a where a.id=id for xml auto) as xmldata from tb_listings Expected output is like: id xmldata ------------------...

How to get the attribute value with XQuery in MS SQL Server 2008

I have an XML like this: <EXP> <TITLES> <SUBTITLE CL="AXT4" FL="1" NB="Text 1"/> </TITLES> <TITLES> <SUBTITLE CL="BVT6" FL="2" NB="Text 2"/> </TITLES> <TITLES> <SUBTITLE CL="PLO7" FL="3" NB="Text 3"/> </TITLES> </EXP> Using XQuery in SQL Server 2008, How can I select Just the value of the attribute NB in a list...

How to load large XML file (> 100 MB) to an XMLType column in Oracle

Dear All, I try this command to upload a file (standard.xml) into table "book" the file is very large (>100MB). insert into book values(1,'Complete Data', XMLType(bfilename('XMLDIR', 'standard.xml'), nls_charset_id('AL16UTF8'))); The problem is after I execute the query above, the XML file is not inserted 100% to the column. There i...

XML, XML Stylesheets XQuery: book and development environment

I'm completely new to XML Schema, XML Stylesheets and XQuery. To me, XML is just a text file just containing tags and values. I know that much, lol. I just got a homework asking us to design simple XML Schemas, and also applying Stylesheets and XQuery. Could anyone please point me to: "Best" books/resources (based on your experience...

Filter SQL queries on the XML column using XPath/XQuery

I'm having a table with one XML column. I'd like to filter out the rows where a specific attribute in the XML match a string, essentially doing a WHERE or HAVING. The table looks something like this | id | xml | And the XML something similar to <xml> <info name="Foo"> <data .../> </info> <xml> I want to get all ids where ...

XQuery: how to properly append , in for loop

So I have xml data like this: <PhoneNumber>213-512-7457</PhoneNumber> <PhoneNumber>213-512-7465</PhoneNumber> and with this XQuery: <PhoneNumberList> { for $phone in $c//PhoneNumber let $phoneStr := "" return concat($phoneStr, $phone) } </PhoneNumberList> I get: <PhoneNumberList>213-512-7457213-512-7465</PhoneNumberList...

XQuery: weird xsi tag being inserted into my XQuery output

Here is an example of the XQuery output that I get: <clinic> <Name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;Healthy Kids Pediatrics</Name> <Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;510 W 27th St, Los Angeles, CA 90007</Address> <PhoneNumberList>213-555-5845</PhoneNumberList> <Numbe...

Does QExo XQuery string-join work?

When I run string-join, I get a weird output like this: <clinic> <Name>Olive Street Pediatrics</Name> <Address>1500 Olive St, Los Angeles, CA 90015</Address> <PhoneNumberList>'\u04bc','\u04e4'</PhoneNumberList> <NumberOfPatientGroups>4</NumberOfPatientGroups> </clinic> Notice the PhoneNumberList. The output reported by Altova...

How to read an attribute of the XML.

DECLARE @XmlData xml SET @XmlData= '<?xml version="1.0" encoding="utf-8" ?> <ROOT PROCESS_DATE="25-Nov-2009" ROW_COUNT="2" VERIFY_TOTAL="654454.54"> <row rowNumber="1"> <Code1>11111</Code1> <Code2>AAAA </Code2> </row> <row rowNumber="2"> <Code1>2222</Code1> <Code2>BBBB </Code2> </row> </ROOT>' -- Foll...

Xquery: nested ifs

Basically I have several sequences that may be empty, if they are empty then I don't want to output it's parent node. If all of the sequences are empty then I don't want the containing node. Basically I have code similiar to this, which doesn't work: let $a := //a let $b := //b return <root> {if (exists($a) or exists($b)) then ...

Xpath replace function, processing matches

I'm writing a function to "title case" strings e.g. "this is a title" to "This is a Title." The following line doesn't work because the regex group reference is lost (or so I assume). Is there an easy way to uppercase my matching letter in the replace function? replace( $input, '\b[a-z]' , upper-case('$0')) ...

xquery brackets without FLWOR

hi I have a bit lame question, can't find the answer though. what happens if I leave the constructor brackets void? e.g. < p> {data(doc("somedata.xml")//node[0])}< /p> I mean, I know what happens, but what is it considered as when being parsed? is it like ? { for $i in "0" return data(doc("somedata.xml")//node[0]) ...

SQL Server xQuery return NULL instead of empty

So in this example I'm trying to return a NULL instead of an empty nvarchar for element2 and element3. I can't seem to find an answer to this anywhere, or if it's even possible. I know I can check .exists() with a nullif of Case/When, but I'd rather not make that check for the sake of performance. WqlEventQuery query = new WqlEventQue...

XQuery, fn:id and BD eXist

Does "fn:id" function return IDREFS when it is used in a FLOWER xquery with eXists database? I can't get any example... :( TIA ...

XQuery method question, trying to sum values read from xml

I'm pretty new to XQuery and I'm trying to write an example function that I can't get to work. I want to read an xml file, parse out the "time" values, sum them as they're read and return the sum. This is trivial and I'm looking to build more functionality into it but I'd like to get this working first. Also, I know there's a "sum" dir...

How to insert xml into a node in another xml using XQuery?

Hi all, I have two xml variable say @res, @student in a stored proc in SQL server 2005. @res contains <Subject>English</Subject> <Marks>67</Marks> <Subject>Science</Subject> <Marks>75</Marks> @student contains: <Student> <Name>XYZ</Name> <Roll>15</Roll> <Result /> <Attendance>50</Attendance> </Student> I need to in...

T-SQL cut XML into pieces

I have a table create table Profiles (id int, xml_data xml ) that has an xml column and for each row i have the same xml that looks like this : <Profile> <personalInfo> <contactInfo> <firstName>John</firstName> <lastName>Doe</lastName> <address>22 Park Avenue</address> <address2 ...

Why would I choose XSLT or XQuery over the other for html document generation?

I was researching alternatives to using Microsoft's XslCompiledTransform and everything seemed to point towards Saxon primarily and secondly XQSharp. As I started to look at documentation for Saxon I saw that XQuery could do the equivalent of my XSLTs that are no where near as terse as XQuery's markup is. What advantages do XSLTs offer ...

Getting a count of attributes with a given value

I'm trying to construct an xquery that will return the count for the number attributes found that have a value of x. This is part of an SQL query and these counts will fill one of the columns returned (that part I can figure out, it's the actual xquery to get the count I haven't figured out yet.) For example, if I have <element eleme...

Concat a list of elements and scores without using a recursive function in XQuery with Tijah extensions

For a university search engine project, I am using MonetDB with Tijah extensions. I've got a list of nodes, returned from a search string: let $qid := tijah:queryall-id($nexi) let $nodes := tijah:nodes($qid) $nodes now contains a list of elements, e.g.: <book>Design Patterns</book> <book>AntiPatterns</book> I can calculate and ret...