Subject: RE: Semantics of xsl:key (MSXML4 broken?)
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sat, 15 Jun 2002 10:21:18 +0100
|
<xsl:key name = 'test' match = 'Book' use =
"/testcase/BooksAuthors/BookAuthor[@bookid =
current()/@bookid]/@authorid"/>
I think it has been reported before that MSXML4 isn't initializing
current() when evaluating the use expression of xsl:key. I think that's
a bug.
Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Bill Cohagan
> Sent: 14 June 2002 17:05
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Semantics of xsl:key (MSXML4 broken?)
>
>
> I've got an xsl:key definition that works fine on Saxon
> 6.5.2, works on Xalan, but does not work on MSXML4SP1. In
> fact the original XSLT code actually caused MSXML to crash
> although the "testcase" version just doesn't work properly.
>
> The problem I'm trying to solve is to take an XML
> representation of a relational many-to-many relationship and
> define a SINGLE xsl:key that will map from one side of the
> relationship to the other. The testcase uses Authors and
> Books, so I want to be able to define a key that when given
> an authorid will produce the set of corresponding Book
> elements. (Obviously in the real world we'd also like to go
> the other way, but for testcase purposes I'll just deal with
> one direction.)
>
> Our solution uses an "unusual" use attribute on the xsl:key
> definition, but if you interpret the spec the way I do then
> it ought to work just fine. Apparently the Saxon and Xalan
> authors *do* interpret the spec the way I do on this issue.
>
> I've had a brief interchange with a MS person on one of their
> MSDN "moderated" groups, but he seemed to think that our
> approach should NOT work, that the use attribute was somehow
> restricted to *relative* path expression. In any case he
> vanished before addressing any of my questions to him as to
> why he and/or MS believed this to be the case.
>
> What I'm looking for is some confirmation that the code
> *ought* to work (as it in fact does in Saxon/Xalan) - or some
> cogent argument as to why it should not; i.e., an explanation
> of how the spec disallows this sort of thing.
>
> Anyway, here's the testcase code, first the XML, then the
> XSL, and finally the results, expected and actual.
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>XML>>>>>>>>>>>>>>>>>>>>>>
> <testcase>
> <Authors>
> <Author authorid = "1" name = "author 1"/>
> <Author authorid = "2" name = "author 2"/>
> <Author authorid = "3" name = "author 3"/>
> </Authors>
> <Books>
> <Book bookid = "a" name = "book a"/>
> <Book bookid = "b" name = "book b"/>
> <Book bookid = "c" name = "book c"/>
> </Books>
> <BooksAuthors>
> <BookAuthor bookauthorid = "x" bookid = "a" authorid = "1"/>
> <BookAuthor bookauthorid = "y" bookid = "a" authorid = "2"/>
> <BookAuthor bookauthorid = "z" bookid = "b" authorid = "1"/>
> <BookAuthor bookauthorid = "w" bookid = "b" authorid = "3"/>
> </BooksAuthors>
> </testcase>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>XSL>>>>>>>>>>>>>>>>>>>>>>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml" omit-xml-declaration="yes" indent = "yes"/>
>
> <xsl:key name = 'test' match = 'Book' use =
> "/testcase/BooksAuthors/BookAuthor[@bookid =
> current()/@bookid]/@authorid"/>
>
> <xsl:template match = "/">
> <TESTRESULT>
> <xsl:for-each select = "key('test','1')">
> <xsl:copy-of select = "."/>
> </xsl:for-each>
> </TESTRESULT>
> </xsl:template>
> </xsl:stylesheet>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SAXON RESULT>>>>>>>>>>>>>
> <TESTRESULT>
> <Book bookid="a" name="book a"/>
> <Book bookid="b" name="book b"/>
> </TESTRESULT>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MSXML4 RESULT>>>>>>>>>>>>
> <TESTRESULT>
> </TESTRESULT>
>
> Thanks in advance,
> Bill bill@xxxxxxxxxxxxxxxxxxxxx
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|