Connecting Tech Pros Worldwide Forums | Help | Site Map

XPath query difficulty...

oopsatwork
Guest
 
Posts: n/a
#1: Sep 26 '08
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
Guest
 
Posts: n/a
#2: Sep 27 '08

re: XPath query difficulty...


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


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



Cheers,

Dimitre Novatchev





"oopsatwork" <mkimberlin@gmail.comwrote in message
news:e5de478f-0f92-43e1-b5d2-893d6414703b@d77g2000hsb.googlegroups.com...
Quote:
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>

Mukul Gandhi
Guest
 
Posts: n/a
#3: Sep 27 '08

re: XPath query difficulty...


On Sep 27, 12:55*am, oopsatwork <mkimber...@gmail.comwrote:
Quote:
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
oopsatwork
Guest
 
Posts: n/a
#4: Sep 28 '08

re: XPath query difficulty...


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

Closed Thread