xquery

Replacing xml namespace prefixes in SQL Server with XQuery

I have an xml structure in an existing SQL Server 2005 database table with a particular namespace defined, I need to query out the XML and in the process, change the namespace prefix to become the default namespace. The old xml has the namespace defined on the root node and child nodes and I know how to replace the root easily enough, bu...

XQuery in SQL server doing SUM over zero value

I'm trying to extract monetary sums stored in some poorly formated xml columns (there is no schema defined for the XML column which I guess is part of the problem). I'm getting a conversion error whenever I encounter a node with 0 as its value. Example: select xml.value('sum(/List/value)', 'numeric') sum from (select cast('<List><value...

XSLT and XQuery on invalid html input, pieces of URI look like entities

I'm using Saxon 9 to analyze invalid html sources. Specifically the html has href values like the following: <a href="blah.asp?fn=view&g_varID=1234">some text</a> I'm getting errors: "Error reported by XML parser: The reference to entity "g_varID" must end with the ';' delimiter." The xml parser is reading the "&g_varID" string and...

In xquery, is there any difference between single and double quotes?

In xquery, is there any difference between single and double quotes? ...

Difference between XPATH, XQuery and Xpointer

What is the difference between XPath, Xquery and Xpointer? As far as my knowledge, xquery is extended version of Xpath. I have the basic knowledge of XPath. Is there any feature available in XPAth which is not in XQuery. Yesterday, i heard a new word "Xpointer". I am confused. Which product is used for which purpose. ...

How to set up Schema-aware XQuery

I'm trying to look at using types to select elements that are subtypes, so I have a test document with subtypes of xs:integer and xs:float. How do I tell XQuery to use the types defined in my schema? (It might be relevant that I'm using oXygen and Saxon-SA) Input document: <?xml version="1.0" encoding="UTF-8"?> <root xmlns:xsi="http:...

How to write an xquery containing sequence elements?

I've got a very large xml data set that is structured like the following: <root> <person> <personid>HH3269732</personid> <firstname>John</firstname> <lastname>Smith</lastname> <entertime>01/02/2008 10:15</entertime> <leavetime>01/02/2008 11:45</leavetime> <entertime>03/01/2008 08:00</e...

Using XQuery in SQL 2005 to replace a node's value?

Given the following XML variable, how can I replace "UNKNOWN" in the StateCode node with "FOO" in TSQL for MS SQL 2005? declare @xmldata xml set @xmldata = '<Collection> <Plan> <StateCode>UNKNOWN</StateCode> <Type>Tubular</Type> </Plan> </Collection>' Unlike a similar question that I found, this is si...

Can dom parsers read inside HTML comments, or is Regex the only way

I am creating very simple CMS for my organisation. My strategy is to embed editable content between tags called < editable >. However to hide these from the browser I am commenting them out. So an example of an editable region will look like this. <!-- <editable name="news_item> Today's news is ... </editable> --> With the content "T...

How to check an empty date argument in a XQuery function?

Consider the following code which checks for an empty date: declare xqse function tns:isEmptyDate($dob as xs:date) as xs:boolean { if(empty($dob)) then { } } When executed, why do I get the below error in ALDSP: weblogic.xml.query.exceptions.XQueryDynamicException: {err}XP0021: "": can not cast to {http://www.w3.org/2001/X...

Deleting Multiple Nodes in Single XQuery for SQL Server

I have: a table with an xml type column (list of IDs) an xml type parameter (also list of IDs) What is the best way to remove nodes from the column that match the nodes in the parameter, while leaving any unmatched nodes untouched? e.g. declare @table table ( [column] xml ) insert @table ([column]) values ('<r><i>1</i><i>2</i>...

Example of xquery in html

Hi guys, Can someone give an example of an html page that uses xquery, do you need something else in order to run xquery. I tried to run some xquery code from w3schools but it is not evaluating in the html page. <html> <ul> { for $x in doc("books.xml")/bookstore/book/title order by $x return <li>{$x}</li> } <...

Saxon in ASP.Net website

Hi, I want to use the Saxon-B XQuery class in my ASP.Net website. But my hosting-provider supports only applications in Medium trust level. Does someone know if it's possible to use Saxon-B and IKVM.Net in a medium trust level environment? Or is there a good alternative XQuery engine for a ASP.Net application in a medium trust level e...

Finding node order in XML document in SQL server

How can I find the order of nodes in an XML document? What I have is a document like this: <value code="1"> <value code="11"> <value code="111"/> </value> <value code="12"> <value code="121"> <value code="1211"/> <value code="1212"/> </value> </value> </value> and I'm tr...

Eclipse: Show XQDT output in Eclipse's graphical XML editor?

I'm using the XQDT (XQuery Development Tools) plugin for Eclipse, and I'd like to view query results in Eclipse's graphical XML editor rather than in the console. Does anyone know of a way to redirect output in this way? ...

XQuery: Return value of an element rather the element itself

I have an XML document that contains the following ... <foo>abc</foo> ... If I evaluate return $xml//foo I get back <foo>abc</foo> Is there any way to get just abc instead? ...

Zorba (XQuery) - using print functions

I'm using Eclipse's XQDT with Zorba 0.9.5. I'm trying to call the Zorba internal function zorba:print(...) from within a FLWOR expression, but it gets ignored. Specifically, I'm doing something like the following import module namespace zorba = "http://www.zorba-xquery.com/zorba/internal-functions"; for $l in list let $bar :=...

Preserving HTML tags inside XQuery

I'm using eXist for a project at work, and I've run into a problem that I can't seem to figure out a solution for. I have an xquery script that is updating an existing document that is already in the database. Part of the data that needs to be updated contains HTML, specifically <p> and </p> tags. I cannot get eXist/XQuery to stop esc...

How to return the first result from XQuery

So I have an XQuery that looks something like this: for $i in /*:rootElement where $i/*:field = "test" return $i This query returns a lot of results, but I only really need one. How can I return just the first item in the result sequence? ...

What is XRPC, how do I use it

I am trying to connect to Thomson Reuters Researcher ID service using XRPC. My questions are as follows: 1) What is XRPC? 2) What do I need to do to send the appropriate data ...