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
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Steve CoxSubject: Pulling in dynamic data from PHP for Xquery
Author: Steve Cox
Date: 25 Nov 2005 06:48 AM
Hi,

Just atarted playingw thi Stylus Studio - very impressed. I'm using XML and Xqueries to process old database tables into a new CRM system based on MYSQL. One thing I need it to do in the migration/transformation is to attach a guid record to each row element - effectively the new ID for each record going back into the final table.

Long story, but it's best to do it at this poaint as the IDs will be referecnes in other tables that will be gererated by various xqueries along the way.

The guid generator is a specific bit of PHP coding using the CRM systems included PHP libraries. I can generate the list either using a standard command line call ("c:\php\php.exe -f c:\test\guid.php") or I can generate it via a web page (eg. http;//localhost/guid.php). This latter php web page can either just present the guid code eg.

805021cb-b9df-1ba7-f269-4386f8c3e965

or I can format it to generate XML. eg:

<records>
<guid>805021cb-b9df-1ba7-f269-4386f8c3e965</guid>
</records>

One guid is generated with each call.

Because of the environments and data sources, I can't really tag the old database records with a guid, so they need to be tagged onto each new row for each new table when they are created. Obviously, it makes sense to do this in the xqueries transforming the data but I can't see how to do this.

I've tried setting up the source document in the xqueries mapper but it only ever generates one guid that is used for all records - it looks like the php page is only 'fired' once and the result kept statically. Is there a way to dynamically run the page and join the resultant guid for each row in an XML document?

Any thoughts on how to do this; if I'm approaching the whole thing incorrectly; alternative methods etc?

Thanks,
Steve

Postnext
(Deleted User) Subject: Pulling in dynamic data from PHP for Xquery
Author: (Deleted User)
Date: 28 Nov 2005 09:09 AM
Steve,
This is a large complicated post; please tell me if I understand the question correctly. I think you have set a default input URL in the xquery scenario (http://localhost/guid.php ???). In the xquery, you read from this input URL several times, but it only gets opened and read once, so you only get one guid.

If this is what you are doing, then it is behaving as designed. Stylus opens the default input URL exactly once, and builds some type of DOM (depending on which xquery processor is being used.) Then the xquery processor accesses that DOM as many times as needed.

You might try using the doc function: doc("http://localhost/guid.php"). Depending on which xquery processor you use, it MIGHT open and read the URL each time it us used.

Which processor are you using? Is this something which will always be run from inside Stylus Studio, or do you plan to deploy it and use a separate processor? Knowing the environment will make it easier to suggest an appropriate solution.

Clyde

Postnext
Steve CoxSubject: Pulling in dynamic data from PHP for Xquery
Author: Steve Cox
Date: 28 Nov 2005 09:26 AM
Hi,

Yes - that's pretty much the issue I have - what I'm effectivily after is my own xquery version of the xslt generate-id with my own id specification. As this spec is from a PHP script, the only option I see is to join it against the php page that generates this id.

As for the processor, I'm not sure yet. I was probably going to go for the one built into stylusstudio but can you recommend one that might achieve the above?

Postnext
(Deleted User) Subject: Pulling in dynamic data from PHP for Xquery
Author: (Deleted User)
Date: 28 Nov 2005 10:12 AM
Steve,

If you are planning to use our built-in processor, you could write a simple java extension function to generate the guid.

If, on the other hand, you want to investigate other processors, you have a couple of choices. Open the scenario dialog for your xquery and click on the Processor tab. Select the Saxon processor, and then see if it satisfied your needs. The non-validating version of that processor is available at no charge and would be a fine choice if it does what you need.

If you have other issues relating to optimized database access, you could consider the DDXQ xquery processor. See the video tutorial at:

http://www.stylusstudio.com/videos/ddxqdemo/datadirectxquery.html

Good luck,
Clyde

Postnext
(Deleted User) Subject: Pulling in dynamic data from PHP for Xquery
Author: (Deleted User)
Date: 29 Nov 2005 02:43 PM
Steve,

Let me add something to that last reply.

It seems that the doc(...) function is required to be stable, that is if you execute it 2 times with the same argument, it will always return the same nodeset, that is, you cant get your guid without doing something clever. Some possibilities:
1) each time you call doc, modify the url by adding something unique (the last guid?) as an unused parameter &unused=blah. This has the disadvantage of clogging your memory with an arbitrary number of (small) document trees.
2) If you are using the Stylus Studio builtin processor, it is pretty easy to write a java extension function in which you can do almost anything.
3) If you are using the Saxon processor, there is a function
discard-document(...) which does just what you want. Use it like this:

let $guid := saxon:discard-document(doc('http:...'))/records/guid

Each time you call it that way, it will fetch the http page anew.

Clyde

Posttop
Steve CoxSubject: Pulling in dynamic data from PHP for Xquery
Author: Steve Cox
Date: 01 Dec 2005 04:34 AM
Originally Posted: 01 Dec 2005 04:35 AM
Thanks,

I'll giver those a go

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.