xquery

Xpath or xquery and test the order

Hi, Using SoapUI (great tool for WS by the way), I have the following xml result : <code>c</code> <code>b</code> <code>a</code> For this sample above, i would like to test the code value are order asc. Of course, for this sample the test will fail like excepted. Any solution with xquery or xpath (i can use groovy inside the test if ...

Writing more efficient xquery code (avoiding redundant iteration)

Here's a simplified version of a problem I'm working on: I have a bunch of xml data that encodes information about people. Each person is uniquely identified by an 'id' attribute, but they may go by many names. For example, in one document, I might find <person id=1>Paul Mcartney</person> <person id=2>Ringo Starr</person> And in anoth...

xquery function to convert tag elements to attributes

Hello, I need to write a function that takes a sequence of "tag" elements of the form: <tag type="markupType" value="topic"/> <tag type="concept" value="death"/> ... and turns them into attributes of the form data-markupType="topic" data-concept="death" So far I have the following function: declare function local:tagsToAttrs($ta...

How to pass an xpath into an xquery function declaration

Hi all, I use Apache Tomcat's Exist DB as an XML database and am trying to construct a sequence by passing the following xpath, defined in FLWOR's 'let' clause: $xpath := $root/second/third into a locally defined function declaration, like so: declare function local:someFunction($uuid as xs:string?, $xpath as xs:anyAtomicType?) { l...

XQuery: Inserting Nodes

I'm reading in an XML file using XQuery and want to insert several nodes/elements and generate a new XML file. How can I accomplish this? I've tried using the replace() function, but, it looks like all my XML tags are being stripped when I call doc() to load my document. So calling replace() isn't any good if my XML tags are being remo...

XQuery fn:replace not behaving as expected

I have an Excel worksheet in XML format which contains <Cell ss:StyleID="s127"><Data ss:Type="String">Replace Me</Data></Cell> I want to replace @A01-Replace with a different string. I'm using the XQuery's replace function like so: let $excel := doc("document.xml") let $test := "another string" return replace($excel, "Replace Me",...

Xquery get value from attribute

Hi, I have some xml and need to extract values using sql <?xml version="1.0" ?> <fields> <field name="fld_AccomAttic"> <value>0</value> </field> <field name="fld_AccomBathroom"> <value>1</value> </field> </fields> </xml> I need to get column name fld_AccomAttic Value 1 The xml is held in a sql server 2005 db I ...

Is there any open source system for keyword search on XML documents?

I found lot of open source XML databases (TPOX, Timber , DBXML), but they are working on XPath and XQuery, I need a system which is developed for the purpose of "Keyword search on XML documents". ...

Query Tamino server with xql parameter in URL. Exclude nodes with specific child.

I have to query a Tamino database through HTTP. http://example.com/db?DocumentType=publication&amp;year=all gives me a list of all publication in the database, something like: <publication> <title> The first publications title </title> <author> Author, M </author> <LastModification> <year> 2008 </year...

xquery escape a bracket

how do i grab a file accross the network with brackets in the name? i.e. fn:doc("file:////machine/folder/folder2/fi[le]1.xml") fn:encode-for-uri() tries to grab locally escape-uri function is not an option because its been dropped. thanks ...

Please recommend an easy xquery tool.

I'm trying to grab some information from a private XML file used as DB schema, I'm thinking an XQuery command line tool could help. Would you please recommend one? Thanks. BTW, the implementations list is too long for me to pick... ...

XQuery vs XSLT for transfroming data

Which one of them do you use in your applications in order to transform XML data to other data types? WHY? ...

Xpath expression to retrieve oldest/earliest node

I have an XML snippet, so: <STATES> <STATE> <NAME>Alabama</NAME> <ABBREVIATION>AL</ABBREVIATION> <CAPITAL>Montgomery</CAPITAL> <POPULATION>4661900</POPULATION> <AREA>52419</AREA> <DATEOFSTATEHOOD>14 December 1819</DATEOFSTATEHOOD> </STATE> <STATE> <NAME>Alaska</NAME> <ABBREVIATION>AK</ABBREVIATION> ...

How to get node without children in xQuery?

So I have two nodes of elements that I'm essentially trying to join. I want the top level node to stay the same but the child nodes to be replaced by those cross referenced. Given: <stuff> <item foo="foo" boo="1"/> <item foo="bar" boo="2" /> <item foo="baz" boo="3"/> <item foo="blah boo="4""/> </stuff> <list a="1" b="2"> <f...

BaseX get line-breaks return between node-data

Hi! I'm using BaseX as my XML based DB. I make a simple query like xquery for $Book in /Libraray/Literaturelist/Literature/Title return fn:data($Book) I get all titles, just as a String that has got no line breaks. Is there a way to add line-breaks with XQuery after each node found by the query to separate the data? This is not rea...

XQuery that updates if something is true and otherwise returns error

I'm trying to create a xquery expressions that inserts some new nodes only if a condition is true and returns an error if the condition is false. A simplyfied version of my state is: let $a := [...] return if($a/@something != "true") then ( insert node ( element {'Foobar'} { } ) into $a/somenode ) else ( ...

Nested for loop in xquery

Hi, I want to compare the elements on a list using XQuery. For this I'm thiking about using two for loops nested. Something like this: for $i in $node[*[name(.)=$dN][data(.)!=""] and *[name(.)=$hN][data(.)!=""]] return { for $j in $node[*[name(.)=$dN][data(.)!=""] and *[name(.)=$hN][data(.)!=""]] and $j != $i ...

What is the syntax error in this xquery script?

Hello, I'm a beginner to XQuery, trying to do some simple exercises to learn it. But this latest query I'm trying to put together refuses to run, giving me a syntax error. This is my XQuery: <HTML> <HEAD><TITLE>Alphabetical Cities Lists</TITLE></HEAD> <BODY> { for $indcode in (65 to 70) let $indlet := codepoints-to-string($indcod...

Determine the frequency of occurrence in XQuery

Hi, does anybody know a way of determining the number of times in which a particular value occurs in a sequence, with XQuery. Thanks in advance ...

Xquery to extract text in html

I am working on extracting text out of html documents and storing in database. I am using webharvest tool for extracting the content. However I kind of stuck at a point. Inside webharvest I use XQuery expression inorder to extract the data. The html document that I am parsing is as follows: <td><a name="hw">HELLOWORLD</a>H...