This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: data translation => descendants appear side by side inHTML-table


I searched for a different and more general approach (not limited to 2 
base elements). The stylesheet is quite short:

<xsl:template match="root">
   <html>
     <head><title>Descriptions</title></head>
     <body>
       <table border="1">
         <xsl:apply-templates 
select="base[not(count(following-sibling::base//description) > 
count(.//description))]//description"/>
       </table>
     </body>
   </html>
</xsl:template>

<xsl:template match="description">
   <xsl:variable name="pos" select="position()"/>
   <tr>
     <xsl:for-each select="/root/base">
       <td>
         <xsl:value-of select="(.//description)[$pos]"/>
       </td>
     </xsl:for-each>
   </tr>
</xsl:template>

But I found a bug in Xalan: When using <xsl:value-of 
select=".//description[$pos]"/>, I already get the wanted result.

But when I read in the spec

"For example
   appendix//ulist/item[position()=1]
matches a node if and only if all of the following are true:
* ...
* evaluating the PredicateExpr position()=1 with the node as context 
node and the *siblings* of the node that are item elements as the 
context node list yields true
* ..."

I suspect this behaviour is wrong, isn't it?

Regards,

Joerg

> should be transformed into:
> 
> <table>
>     <tr>
>         <td>some_desc1</td>
>         <td>some_desc1</td>
>     </tr>
>     <tr>
>         <td>some_desc2</td>
>         <td>some_add_desc2</td>
>     </tr>
>     <tr>
>         <td>some_add_desc3</td>
>         <td>some_desc3</td>
>     </tr>
>     <tr>
>         <td>some_add_desc4</td>
>         <td>some_desc4</td>
>     </tr>
>     <tr>
>         <td></td>
>         <td>some_add_desc5</td>
>     </tr>
> </table>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]