XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 27 Dec 2008 08:57 PM

I'm on the evaluation period of Stylus Studio 2008 and I've been trying to determine if it will do what I need to do easier than using Visual Studio, which I already have a license for.

What I'm trying to do is extract information out of a lot of 2 meg size XML files that are generated each day during our call center activity. I want to search each file for specific information and write that to another file if it finds it.

When I read about XQuery, it sounded a lot easier that continuing to work with Visual Studio C# to do the same thing. I'm at about the same point with both programs... I can open a single XML file and find an occurance of what I'm looking for. XQuery actually gives me all the data in the section where the error message is that I'm looking for. This is good. The problem is that it's taken me 3 weeks of researching XPath coding to get this (we were having the worst snow storm in 40 years in the Pacific Northwest during this time, so I wasn't able to spend a lot of time working on it) far.

Looking over some of the messages in the forum, it looks like I'm still going to have to learn a bunch of programming to get what I'm after. And I see mention of something called Saxon to do some of the things I want, which I don't know if that is part of Stylus Studio or if it's another program that I would have to buy to work with Stylus Studio.

The marketing information on the web site makes it sound real easy to extract information from XML files, but so far, I'm not finding it to be all that easy. I've gone through a couple of tutorials and they didn't really give me enough information to get very far. So I'm beginning to think that since I already own Visual Studio, that I'm not going to gain anything by buying a license for Stylus Studio as I'm still going to have to do a bunch of coding to extract the data... which I'm going to have to learn first.

It's possible that I'm missing something in XQuery and trying to do this the hard way. It wouldn't be the first time I've done that. So rather than just delete it after my demo period is up (or sooner since I keep getting frustrated with it), I thought I'd ask to see what sources I'm missing that could help me see that it will make it easier to extract information out of my XML files.

Thanks

Mike

Postnext
Minollo I.Subject: XQuery General Question
Author: Minollo I.
Date: 27 Dec 2008 10:54 PM
XQuery is a programming language; as for any programming language, there is a learning curve. Is it worth it? Based on the problem you are trying to solve, I would say yes; once you have passed the initial learning period, the power and flexibility that XQuery provides you when querying and creating XML is impressive; no comparison with other languages like C#, C++ or VB (or Java) that you may be considering.

Stylus Studio bundles two XQuery engines: DataDirect XQuery (www.xquery.com), which is owned by the same company that develops Stylus Studio (www.datadirect.com); and Saxon (www.saxonica.com), which is an XQuery engine available as open source and as a commercial product. DataDirect XQuery specializes in performance, scalability and RDBMS access; you can find plenty of information on its web site (www.xquery.com) and on its blog (www.xml-connection.com).
Stylus Studio itself is a development environment; you can run both DataDirect XQuery and Saxon from within Stylus Studio, and if you want to run XQuery out of the Stylus Studio context you will need to acquire "runtime" licenses for the XQuery engine.

If you would like some help about how to query your multiple documents and create the required output, feel free to post here some sample data and sample results, and we'll do our best to make things easier for you. If you need an extension to your Stylus Studio evaluation, let us know, and we'll take care of that too.

Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 28 Dec 2008 01:33 AM
Originally Posted: 28 Dec 2008 01:31 AM
Minollo, thanks for the fast reply. There is usually a learning curve in everything, sometimes I have problems getting the traction to make it up the curve. The one problem I've been having is finding a beginning of where to start. I've gone through your tutorials and online help and even the one it says you can learn it in 10 minutes. I think I need more than 10 minutes. :D

I would normally have one of my programmers do this, but they are both busy on more important and bigger projects, and I'm getting tired of waiting, so I've been trying to do it myself.

What I have is a bunch of trace logs that are written to by our call center application until they reach 2 megs in size. Then it is closed and another one is started. During a 24 hour period we can get 30 or more of these files created. What I want to do is run a program that will look at each file and look for a event message and if it occurs to write out about 7 or so elements of the 28 in that section. If it's easier to just pull out the whole 28 elements and their text, that's ok too.

This is one of the sections that my query is pulling out now:

<DropEvent>
<SocketId/>
<SessionId/>
<UserName>User6116</UserName>
* <Station>5707</Station>
<ActiveCRV>2316</ActiveCRV>
<MsgCtrlId>9969801 2008-07-17 12:40:19</MsgCtrlId>
<ANIMatch>N</ANIMatch>
<CustId/>
<CPN>2062743020</CPN>
<GPDirSignOn>N</GPDirSignOn>
<SignOnFlag>Y</SignOnFlag>
* <GPowerCallId>4636100</GPowerCallId>
<ActiveCallId>537</ActiveCallId>
<PartyType>Agent</PartyType>
<EndingNum>5707</EndingNum>
* <AgentId>6210</AgentId>
* <AgentName>Cheryl</AgentName>
* <OrigDateTime>2008-07-17 12:40:02</OrigDateTime>
<CallDuration>1</CallDuration>
<TrackingPhone/>
<TrackingId/>
<TrackingName/>
<TrunkGroup>5</TrunkGroup>
<TrunkNum>6</TrunkNum>
<Source>RedirectedEvent RedirectedEvent</Source>
<CountryCode/>
<CityCode/>
<GPServerDateTime>2008-07-17 12:40:19</GPServerDateTime>
</DropEvent>

