|
next
|
 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.
|
next
|
 Subject: 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
|
next
|
 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?
|
|
|
|