Subject: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.
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
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.
Subject: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
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 ;-)