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)
-> + Sample XQuery extension using ... (2)
-> + Another EDI problem (7)
-> + Removing xmls:od and xmls:xsi ... (2)
-> + Configuring MarkLogic with Sty... (10)
-> + EDI to XML (7)
-> + Can't write to SQL-Server (4)
-> + XQuery and SQL-Server (2)
-> + Connection to MS SQL Server in... (2)
-> + copy/modify with Stylus Studio... (5)
-> - copy/modify with Stylus Studio... (1)
-> + [SQLServer JDBC Driver]Value c... (5)
-> + wild card chracter usage in XS... (2)
-> + Xquery with SQL NEWID function (4)
-> + Change Only One Line (5)
-> + Format DB xQuery results (3)
-> + Adding MsSQL Database to XQuer... (3)
-> + Need help with using XQuery in... (2)
-> + please help! simple XML transf... (2)
-> + xquery for invoice data (3)
-> - Xquery to cross reference two ... (3)
-> ->Xquery to cross reference...
-> ->Xquery to cross reference...
-- Previous [121-140] [141-160] [161-180] 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.