Connecting Tech Pros Worldwide Help | Site Map

XPath query difficulty...

  #1  
Old September 26th, 2008, 09:05 PM
oopsatwork
Guest
 
Posts: n/a
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>
  #2  
Old September 27th, 2008, 05:15 AM
Dimitre Novatchev
Guest
 
Posts: n/a

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>

  #3  
Old September 27th, 2008, 07:35 AM
Mukul Gandhi
Guest
 
Posts: n/a

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
  #4  
Old September 28th, 2008, 04:15 AM
oopsatwork
Guest
 
Posts: n/a

re: XPath query difficulty...


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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting all the input elements of a malformed form tag yawnmoth answers 5 September 3rd, 2008 01:45 PM
getting all the input elements of a form tag yawnmoth answers 0 July 16th, 2008 11:15 PM
How to escape single quotes Marina Levit [MVP] answers 8 November 15th, 2006 12:45 PM
Trouble with using Session state Greg Linwood answers 9 November 18th, 2005 12:27 AM