[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Converting from <dt><dd> pairs to better XML
Dear Evan,
By means of which rule will the stylesheet be able to infer that the missing grouping key is 'DDD'? Maybe the actual problem suggests an obvious rule for generating these column titles? In any case, whether you generated a sequence of titles in advance or whether you supply it verbatim: Since it's not there in the data, you cannot derive a grouping key out of the data. Instead I suggest the following solution that doesn't use grouping at all (because you reassured us that after each dt, there's always a single dd): <xsl:template match="dl"> <xsl:variable name="context" select="." as="element(dl)" /> <xsl:variable name="dds" as="xs:string+"> <!-- The following may be a sequence calculated in advance: --> <xsl:for-each select="('AAA', 'BBB', 'CCC', 'DDD', 'EEE')"> <xsl:sequence select="string-join( (: could also use following-sibling::dd[1] here :) $context/dt[. eq current()]/following-sibling::*[1]/self::dd, ',' )" /> </xsl:for-each> </xsl:variable> <xsl:sequence select="string-join($dds, '|')" /> </xsl:template> Regarding 'following-sibling': Is it the following-sibling::*[1]/self::dd that you find hard to understand? This is to say: "use the immediately following sibling element but only if it's a dd." We should probably raise an error if it turns out not to be self::dd. In this case, as I wrote in the comment above, you could also select following-sibling::dd[1] which means "use the first of the following dd siblings". In the original example, we had <xsl:sequence select="string-join( for $dt in current-group() return $dt/following-sibling::*[1]/self::dd, ',' )" /> which just means: construct a sequence in such a way that for each member of the current group [#] use the immediately following dd element and add it to the sequence. [#] The current group consists of all <dt>AAA</dt> elements in the first group, all <dt>BBB</dt> elements in the second group, and so on. -Gerrit On 03.09.2010 02:10, Evan Leibovitch wrote: Thanks to everyone who helped in my original question
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard VC6ckler
|
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
|