The lines with the * in front are the ones I'd like to pull out if that is possible. I looked through some of the XPath coding and didn't see a way to specify just certain elements.

My query that I did to extract the above looks like this:

TraceFile/TraceRec/Message/DropEvent[Source="RedirectedEvent RedirectedEvent"]

I created a project and assigned the Test1.xml file to the query as I didn't even know how to tell the query itself to use a specific file. This has been the frustrating part so far, trying to figure out how to create a simple query that you tell where the .xml file is, which one to read in, what to look for and what to do with the output. That's why I kept going back to C# as I'd been able to do that part already. But you are right, XQuery does look like it would be much easier to create with if I get up the learning curve a bit. I'm sure what I'm trying to do is about as basic as it gets for XQuery too and I'm just trying to make it harder than it needs to be. :D

So if you can get me started, I would appreciate it. And I might need an extension on the trial period, but I still have a few more days available, I think.

Thanks

Mike

Postnext
Minollo I.Subject: XQuery General Question
Author: Minollo I.
Date: 28 Dec 2008 04:24 PM
If you were working with a single file, you could do something like this (assuming my log file is in c:\a):
<myEvents> {
for $event in doc("file:///c:/a/log1.xml")//DropEvent
where $event/Source="RedirectedEvent RedirectedEvent"
return
<event> {
$event/Station,
$event/GPowerCallId,
$event/AgentId,
$event/AgentName,
$event/OrigDateTime
} </event>
} </myEvents>

Working with a collection of log files, you can do something like this (assuming the log files are in c:\a and named log*.xml):
<myEvents> {
for $event in collection("file:///c:/a?select=log*.xml")//DropEvent
where $event/Source="RedirectedEvent RedirectedEvent"
return
<event> {
$event/Station,
$event/GPowerCallId,
$event/AgentId,
$event/AgentName,
$event/OrigDateTime
} </event>
} </myEvents>

Helps?

Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 28 Dec 2008 06:09 PM
It helps right off the bat as it shows me how to even find the file I want to open. I tried putting a line with DOC using DOC(file:///C:/text.xml) and several other different ways and kept getting an error message.

I'll give this a try and let you know. Thanks.

Mike

Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 28 Dec 2008 06:34 PM
Well, I found out another thing I was not considering... it seems that at least file names are case sensitive. Most of the programming I've done over the last 5 years or so has been in SQL queries and it doesn't care about case, so I'm use to just doing everything in mostly lowercase. My file names are both upper and lower case and because I didn't have my filename* at the correct case, it didn't work at first. I thought it didn't like spaces in the path names at first, but that wasn't the problem at all.

It looks good so far. And the example you gave makes sense and provides some of the information I was looking for to get started.

I have another question. Is the syntax that you used the XQuery language that is in the book XPath 2.0 Programmers Reference by Dr. Michael Kay that is on your website?

Thanks

Mike

Postnext
Minollo I.Subject: XQuery General Question
Author: Minollo I.
Date: 28 Dec 2008 08:11 PM
Originally Posted: 28 Dec 2008 08:10 PM
The example I've included is an XQuery example, consistent with the XQuery 1.0 language specified by the W3C (http://www.w3.org/XML/Query/); both DataDirect XQuery and Saxon will run it.

XPath 2.0 is the expression language used by XQuery (and XSLT 2.0); you can think of XQuery as a super-set of XPath 2.0. See http://www.xml-connection.com/2007/09/xquery-book-recommendation.html for additional recommendations in terms of XQuery publications; you may also find more useful examples in the blog.

Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 28 Dec 2008 08:48 PM

I'll go browse though that information, thanks.

I have another question about Stylus Studio and usage. If I have a licensed copy of Stylus Studio and create different queries for people to run against our various xml files, does each person need to have Stylus Studio installed and a license? In other words, if they are just going to be running the query but not developing, does everyone have to have a copy of Stylus Studio? Or is there a run time version?

Thanks for all the help, Minollo. With your help, it looks like I'm going to have enough to show why this is a good program to buy. :D

Mike

Postnext
Minollo I.Subject: XQuery General Question
Author: Minollo I.
Date: 29 Dec 2008 06:05 PM
The recommended "runtime license" is DataDirect XQuery (http://www.xquery.com), which can be executed through a command line, integrated in a Java application or even accessed as a Web service hosted by your preferred app server.

Postnext
Mike JordanSubject: XQuery General Question
Author: Mike Jordan
Date: 04 Jan 2009 10:47 AM
Hi Minollo, I just wanted to follow up and let you know I am going to purchase a copy. My company vendor, Insight, has been trying to get updated pricing and part numbers but it seems your sales person was not available last week. I still haven't decided which version to go with, Professional or Enterprise yet, as I'm not sure if I will ever get to the point that the extra features of Enterprise will be useful.

I also checked on DataDirect XQuery. There was no pricing on their web site (that I could find) to indicate it's price and my sales rep at Insight is trying to find that out as well.

I still have lots of questions, but you have shown me enough to know that I can do what I want with this program... once I get past the learning curve.

Thanks for your help and I know I'll be back with more questions.

Mike

Posttop
Minollo I.Subject: XQuery General Question
Author: Minollo I.
Date: 04 Jan 2009 11:00 AM
Sorry for the trouble in talking to our sales reps. I'm sure tomorrow someone will get in touch with your vendor.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.