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: different results with xalan and msxsl/saxon


Hi Frank,

> <!-- selecting the headings with one level higher than the preceding
> heading -->
> <xsl:key name="headings" match="file/p[starts-with(@stylename, 'heading')]"
>   use="preceding-sibling::p[starts-with(@stylename, 'heading')]
>   [substring(@stylename, 9 , 1)=substring(current()/@stylename, 9,
> 1)-1][1]"/>

I think that the difference between processors probably occurs here.
It may well be that when the expression held in the use attribute is
evaluated, Xalan interprets current() as referring to the matched node
(which is the correct interpretation, in my opinion) whereas MSXML and
Saxon interpret it as something else (probably the root node of the
source document).

As a work-around, if you know how many levels of headings you can
have, you could try using separate keys instead:

<xsl:key name="headings" match="file/p[@stylename = 'heading 2']"
  use="preceding-sibling::p[@stylename = 'heading 1'][1]" />
<xsl:key name="headings" match="file/p[@stylename = 'heading 3']"
  use="preceding-sibling::p[@stylename = 'heading 2'][1]" />
<xsl:key name="headings" match="file/p[@stylename = 'heading 4']"
  use="preceding-sibling::p[@stylename = 'heading 3'][1]" />
...

Also, you should note that you're currently using the *values* of the
paragraphs as the key values, which means that you'll run into
problems if you have two headings with the same title; probably you
should generate an ID for each p element instead, and use them.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]