[xquery-talk] query help

Taranmeet Kindra taranmeet.kindra at india.birlasoft.com
Wed Sep 20 18:11:37 PDT 2006




Hello

I want to write a query that would check if job code given in
//BasicInfo/JobGroups/JobGroup/JobCodes/JobCode/text()

Is among one of them specified at
//BasicInfo/Divisions/Division/Locations/Location/Departments/Department
/JobCode

If not then I would like the query to return that job code.

Here a section of XML

			<Divisions>
				<Division DivisionCode="003">
					<Locations>
						<Location Code="MS385">
							<Departments>

<Department DepartmentCode="MBYC">

<JobCode>3694000</JobCode>

<JobCode>0550006</JobCode>

</Department>
							</Departments>
						</Location>
					</Locations>
				</Division>
			</Divisions>
			<JobGroups>
				<JobGroup GroupName="0001">
					<JobCodes>

<JobCode>301888</JobCode>
					</JobCodes>
					<JobAccumulatorCode>
</JobAccumulatorCode>
				</JobGroup>
				<JobGroup GroupName="0002">
					<JobCodes>

<JobCode>301882</JobCode>
					</JobCodes>
					<JobAccumulatorCode>
</JobAccumulatorCode>
				</JobGroup>
				<JobGroup GroupName="0003">
					<JobCodes>

<JobCode>302098</JobCode>
					</JobCodes>
					<JobAccumulatorCode>
</JobAccumulatorCode>
				</JobGroup>
				<JobGroup GroupName="0004">
					<JobCodes>

<JobCode>302044</JobCode>

<JobCode>302045</JobCode>
					</JobCodes>
					<JobAccumulatorCode>
</JobAccumulatorCode>
				</JobGroup>
			</JobGroups>




I tried following few queries none of them give desired results


----------------not working--------------------------------------

let $result
for $Bcode in
//BasicInfo/Divisions/Division/Locations/Location/Departments/Department
/JobCode/text()
for $grp in //BasicInfo/JobGroups/JobGroup
for $code in $grp/JobCodes/JobCode/text(){
if (not(  compare($Bcode,$code)))
$result:= concat($result, $code)
}
return $result


--------------------not working---------------
let $result:= ()
for $Bcode in
//BasicInfo/Divisions/Division/Locations/Location/Departments/Department
/JobCode/text()
for $grp in //BasicInfo/JobGroups/JobGroup
for $code in $grp/JobCodes/JobCode/text()
return if (not(  compare($Bcode,$code)))
		then $code
		else (ok)

--------------------not working---------------------------------------
let $Bcode :=
//BasicInfo/Divisions/Division/Locations/Location/Departments/Department
/JobCode/text()
for $code in //BasicInfo/JobGroups/JobGroup/JobCodes/JobCode/text()
return if (not(contains($Bcode,$code)))
		then $code
		else (ok)



your insight would be very helpful

Thanks
Taran

*********************************************************************************************************************************************************************
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient,any disclosure,copying, use, or distribution of the information included in this message and any attachments is
prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
*********************************************************************************************************************************************************************



More information about the talk mailing list