Jump to content

first xquery (file??)


gawain

Recommended Posts

The XQuery tutorial on W3Schools is very outdated, as it was written before XQuery was a reccomendation, and thus, before there were any decent implementations.I'd suggest you try the XQuery primer from StylusStudio and use the tools mentioned there (Stylus Studio of course, and SAXON).You can also have ordinary XQuery files and run them on SAXON, but it's all much easier in Stylus Studio.

Link to comment
Share on other sites

Thanks for the tipsThe following

The XQuery tutorial on W3Schools is very outdated, as it was written before XQuery was a reccomendation, and thus, before there were any decent implementations.
makes me think that xquery is not much used and so I'm asking if it's worthwhile learning it. (In so far Ive gone thorough xml, xpath and xsl tutorials)Thanks and merry xsmas :)
Link to comment
Share on other sites

Thanks for the tipsThe following

The XQuery tutorial on W3Schools is very outdated, as it was written before XQuery was a reccomendation, and thus, before there were any decent implementations.
makes me think that xquery is not much used and so I'm asking if it's worthwhile learning it. (In so far Ive gone thorough xml, xpath and xsl tutorials)Thanks and merry xsmas :)
Link to comment
Share on other sites

Well, it's not used that much yet, simply because it's too new (it became a reccomendation January this year) and there are not that many implementations yet. But XQuery has a very bright future, and has had it long before it became a reccomendation. RDBMSes (read: SQL database engines) or at least some of them have plans to integrate XQuery as part of their SQL syntax to allow users to extract XML data out from XMLs stored in the database. Thus, you'll be able to not only select a roll and cell from a database table, but also a node from the XML stored in that cell.XQuery is also considered by some as a competitor to XSLT in XML transformations. Why for me personally, XSLT is still better in this regard, that's not the case for people that don't understand XML that much.Also, XSLT's true power comes from its ability to do functional programming. That is, the ability to process a node regardless of its location in the source, and output it within another node that is also with an unknown location. "Unknown" as in "dependant on the source". Sounds confusing? It sure is before you actually need this sort of power. Programmers often undestand procedural programming easier which is also why all XSLT tutorials begin with XSLT's procedural constructs (for-each, if, choose, call-template) and leave the functional ones (apply-templates, mode, priority, match) for later.XQuery on the other hand is completely procedural, at least from what I've read. Its only power comes from the ability to select any set of nodes by a single expression, and thus apply an action on all of them, but putting them in a way that depends on the source is not that easy as with XSLT, if at all possible. XQuery's true power and field of use is, in my point of view as an XSLT fan is, as its name implies - querying.Happy learning, querying and transforming, and merry xmas to you too :) .

Link to comment
Share on other sites

Thanks a lot for your reply, really encouraging. :) If I can ask one more question: I have a lot of files whose structure may be the the following one (well, I'm not sure to resort to docbook or TEI)<speech><placeofspeech></placeofspeech><timeofspeech></timeofspeech><authorofspeech></authorofspeech><paragraph> text text </paragraph><paragraph> text text </paragraph><paragraph> text text text text text text </paragraph></speech>And I need to search for single words (text ) or near words (text text text ) and have together with them the author of the speech and the time of the speech as well. That's why I'm trying to learn xslt and xquery.Btw: do they support a regex search?Thanks a lot

Link to comment
Share on other sites

do they support a regex search?
XQuery 1.0 and XSLT 2.0 - yes.XSLT 1.0 - no.Like XQuery 1.0 though, XSLT 2.0 is not that supported yet. It became a reccomendation the day XQuery 1.0 did.There are only two XSLT 2.0 processors today as far as I'm aware - SAXON and AltovaXML. They can both be used in JAVA or .NET applications, or from the command line. AltovaXML can also be used from COM, making it suitable for languages like PHP, but still not that good.There's no open source XSLT 2.0 processor written in C, and thus there's no fast and reliable implementation for PHP. From my signature you can see an attempt of mine to encompass what's already doable in some way for PHP, and make it available with a nice API, currently in use by PHP for XSLT 1.0.How exactly do you indend to use XSLT 2.0 or XQuery? What's your environment like?
Link to comment
Share on other sites

Thanks for replying and sorry for my being late, I couldn't connect to the site

How exactly do you indend to use XSLT 2.0 or XQuery? What's your environment like?
What I mainly intend to do with XSLT 2.0/Xquery is text searching, in a way that I can use regular expressions. I don't have particular needs, just only the possibility to search words that are near, separated bewtwen them by few other words; the output of the searched text should be all the paragraph in which that text has been found, the author of the text and the date. (I hope I'm making myself clear). The output should be like something this:«text text text text text text text text text text » (Author - date). But I stress: the text in output is a paragraph which has to be extracted from many others.What do you mean with environment ? If I understand well: I work mainly in Linux and I can use a bit of PHP. I've got java installed in windowsI don't understand COM. :) Bye
Link to comment
Share on other sites

