Subject: Re: Need some help with an expression... From: Francis Norton <francis@xxxxxxxxxxx> Date: Tue, 22 Aug 2000 22:15:08 +0100 |
If I understand your requirement correctly - in particular, that the "9" is a search parameter - then the following example - which simply adds to your perfectly correct first attempt - should do what you want. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <out> <xsl:value-of select="/box/category[@name='someType']/header[self/instance='9']/ref"/> </out> </xsl:template> </xsl:stylesheet> Basically what you do is put anything that is only part of the search path, but not part of the result path, in square brackets. I think of the square brackets as being like the where claseu of an SQL statement (but then I think of xpath as being the SQL of tree-structured data...) Hope this helps - Francis. Charles Douthart wrote: > > Hello, > I'm fairly new to XPath and hope that you all can help me with a > problem. > > Given an XML structure like the following: > > <box> > <category name="someType"> > <header> > <self> > <host>myhost</host> > <instance>9</instance> > </self> > <ref> > <host>thathost</host> > <instance>1010101</instance> > </ref> > </header> > > And the value of the header instance is 9 (passed from a web page to a > servlet) > > What expression can I use to get the ref elemenent under the same header > parent? I undserstand enough to produce > /box/category[@name='someType']/header, but I'm stumped as to how I > should proceed from there. I need to test the value of /self/instance > to find the matching element and then get the ref sibling of the same > header ancestor of the matching element. > > TIA, > charles douthart > charles.douthart@xxxxxxxxxxxxx > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- Francis Norton. Defy Convention? Deify Convention! XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Need some help with an expression.., Charles Douthart | Thread | Re: Need some help with an expressi, Charles Douthart |
RE: problems again!, Matthew Bentley | Date | Re: me escape logic escapes me, John Robert Gardner |
Month |