XPath query difficulty...

Discussion in 'XML' started by oopsatwork, Sep 26, 2008.

  1. oopsatwork

    oopsatwork Guest

    I'm trying to construct an XPath and it is giving me trouble. I have
    an XML that contains a "Routine". The routine contains "Steps". The
    steps have different types. Some types of steps have more steps
    contained within them (substeps). I want to get a list of all of the
    steps in a routine, including any substeps...but excluding substeps
    that occur in a particular type of step ("Subroutine").

    Below is a simplified example XML. The query I envision would return
    all of the steps in the routine, including substeps found in the
    "Loop" step type and "Condition" step type...but NOT including any
    steps that are anywhere within a "Subroutine" step.

    Any thoughts? My sincerest thanks in advance!

    -----

    <Routine>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Condition</Type>
    <TrueSteps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </TrueSteps>
    <FalseSteps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    </FalseSteps>
    </Step>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Subroutine</Type>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculation</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Routine>
     
    oopsatwork, Sep 26, 2008
    #1
    1. Advertising

  2. > I'm trying to construct an XPath and it is giving me trouble. I have

    > an XML that contains a "Routine". The routine contains "Steps". The


    > steps have different types. Some types of steps have more steps


    > contained within them (substeps). I want to get a list of all of the


    > steps in a routine, including any substeps...but excluding substeps


    > that occur in a particular type of step ("Subroutine").




    //Step[not(ancestor::Type[. = ' Subroutine '])]



    Cheers,

    Dimitre Novatchev





    "oopsatwork" <> wrote in message
    news:...
    > I'm trying to construct an XPath and it is giving me trouble. I have
    > an XML that contains a "Routine". The routine contains "Steps". The
    > steps have different types. Some types of steps have more steps
    > contained within them (substeps). I want to get a list of all of the
    > steps in a routine, including any substeps...but excluding substeps
    > that occur in a particular type of step ("Subroutine").
    >
    > Below is a simplified example XML. The query I envision would return
    > all of the steps in the routine, including substeps found in the
    > "Loop" step type and "Condition" step type...but NOT including any
    > steps that are anywhere within a "Subroutine" step.
    >
    > Any thoughts? My sincerest thanks in advance!
    >
    > -----
    >
    > <Routine>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Loop</Type>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Loop</Type>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > </Steps>
    > </Step>
    > </Steps>
    > </Step>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Condition</Type>
    > <TrueSteps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Loop</Type>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > </Steps>
    > </Step>
    > </TrueSteps>
    > <FalseSteps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > </FalseSteps>
    > </Step>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Subroutine</Type>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > <Step>
    > <Type>Loop</Type>
    > <Steps>
    > <Step>
    > <Type>Calculation</Type>
    > <Other>stuff</Other>
    > </Step>
    > </Steps>
    > </Step>
    > </Steps>
    > </Step>
    > </Steps>
    > </Routine>
     
    Dimitre Novatchev, Sep 27, 2008
    #2
    1. Advertising

  3. oopsatwork

    Mukul Gandhi Guest

    On Sep 27, 12:55 am, oopsatwork <> wrote:
    > I'm trying to construct an XPath and it is giving me trouble.  I have
    > an XML that contains a "Routine".  The routine contains "Steps".  The
    > steps have different types.  Some types of steps have more steps
    > contained within them (substeps).  I want to get a list of all of the
    > steps in a routine, including any substeps...but excluding substeps
    > that occur in a particular type of step ("Subroutine").


    I would think, this should work (not tested, though)

    //Step[not(ancestor::Step[Type = 'Subroutine'])]

    Regards,
    Mukul
     
    Mukul Gandhi, Sep 27, 2008
    #3
  4. oopsatwork

    oopsatwork Guest


    > //Step[not(ancestor::Step[Type = 'Subroutine'])]


    You guys are pimps...thanks for the help!
     
    oopsatwork, Sep 28, 2008
    #4
    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. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,974
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,415
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    527
  4. goog
    Replies:
    0
    Views:
    508
  5. David Gordon

    xpath query query

    David Gordon, May 18, 2005, in forum: XML
    Replies:
    2
    Views:
    795
    David Gordon
    May 18, 2005
Loading...

Share This Page