Using an attribute value as part of an XPath query
Posted: Tue Oct 04, 2005 7:39 pm
I'm working with an XML file describing a database's metadata (i.e., just the tables and other structural elements and their relationships, not any data itself). It was generated by a commercial application and I do not have access to the DTD.
Is there a way given the following XML tree to get the Ref value "o16" and use it to find the o:Column element with an Id of the same value? I can do it when I specifically enter a static value in the XPath (ex. //o:Column[attribute::Id="o16"]), but need to be able to loop through any existing references using xsl:for-each (ex. //o:Column[attribute::Ref="X"] where X is the current value of Ref in the xsl:for-each). Ultimately I want to get //o:Column[attribute::Ref="X"]/a:Name
Thanks for the help
Roland
Is there a way given the following XML tree to get the Ref value "o16" and use it to find the o:Column element with an Id of the same value? I can do it when I specifically enter a static value in the XPath (ex. //o:Column[attribute::Id="o16"]), but need to be able to loop through any existing references using xsl:for-each (ex. //o:Column[attribute::Ref="X"] where X is the current value of Ref in the xsl:for-each). Ultimately I want to get //o:Column[attribute::Ref="X"]/a:Name
Code: Select all
<model>
<o:RootObject>
<c:Tables>
<o:Table>
<a:Name>
<c:Columns>
<o:Column Id="o16">
<a:Name>
<c:Indexes>
<o:Index>
<a:Name>
<c:IndexColumns>
<o:IndexColumn>
<c:Column>
<o:Column Ref="o16">
Roland