Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] data translation => descendants appear side by side in HTML-table

From: Wendell Piez <wapiez@---------------->
To:
Date: 5/6/2002 8:36:00 AM
Joerg,



I'm afraid I didn't track the start of this thread, but there is a common 
"gotcha" here, and I think you're right, you may be observing a buglet in 
Xalan.



(.//description)[$pos] is an expansion of



(./descendant-or-self::node()/child::description)[position()=$pos]
translates into English as

From the context node, collect all descendant description elements (i.e. 
all description elements that are children of the context node or its 
descendants), and of that set take the one in $pos position in document order.



.//description[$pos] expands



./descendant-or-self::node()/child::description[position()=$pos]
translates as

From the context node, collect all description elements that are children 
of the context node or its descendants, and take those that are in $pos 
position *as children of their parents* (i.e. among their siblings).



Note that the presence of the parentheses grouping operator in the first 
case is critical, since it collects all those children and filters them as 
a group; whereas in the second case, the predicate operates only on the 
last step, 'child::description[position()=$pos]'.



Does that help clarify or confirm? It was tough enough for me to 
internalize this distinction when I was learning XPath that it stuck. I hope.



Cheers,
Wendell

At 09:25 AM 5/4/2002, you wrote:
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




======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent