XPath query difficulty...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • oopsatwork

    XPath query difficulty...

    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>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Condition </Type>
    <TrueSteps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </TrueSteps>
    <FalseSteps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </FalseSteps>
    </Step>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Subroutin e</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Routine>
  • Dimitre Novatchev

    #2
    Re: XPath query difficulty...

    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::T ype[. = ' Subroutine '])]



    Cheers,

    Dimitre Novatchev





    "oopsatwork " <mkimberlin@gma il.comwrote in message
    news:e5de478f-0f92-43e1-b5d2-893d6414703b@d7 7g2000hsb.googl egroups.com...
    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>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Condition </Type>
    <TrueSteps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </TrueSteps>
    <FalseSteps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </FalseSteps>
    </Step>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Subroutin e</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    <Step>
    <Type>Loop</Type>
    <Steps>
    <Step>
    <Type>Calculati on</Type>
    <Other>stuff</Other>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Step>
    </Steps>
    </Routine>

    Comment

    • Mukul Gandhi

      #3
      Re: XPath query difficulty...

      On Sep 27, 12:55 am, oopsatwork <mkimber...@gma il.comwrote:
      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::S tep[Type = 'Subroutine'])]

      Regards,
      Mukul

      Comment

      • oopsatwork

        #4
        Re: XPath query difficulty...

        //Step[not(ancestor::S tep[Type = 'Subroutine'])]
        You guys are pimps...thanks for the help!

        Comment

        Working...