Subject: Re: [xsl] Transformation of generic spreadsheet XML From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 19 Apr 2001 22:12:27 +0100 |
Hi Xiaocun, > Very much appreciated for the well detailed answer :) My pleasure. >> I think you'd be better off storing the bidHeader row in a global >> variable (assuming that the row elements are children of a 'rows' >> document element here): >> >> <xsl:variable name="bidHeader" select="/rows/row[1]" /> > > Sorry I did not provide the whole picture in my original post (it > was already pretty long :(). The actual source XML had many rows > before the $bidHeader row, therefore the bid header row does not > have exact position among its siblings. So my XSL had to catch that > bid header row and process all following siblings as follows: > > <xsl:template match="row" mode="createBids"> > <RFQRequest> > <xsl:element name="createBids"> > <xsl:apply-templates > select="following-sibling::row" mode="BidsDetail"/> > </xsl:element> > </RFQRequest> > </xsl:template> > > <xsl:template match="row" mode="BidsDetail"> > <xsl:if test="string(cell[1]) = string('BidType') or > substring(cell[1],2) = string('BidType')"> > <xsl:variable name="bidHeader" select="."/> > ...... You don't need to use the string() function to convert strings to strings - string('BidType') is *exactly* the same as 'BidType'. Also, you don't have to convert cell[1] to a string explicitly - it's being compared to a string ('BidType') so it'll automatically be converted to a string for the comparison. So your test in the above is exactly the same as: cell[1] = 'BidType' or substring(cell[1], 2) = 'BidType' But even with the fact that you can't just get the *first* row, I think you could still store that particular row as a global variable with: <xsl:variable name="row" select="/rows/row[cell[1] = 'BidType' or substring(cell[1], 2) = 'BidType']" /> This selects the row where the value of the first cell is 'BidType' or where the substring of the value of that first cell after the first character is 'BidType'. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transformation of generic, Xiaocun Xu | Thread | [xsl] Applying template conditional, Xiaocun Xu |
Re: [xsl] Question about linking us, Betty . Risher | Date | Re: [xsl] Transitive closure for XP, Christian Nentwich |
Month |