I want to select all the node names beneath a given node

Discussion in 'XML' started by thecolour, Jun 26, 2007.

  1. thecolour

    thecolour Guest

    Dear all

    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";

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

    <ReconResults>


    {
    :)this sections gets all the differences between rows present in
    both datasets :)
    for $PolicyInwardsDifference in /diffgr:diffgram/NewDataSet/
    PolicyInwards
    return
    if( $PolicyInwardsDifference/@diffgr:hasChanges[text() =
    'modified'] )
    then
    <Difference>
    <PKValue>
    {$PolicyInwardsDifference/PolicyID/text()}
    </PKValue>

    <Column>
    <ColumnName></ColumnName>
    <ValueSource></ValueSource>
    <ValueTarget></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
    thecolour, Jun 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?=22Gabri=EBl=40Home=22?=

    Strange white block beneath the page in FF

    =?ISO-8859-1?Q?=22Gabri=EBl=40Home=22?=, Jan 30, 2006, in forum: HTML
    Replies:
    5
    Views:
    396
    Mark Parnell
    Feb 1, 2006
  2. Lewis G. Pringle, Jr.
    Replies:
    0
    Views:
    592
    Lewis G. Pringle, Jr.
    Sep 30, 2003
  3. chiara
    Replies:
    6
    Views:
    458
    Barry Schwarz
    Oct 6, 2005
  4. thecolour
    Replies:
    2
    Views:
    412
    thecolour
    Jun 27, 2007
  5. Matt
    Replies:
    2
    Views:
    193
    Roland Hall
    Jan 11, 2004
Loading...

Share This Page