Thanks for replying and sorry for my being late, I couldn't connect to the siteWhat I mainly intend to do with XSLT 2.0/Xquery is text searching, in a way that I can use regular expressions. I don't have particular needs, just only the possibility to search words that are near, separated bewtwen them by few other words; the output of the searched text should be all the paragraph in which that text has been found, the author of the text and the date. (I hope I'm making myself clear). The output should be like something this:«text text text text text text text text text text » (Author - date). But I stress: the text in output is a paragraph which has to be extracted from many others.What do you mean with environment ? If I understand well: I work mainly in Linux and I can use a bit of PHP. I've got java installed in windowsI don't understand COM. :) Bye
By "environment" I refer to an OS (1), a programming language to use (2), and a medium of the finished application (3).In your case, your environment consists of a web application (3) (it could have also been a desktop application), written in PHP (2) (it could have been written in ASP.NET, ColdFusion, etc., or in the case of desktop applications - C, C#, JAVA, VB, etc.), running on a Linux web server (1) (it could have been on Windows).I'm sorry to say you're using the most common environment web hosting companies provide, and despite that, the least supported one.The only XSLT2.0/XQuery1.0 processor that runs on Linux and has any chance to work with PHP is SAXON running on JAVA. You could run SAXON from the command line, or with the PHP/JAVA Bridge extension, or as a web service. See The article in SAXON's wiki for details.

For the record, I added a link to my own wrapper, but I also added the review to it, which as you can see is not that all positive.

Unless you're hosting your own server, you probably won't be allowed to execute programs from the command line. A web service still isn't good if you can't install SAXON somewhere you have rights for that. And as for the PHP/JAVA Bridge, the bridge itself must be installed by the host. The installation, as I say myself in that article, is not that easy to do, mostly due to the lack of a decent documentation about it, and because it assumes JAVA knowledge.[offtopic]COM is what I think was called an "abstract interface for inter language communication" (at least that's how I define it to myself). COM is defined in Wikipedia as "a language-neutral way of implementing objects so they can be used in environments different from the one they were created in".[/offtopic]In the case of AltovaXML, the XSLT processor is written in C, but thanks to its COM interface, it can be used from other languages like C# for example, and everyone else that supports COM. PHP supports COM, so AltovaXML can easily be used from it. However, COM is only supported in Windows, and PHP too has it precompiled only for the windows build.

Link to comment
Share on other sites

Thanx for your quick and very thorough answer.One last questionSo, for the moment I have to give up, I guess? Just keep practising with xslt 1.0, or do you reckon that I can start off with xslt 2.0 somehow?Thanks for your courtesy

Link to comment
Share on other sites

So, for the moment I have to give up, I guess? Just keep practising with xslt 1.0, or do you reckon that I can start off with xslt 2.0 somehow?
You can "play" with XSLT 2.0 by using my wrapper (or by writing your own one of course), but on a live site, I'd suggest you stick with XSLT 1.0 and the PHP XSL extension, especially if performance means anything to you.In the end of the day, it's most important what is the host going to allow you to install. Speak with them. Find out what rights you have and what not, paying up to them or changing the host if something is a must.If you host the site yourself, you'll be sure to have all of those rights of course.
Link to comment
Share on other sites

Thanks

You can "play" with XSLT 2.0 by using my wrapper
of course: I've already read some of the documentation, and I'm going to try it as soon as possible
by writing your own one of course
maybe while dreaming
on a live site ... what is the host going to allow you to install ... If you host the site yourself
what's this? All this matter is for my own personal interest: my hope was that I could do the research on the xml files on my own pc, I didn't think of uploading all the files on a site on the web.Thanks again
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...