Xquery for finding cousins in an xml

walatafa

New Member
I am new to xquery and I am looking for a quick solution to this problem.I have an xml document, and I want to find all pairs of first cousins and all pairs of 2nd cousins in the documents.Please have a look a the the xml below and guide me how to proceed or if you can provide any code snippet that will be highly appricieated.\[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE GEDCOM SYSTEM "file:/Users/indiwarafernando/Downloads/family.dtd"><GEDCOM> <HeaderRec> <FileCreation Date=""></FileCreation> <Submitter> <Link Target="" Ref="FM001"/> </Submitter> </HeaderRec> <FamilyRec Id="FM001"> <HusbFath> <Link Target="IndividualRec" Ref="IN001"/> </HusbFath> <WifeMoth> <Link Target="IndividualRec" Ref="IN002"/> </WifeMoth> <Child> <Link Target="IndividualRec" Ref="IN004"/> </Child> <Child> <Link Target="IndividualRec" Ref="IN007"/> </Child> </FamilyRec> <FamilyRec Id="FM002"> <HusbFath> <Link Target="IndividualRec" Ref="IN004"/> </HusbFath> <WifeMoth> <Link Target="IndividualRec" Ref="IN005"/> </WifeMoth> <Child> <Link Target="IndividualRec" Ref="IN006"/> </Child> </FamilyRec> <FamilyRec Id="FM003"> <HusbFath> <Link Target="IndividualRec" Ref="IN007"/> </HusbFath> <WifeMoth> <Link Target="IndividualRec" Ref="IN008"/> </WifeMoth> <Child> <Link Target="IndividualRec" Ref="IN009"/> </Child> </FamilyRec> <IndividualRec Id="IN001"> <IndivName>Fathers name</IndivName> <!-- This tag used for father of c1 or husband of w1 --> <Gender>Male</Gender> <AssocIndiv> <Link Target="" Ref="IN002"/> <Association>Wife</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN002"> <!-- This tag used for mother of c1 or wife of h1 --> <IndivName>Mother s name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN001"/> <Association>Husband</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN003"> <!-- This tag used for a child to h1 or w1 or grand son to gm1 or gf1 --> <IndivName>Child 1 name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN001"/> <Association>Father</Association> </AssocIndiv> <AssocIndiv> <Link Target="IndividualRec" Ref="IN002"/> <Association>Mother</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN005"> <!-- This tag used for grand mother --> <IndivName>Grand mother's name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN004"/> <Association>Husband</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN004"> <!-- This tag used for grand father --> <IndivName>Grand father's name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN005"/> <Association>Grand Father's Wife</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN006"> <!-- This tag used for a child to h1 or w1 or grand son to gm1 or gf1 --> <IndivName>Child 1 name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN004"/> <Association>Father</Association> </AssocIndiv> <AssocIndiv> <Link Target="IndividualRec" Ref="IN005"/> <Association>Mother</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN007"> <!-- This tag used for grand mother --> <IndivName>Grand mother's name</IndivName> <Gender>Female</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN008"/> <Association>Husband</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN008"> <!-- This tag used for grand father --> <IndivName>Grand father's name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN007"/> <Association>Grand Father's Wife</Association> </AssocIndiv> </IndividualRec> <IndividualRec Id="IN009"> <!-- This tag used for a child to h1 or w1 or grand son to gm1 or gf1 --> <IndivName>Child 1 name</IndivName> <Gender>Male</Gender> <AssocIndiv> <Link Target="IndividualRec" Ref="IN007"/> <Association>Father</Association> </AssocIndiv> <AssocIndiv> <Link Target="IndividualRec" Ref="IN008"/> <Association>Mother</Association> </AssocIndiv> </IndividualRec></GEDCOM>\[/code\]*Example Output: *An example output of a pair of first cousin isIN006 and IN009RegardsFareed
 
Back
Top