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)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
(Deleted User) Subject: Xquery to cross reference two files
Author: (Deleted User)
Date: 25 Mar 2009 12:31 PM
Hi Stylussees,


I am searching for a way to cross reference two xml files. My first file contains a list of payment/receipt request which all have a link to a project. My second file contains all projects.

The first file is imported after the second and if a payment/receipt is imported for a project which does not exist the import application returns an error.

What I want to do is cross reference the two xml files to check for projects which do not exist in file 2. So I made below xquery. Which either is not completey correct, cause it runs for hours without any result or my files are just too big - file 1 has 8525 records and file 2 2 has 20.000+ records.

Hope you can help me out,


Cynthia

for $ProjectNumber in doc('file:///e:/Klanten/Conversie/BetalingenOntvangsten/CrossReference/OnlyProjects.xml')/Projects/ProjectNumber return
let $arg1:=$ProjectNumber/text()
for $Project in doc('file:///e:/Klanten/Conversie/Projecten/5maart/AllProjectsOnly.xml')/Projects/Project return
let $arg2:=$Project/text()

return

if ($arg1=$arg2)
then ()
else
<Project>
{$arg1}
</Project>

Postnext
Ivan PedruzziSubject: Xquery to cross reference two files
Author: Ivan Pedruzzi
Date: 25 Mar 2009 06:14 PM

The following assumes that "ProjectNumber" from document 1 and "Project" from document 2 are the keys for testing your criteria


declare variable $OnlyProjects := doc('file:///e:/Klanten/Conversie/BetalingenOntvangsten/CrossReference/OnlyProjects.xml');
declare variable $AllProjectsOnly := doc('file:///e:/Klanten/Conversie/Projecten/5maart/AllProjectsOnly.xml');


for $ProjectNumber in $OnlyProjects/Projects/ProjectNumber
return
if(exists($AllProjectsOnly/Projects/Project[. = $ProjectNumber])) then ()
else concat("Project ", $ProjectNumber, " missing")


Ivan Pedruzzi
Stylus Studio Team

Posttop
(Deleted User) Subject: Xquery to cross reference two files
Author: (Deleted User)
Date: 27 Mar 2009 05:33 AM
Thanks, I am gonna test it right away....

Posted another problem relating to these files in the XSLT board, cause besides valiation I also want to a separate ProjectMembers xml file into my Projects file. Posted under 'Performance xsl:for each and need for xsl:key instruction?'

Learned a lot this week! Thanks,


Cynthia

   
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.