Using XQuery

L

Lynn

Hi ...

I'm trying to get a handle on things XML and found the following code on
Wikipedia:

<html><head/><body>
{
for $act in doc("hamlet.xml")//ACT
let $speakers := distinct-values($act//SPEAKER)
return
<span>
<h1>{ $act/TITLE/text() }</h1>
<ul>
{
for $speaker in $speakers
return <li>{ $speaker }</li>
}
</ul>
</span>
}
</body></html>

I saved this in file "hamlet.htm" along with the referenced file
("hamlet.xml") in the same directory; when I try to open "hamlet.htm" in
either IE6 or Firefox 2 all I get is sort of a truncated version of the
hamlet.htm file ..

What am I not doing right here? It's an HTML file so it would seem IE or FF
are the right tools to use ... do they not support XQuery? Do I need to use
a different kind of tool? Or am I thinking about all of this the wrong way
entirely?

btw, I have no problem opening the hamlet.xml file in either IE or Firefox,
so it appears to be well-formed

Any advice or information ?

TIA
 
J

Joseph Kesselman

It ISN'T an HTML file. It's an XQuery which produces an HTML file. You
need to run it, and the input XML document, through an XQuery processor;
that will generate an HTML file which can then be viewed with a browser.
 
L

Lynn

It ISN'T an HTML file. It's an XQuery which produces an HTML file. You
need to run it, and the input XML document, through an XQuery processor;
that will generate an HTML file which can then be viewed with a browser.


ok ... an XQuery processor like what? are you talking about a client-side
GUI app, a command line tool, a server-side component I need to code against
? something else?

thanks ...
 
P

Pavel Lepin

Lynn said:
ok ... an XQuery processor like what? are you talking
about a client-side GUI app, a command line tool, a
server-side component I need to code against
? something else?

STFW, will you?
 
M

Martin Honnen

Lynn said:
ok ... an XQuery processor like what? are you talking about a client-side
GUI app, a command line tool, a server-side component I need to code against
? something else?

Saxon <http://saxon.sourceforge.net/> supports XQuery 1.0. You can run
it from the command line, you can use it in a server-side Java component
(e.g. servlet) too if you want.
 
L

Lynn

Saxon <http://saxon.sourceforge.net/> supports XQuery 1.0. You can run it
from the command line, you can use it in a server-side Java component
(e.g. servlet) too if you want.

Thanks, Martin ... that might be helpful for getting acquainted at the
command line; I code .NET/C# and the few articles I've seen on the web
seem to refer to namespaces in the Framework which apparently have been
deprecated (Microsoft.Xml.Xquery, for one) ... the current MS docs seem to
only reference XQuery in the SQL Server context, which is not what I'm
looking for ... I can't imagine MS has abandoned XQuery but where they've
buried it I'm not clear on for now

L
 
L

Lynn

STFW, will you?

if you read my original post, you'd know that I *had* S'dTFW and the
information I found was ambiguous and incomplete; if you don't want to
respond to an inquiry, don't ... or, as you would put it: STFU ... it'll
save you time
 
M

Martin Honnen

Lynn said:
Thanks, Martin ... that might be helpful for getting acquainted at the
command line; I code .NET/C# and the few articles I've seen on the web
seem to refer to namespaces in the Framework which apparently have been
deprecated (Microsoft.Xml.Xquery, for one) ... the current MS docs seem to
only reference XQuery in the SQL Server context, which is not what I'm
looking for ... I can't imagine MS has abandoned XQuery but where they've
buried it I'm not clear on for now

Saxon has a .NET API as well.
As for Microsoft supporting XQuery, they have limited support on SQL
Server 2005, will have slightly improved support on SQL Server 2008.
Don't expect XQuery support in the .NET framework as provided by
Microsoft, instead they are pushing the new LINQ and XML to LINQ
extension in the .NET framework 3.5.
 
L

Lynn

Saxon has a .NET API as well.
As for Microsoft supporting XQuery, they have limited support on SQL
Server 2005, will have slightly improved support on SQL Server 2008. Don't
expect XQuery support in the .NET framework as provided by Microsoft,
instead they are pushing the new LINQ and XML to LINQ extension in the
.NET framework 3.5.

thanks ... that's even more helpful! what I'm wondering now is how
"important" XQuery is as a technology; is it widely used? apparently not
in the world of MS developers I gather ... seems like the Saxon .NET API
might be used in the occasional project to support XQuery but I don't know
if that warrants any significant investment of time or money .. or is it all
too new to tell since it only became a W3C Recommendation this year?
 
J

Joseph Kesselman

what I'm wondering now is how
"important" XQuery is as a technology; is it widely used?
> ...
> too new to tell since it only became a W3C Recommendation this year?

Pretty much.

XQuery, like XSLT 2.0 (which is actually part of the same development
effort; the two language specs were literally generated from the same
source files to keep everything in sync), is relatively new and hence
not yet widely supported or in wide use.

Whether it *will* be important really has to be answered with "for
whom?". XQuery doesn't really do all that much which XSLT 2.0 doesn't,
but it looks more like the database query languages some folks are
already used to (rather than being XML syntax). It thus may be easier
for some folks to wrap their heads around. It's also tuned for a
slightly different set of tasks, and is intended to evolve somewhat
differently -- for example, XQuery may grow to include the ability to
write back into the original document, which is not something XSLT will
ever do. (That difference will mean the best approach for optimizing
them also starts to diverge; it breaks the "functional language" model.)

There was definitely demand for XQuery, which is why it was created
alongside XSLT 2.0. Which customers actually wind up using which, only
time will tell.
 
P

P. Lepin

Lynn said:
if you read my original post, you'd know that I *had* S'dTFW and the
information I found was ambiguous and incomplete

O rly? That's mighty interesting, because if you google for 'XQuery
processor', the first hit is, guess what, 'The SAXON XSLT and XQuery
Processor'. IOW, *plonk*.
 
L

Lynn

Thanks for the comments, Joe ... it looks to me like a technology whose day
will likely come because it makes sense for several reasons .. but right now
it looks like it's still off in the margins, largely in the hands of the
cognoscenti ... at least that's what I'm seeing from comments here, Google
Trends, frequency of Wikipedia updates on the topic and general media
coverage ... something emerging; I'm just trying to triage all this stuff
so I can spend my time productively
 
L

Lynn

O rly? That's mighty interesting, because if you google for 'XQuery
processor', the first hit is, guess what, 'The SAXON XSLT and XQuery
Processor'. IOW, *plonk*.


stop being a jerk, Pavel ... Joe mentioned using an XQuery processor; why
would I *not* ask him what HE meant?

if you're not not going to respond civilly to reasonable questions, please,
get me in your killfile NOW and let's be done with this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top