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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> - Stylus Studio - Registrar en o... (1)
-> + Stylus Studio - Registrar en o... (2)
-> + Can a pipeline send a file by ... (2)
-> + After Updateing WIN10 to WIN11... (12)
-> + Where do I add the custom java... (3)
-> + Where is the Diagram tab? (5)
-> + Applying XSLT to Word DOCX/XML (2)
-> - CSV conversion via ConvertToXM... (1)
-> + Text symbols in SS not same as... (4)
-> + Exposing xquery as webservice ... (6)
-> + Syntax Identifier (2)
-> + Saving a Converted XML as an X... (5)
-> + Output document cannot be pars... (4)
-> - Archiving output from conversi... (1)
-> + EDIFACT guideline from Stylus ... (3)
-> + CSV file putting all the data ... (5)
-> + Can't install Home version 64b... (5)
-> + presale - Can I covers this sc... (5)
-> + Problem with UNB (5)
-> + Splitting EDIFACT files pipeli... (4)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Steve CoxSubject: Pulling in dynamic data from PHP for Xquery
Author: Steve Cox
Date: 25 Nov 2005 06:48 AM

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.


or I can format it to generate XML. eg:


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?


(Deleted User) Subject: Pulling in dynamic data from PHP for Xquery
Author: (Deleted User)
Date: 28 Nov 2005 09:09 AM
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.


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

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?

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

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:


Good luck,

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

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.


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

I'll giver those a go

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!  

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.