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
Tom RedfernSubject: XQuery automated comparison of node values
Author: Tom Redfern
Date: 27 Jun 2007 03:35 AM
Originally Posted: 27 Jun 2007 03:26 AM
Hello - I'm not strictly a stylus studio developer, but I am struggling with an xquery and I thought the good folks here may be kind enough to help me.

I have a diffgram:


<?xml version="1.0" standalone="yes"?>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

<NewDataSet>

<PolicyInwards diffgr:id="PolicyInwards1" msdata:rowOrder="0"
diffgr:hasChanges="modified">
<PolicyID>POL0001</PolicyID>
<InsuredName>Insured Co 111</InsuredName>
<InceptDate>2007-01-01T00:00:00+00:00</InceptDate>
<BrokerCode>BKR1</BrokerCode>
<UW>U1</UW>
<LimitCCY>GBP</LimitCCY>
<LimitAmt>1000001.00</LimitAmt>
<SharePctg>0.10</SharePctg>
<Status>L</Status>
</PolicyInwards>

<PolicyInwards diffgr:id="PolicyInwards2" msdata:rowOrder="1"
diffgr:hasChanges="modified">
<PolicyID>POL00010</PolicyID>
<InsuredName>Insured Co 10</InsuredName>
<InceptDate>2007-01-15T00:00:00+00:00</InceptDate>
<BrokerCode>BKR10</BrokerCode>
<UW>U10</UW>
<LimitCCY>USD</LimitCCY>
<LimitAmt>1000010.00</LimitAmt>
<SharePctg>1.00</SharePctg>
<Status>L</Status>
</PolicyInwards>

<PolicyInwards diffgr:id="PolicyInwards4" msdata:rowOrder="3"
diffgr:hasChanges="inserted">
<PolicyID>POL100040</PolicyID>
<InsuredName>Insured Co 100040</InsuredName>
<InceptDate>2281-05-19T14:44:29.63+01:00</InceptDate>
<BrokerCode>BKR 100040</BrokerCode>
<UW>UW 100040</UW>
<LimitCCY>GBP</LimitCCY>
<LimitAmt>1100040.00</LimitAmt>
<SharePctg>11.00</SharePctg>
<Status>L</Status>
</PolicyInwards>

</NewDataSet>

<diffgr:before>

<PolicyInwards diffgr:id="PolicyInwards1" msdata:rowOrder="0">
<PolicyID>POL0001</PolicyID>
<InsuredName>Insured Co 1</InsuredName>
<InceptDate>2007-01-01T00:00:00+00:00</InceptDate>
<BrokerCode>BKR1</BrokerCode>
<UW>U1</UW>
<LimitCCY>GBP</LimitCCY>
<LimitAmt>1000001.00</LimitAmt>
<SharePctg>0.10</SharePctg>
<Status>L</Status>
</PolicyInwards>

<PolicyInwards diffgr:id="PolicyInwards2" msdata:rowOrder="1">
<PolicyID>POL00010</PolicyID>
<InsuredName>Insured Co 10</InsuredName>
<InceptDate>2007-01-02T00:00:00+00:00</InceptDate>
<BrokerCode>BKR10</BrokerCode>
<UW>U10</UW>
<LimitCCY>USD</LimitCCY>
<LimitAmt>1000010.00</LimitAmt>
<SharePctg>1.00</SharePctg>
<Status>L</Status>
</PolicyInwards>

<PolicyInwards diffgr:id="PolicyInwards3" msdata:rowOrder="2">
<PolicyID>POL00019</PolicyID>
<InsuredName>Insured Co 19</InsuredName>
<InceptDate>2007-01-19T00:00:00+00:00</InceptDate>
<BrokerCode>BKR19</BrokerCode>
<UW>U19</UW>
<LimitCCY>EUR</LimitCCY>
<LimitAmt>1000019.00</LimitAmt>
<SharePctg>1.90</SharePctg>
<Status>L</Status>
</PolicyInwards>

</diffgr:before>

</diffgr:diffgram>


and I am trying to select all the child node names out of each <PolicyInwards> node. Ideally I want to programatically compare the values entered in the child nodes across different <PolicyInwards> nodes, without having to hard code the node names themselves.

Eg I want to compare the values in elements <InsuredName>, <InceptDate>, etc under /diffgr:diffgram/NewDataSet/PolicyInwards[diffgr:id='PolicyInwards2'] with the same element values under /diffgr:diffgram/Diffgr:before/PolicyInwards[diffgr:id='PolicyInwards2'], extract the element name, and the values of each under NewDataSet and Diffgr:before for each element

