Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath query difficulty...

Reply
Thread Tools

XPath query difficulty...

 
 
oopsatwork
Guest
Posts: n/a
 
      09-26-2008
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>
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      09-27-2008
> 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>



 
Reply With Quote
 
 
 
 
Mukul Gandhi
Guest
Posts: n/a
 
      09-27-2008
On Sep 27, 12:55*am, oopsatwork <(E-Mail Removed)> 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
 
Reply With Quote
 
oopsatwork
Guest
Posts: n/a
 
      09-28-2008

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


You guys are pimps...thanks for the help!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments