[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Finding preceeding-siblings with non empty value
Hello,
I have xml that comes from a database which creates rows for changes to a "record". The complete record is a kind of composite of all previous rows -- almost so, if the 'model code' changes it appears that values are reset. (Apologies that I can't be more definite with this undocumented Perl code.) I was having success by looking for the first preceding element of the same type: preceeding[row[site-transaction-name='model code']][1] But what I want is the first preceeding element that is not empty. This is complicated by the fact that the elements are grouped, Could it be this: preceding[row[site-transaction-name='model code']][not empty(.)] Thanks for any tips. --Hank Snippet of code showing that I group the rows by date, <xsl:for-each select="$group/pressure"> <xsl:choose> <!-- If there is a model code, then its a complete record. --> <xsl:when test=".[row[site-transaction-name='model code']]"> <!-- e.g. print the type / model --> <xsl:output select="./row[site-transaction-name='antenna model code']/site-transaction-value" /> </xsl:when> <xsl:otherwise> <!-- This is an update. Find the most recent value from preceeding-siblings. --> <xsl:variable name="ptype" select="preceding[row[site-transaction-name='model code']][1]" /> </xsl:otherwise> </xsl:choose> </xsl:for-each> -------- The grouped data: <pressure xmlns=""> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>additional information</site-transaction-name> <site-transaction-value>Meteo sonde delivered unreliable data 
 at the end</site-transaction-value> <effective-date>1998-11-15T00:00:00.000</effective-date> </row> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>serial number</site-transaction-name> <site-transaction-value>69855</site-transaction-value> <effective-date>1998-11-15T00:00:00.000</effective-date> </row> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>model code</site-transaction-name> <site-transaction-value>PARMT3</site-transaction-value> <effective-date>1998-11-15T00:00:00.000</effective-date> </row> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>data frequency</site-transaction-name> <site-transaction-value>60 s</site-transaction-value> <effective-date>1998-11-15T00:00:00.000</effective-date> </row> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>elev diff to gps</site-transaction-name> <site-transaction-value>-4 m (with respect to marker)</site-transaction-value> <effective-date>1998-11-15T00:00:00.000</effective-date> </row> </pressure> <pressure xmlns=""> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>elev diff to gps</site-transaction-name> <site-transaction-value>-4 m (with respect to marker)</site-transaction-value> <effective-date>2000-07-20T00:00:00.000</effective-date> </row> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>serial number</site-transaction-name> <site-transaction-value>70804</site-transaction-value> <effective-date>2000-07-20T00:00:00.000</effective-date> </row> </pressure> <pressure xmlns=""> <row> <site-transaction-type>pressure sensor</site-transaction-type> <site-transaction-name>elev diff to gps</site-transaction-name> <site-transaction-value>-3.83 m (with respect to marker)</site-transaction-value> <effective-date>2001-02-19T00:00:00.000</effective-date> </row> </pressure> -- Louis (Hank) Ratzesberger sopac.ucsd.edu
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|