The best I have come up with so far is

declare namespace diffgr = "urn:schemas-microsoft-com:xml-diffgram-v1";

<ReconResults>

{

for $PolicyInwardsDifference in /diffgr:diffgram/NewDataSet/PolicyInwards
where $PolicyInwardsDifference/diffgr:id[text() = /diffgr:diffgram/diffgr:before/PolicyInwards/diffgr:id/text()]
return

if( $PolicyInwardsDifference/@diffgr:hasChanges[text() = 'modified'] )
then

<Difference>
<PKValue>
{$PolicyInwardsDifference/PolicyID/text()}
</PKValue>
{
for $Column in $PolicyInwardsDifference/node()
return

<Column>
<ColumnName>{$PolicyInwardsDifference[node() = $Column]}</ColumnName>
<ValueBefore>(need to get this)</ValueSource>
<ValueAfter>(need to get this)</ValueTarget>
</Column>
}

</Difference>

else ()
}


</ReconResults>


I am happy to clarify if someone out there would be so kind as to help me out.

Many thanks
Tom

Postnext
Tom RedfernSubject: XQuery automated comparison of node values
Author: Tom Redfern
Date: 27 Jun 2007 05:39 AM
OK I have made some more progress. My XQuery now looks like this:

<ReconResults>

{
for $PolicyInwardsDifference in /diffgr:diffgram/NewDataSet/PolicyInwards
return

if( $PolicyInwardsDifference/@diffgr:hasChanges[text() = 'modified'] )
then
<Difference>
<PKValue>
{$PolicyInwardsDifference/PolicyID/text()}
</PKValue>
{
for $Column in $PolicyInwardsDifference/*/name()
where $PolicyInwardsDifference/@diffgr:id = /diffgr:diffgram/diffgr:before/PolicyInwards/@diffgr:id
return


<Column>
<ColumnName>{$Column}</ColumnName>
<ValueSource>{$PolicyInwardsDifference/*/node()}</ValueSource>
<ValueTarget>{/diffgr:diffgram/diffgr:before/PolicyInwards[@diffgr:id = $PolicyInwardsDifference/@diffgr:id]/*/node()}</ValueTarget>

</Column>
}
</Difference>
else ()
}
</ReconResults>

and the output I get is this:

<ReconResults>
<Difference>
<PKValue>POL0001</PKValue>
<Column>
<ColumnName>PolicyID</ColumnName>
<ValueSource>POL0001 Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001 Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>InsuredName</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>InceptDate</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>BrokerCode</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>UW</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>LimitCCY</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>LimitAmt</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>SharePctg</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
<Column>
<ColumnName>Status</ColumnName>
<ValueSource>POL0001Insured Co 1112007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueSource>
<ValueTarget>POL0001Insured Co 12007-01-01T00:00:00+00:00BKR1U1 GBP1000001.000.10L</ValueTarget>
</Column>
</Difference>
<Difference>
<PKValue>POL00010</PKValue>
<Column>
<ColumnName>PolicyID</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>InsuredName</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>InceptDate</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>BrokerCode</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>UW</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>LimitCCY</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>LimitAmt</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>SharePctg</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
<Column>
<ColumnName>Status</ColumnName>
<ValueSource>POL00010Insured Co 102007-01-15T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueSource>
<ValueTarget>POL00010Insured Co 102007-01-02T00:00:00+00:00BKR10U10USD1000010.001.00L</ValueTarget>
</Column>
</Difference>
<Missing>
<MissingIn>Source</MissingIn>
<PKValue>POL100040</PKValue>
</Missing>
<Missing>
<MissingIn>Target</MissingIn>
<PKValue>POL00019</PKValue>
</Missing>
</ReconResults>

which is ALMOST what I want but I can't prevent the values in the <ValueSource/> and <ValueTarget/> nodes to stop repeating.

I would massivly appraciate any help at all.

Best
Tom

Posttop
(Deleted User) Subject: XQuery automated comparison of node values
Author: (Deleted User)
Date: 27 Jun 2007 03:30 PM
Hi Tom,
this is a forum for Stylus Studio users; but you are so close to the solution, that by downloading an evaluation copy of Stylus and using the XQuery debugger you will find the error in no time ;-)

Alberto

   
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.