Subject: [xsl] Re: current context preceding-sibling then following-sibling From: Karl Stubsjoen <kstubs@xxxxxxxxx> Date: Mon, 7 Mar 2005 12:33:26 -0700 |
Did the following message ever make the list? I posted this a few days back. current context preceding-sibling then following-sibling On Fri, 4 Mar 2005 08:14:19 -0700, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote: > Hello, > > I have complex xpath query which I need help with. Let me first jump > to the question which appears to be the hangup: > > the context of the following-sibling following a preceding-sibling > should result you in the context of the current sibling? > > Often times with a problem like this there is another or better > approach. I may have reached the point where I need to try another > approach. However, I am so close to the correct solution that I wish > to persue this just a bit further. Let me see if I can explain what > it is I am trying to accomplish: > > The short of it is, I am comparing the preceding-sibling with the > current. The preceding-sibling must contain the code "XYZ" when the > current contains the code "WXY". > > You derive the code to match by a code lookup which is part of the XML > source. So, for current you can determine what the > preceding-sibling's code should be by first looking in the code > section at the top of the source. > > So, code "WXY" is only valid when the preceding-sibling is code "XYZ" > (as an example). > > A mock up XML: > > <ROOT> > <CODES> > <CODE name="WXY"> > <MATCH>XYZ</MATCH> > </CODE> > </CODES> > <RESULTS> > <RESULT code="XYZ" /> > <RESULT code="WXY"/> > </RESULTS> > </ROOT> > > You might be asking why preceding-sibling followed by following-sibling: > Because the RESULT code for current is actually an ID which is > resolved in CODE lookup above (not shown here) ... well, let me just > add the actual xpath expressions here and maybe it will be easier to > understand... > > My "hard coded method" works perfectly... > > HARD CODED METHOD: > ===================================================== > /root/recordset[@rsName='Memberships']/record[field[@fieldname='RefEntryActivityID']= > ( 33 )]/preceding-sibling::record[field[@fieldname='ExitActivityValue'] > = ( 'W4' ) ] > > Each value within the ( ) needs to be replaced with an appropriate > xpath statement. > > So, the first ( 33 ) above is replaced with the following: > > /root/recordset[@rsName='Codes']/record[field[@fieldname='Section']= ( > 209 )]/field[@fieldname='ID'] > > This XPATH still works great but now I need to replace the ( 209 ), > but this is not really an issue so we'll skip to the ( 'W4' ). > > The ( 'W4' ) is replaced with: > > /root/recordset[@rsName='Codes']/record[field[@fieldname='ID']= ( 33 > )]/field[@fieldname='Match'] > > Now, it is this next ( 33 ) which is the problem! This value is > really the current siblings RefEntryActivityID, which the current > sibling is now out of context? (that is a question). Notice that ( 33 > ) is part of the right hand side of a preceding-sibling. So, couldn't > I just go following-sibling at this point? Which doesn't appear to be > working... Here are my 3 attempts at getting this ( 33 ) value from > the original current context (none work): > > 33 = field[@fieldname='RefEntryActivityID'] > 33 = ./field[@fieldname='RefEntryActivityID'] > 33 = following-sibling::record/field[@fieldname='RefEntryActivityID'] > > Thanks for the help! > > Karl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] current context preceding-sib, Karl Stubsjoen | Thread | Re: [xsl] current context preceding, J.Pietschmann |
Re: [xsl] Media types used in xml-s, J.Pietschmann | Date | Re: [xsl] how to concatenate fields, Deirdre Saoirse Moen |
Month |