Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to select a node set base on the attribute value of a sibling node.

I have a nodes

<Table Name='Customers>

<Field Name='CustomerId'/>

<Field Name='AccountNumber'/>

</Table>

 

<ExtendedDataType>

<Table Name='Customers'/>

<Field Name='CustomerId'/>

</ExtendedDataType>

 

This query returns all of the Property nodes from the Customers table:

/xs:Tables/xs:Table[attribute::Name=Customers]/xs:Propertys/xs:Property

 

I want to replace 'Customers' with

parent::Table[attribute::Name] resulting in something like

/xs:Tables/xs:Table[attribute::Name=parent::Table[attribute::Name]/xs:Propertys/xs:Property

 

so that I can filter the choices for Field of ExtendedDataType by using the Table Name that has already been selected.

 

can this be done? do i need a variable or something?

Thanks for the help,

lp

Posted (edited)

...predicate evaluation

 

if n is the current node:

This returns a nodelist with the correct nodes

n.SelectNodes("/xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name='Customers']/xs:Propertys/xs:Property", nsmgr)

...And this prints 'Customers'

   Dim child As XmlNode
   child  = n.SelectSingleNode("parent::node()/xs:Table", nsmgr)
   MsgBox(child .Attributes("Name").Value)

when i replace 'Customers' with "parent::node()/xs:Table/@Name" giving

 

n.SelectNodes("/xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name=parent::node()/xs:Table/@Name]/xs:Propertys/xs:Property", nsmgr) 

I get a list of all Property Nodes from all Table/Propertys not a filtered list.

Shouldn't 'parent::node()/xs:Table/@Name' evaluate to 'Customers' in the expression?

 

thanks,

lp

Edited by PlausiblyDamp
Posted (edited)

same problem, different issue

 

so here's what i left with

xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table[attribute::Name=parent::node()/xs:Table/@Name]/xs:Propertys/xs:Property"

the expression is evaluating correctly, however not like i initially thought.

it seems that the reference to parent::node() is the parent of the current Table node, not the parent of the the original context. I can only assume that the xs:ObjectTree/xs:DataDictionary/xs:Tables/xs:Table changes the context of the expression.

So the question becomes, how do i reference the original context node after some traversal of the tree(objecttree/datadictionary/tables/table)?

Edited by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...