Subject: Different xsl:key implementations (was Re: [xsl] Another key question) From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 17 Oct 2002 17:45:50 -0400 |
I'm trying to do something with keys and having a bit of trouble. In doing so, I've done some research with some sample data and come up with the following results.
...
<xslt:key name="sections" match="section" use="generate-id(current())"/>
...
I get the following result out of MSXML4.
...
<title>H1</title>
<para>IDAEAWY</para>
<para></para>
What should happen?
My main question, is what does 'current()' mean in the context in which I've used it within xsl:key.
First read of section 12.2 of XSLT 1.0: --------------------------------------
Second read of section 12.2 of XSLT 1.0: ---------------------------------------
Conclusion ----------
X:\samp>type key-current.xml <?xml version="1.0" encoding="iso-8859-1"?> <test att1='1' att2='2' att3='3'> <x this='a' that='b'>First X</x> <x this='c' that='d'>Second X</x> </test> X:\samp>type key-current.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="atts-." match="x" use="count(./@*)"/> <xsl:key name="atts-current" match="x" use="count(current()/@*)"/> <xsl:key name="atts-root" match="x" use="count(current()/*/@*)"/>
<xsl:template match="/"> <xsl:for-each select="key( 'atts-.', '0' )"> Found 0 attributes in use= expression using "./@*" </xsl:for-each> <xsl:for-each select="key( 'atts-.', '1' )"> Found 1 attribute in use= expression using "./@*" </xsl:for-each> <xsl:for-each select="key( 'atts-.', '2' )"> Found 2 attributes in use= expression using "./@*" </xsl:for-each> <xsl:for-each select="key( 'atts-.', '3' )"> Found 3 attributes in use= expression using "./@*" </xsl:for-each> <xsl:for-each select="key( 'atts-current', '0' )"> Found 0 attributes in use= expression using "current()/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-current', '1' )"> Found 1 attribute in use= expression using "current()/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-current', '2' )"> Found 2 attributes in use= expression using "current()/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-current', '3' )"> Found 3 attributes in use= expression using "current()/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-root', '0' )"> Found 0 attributes in use= expression using "current()/*/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-root', '1' )"> Found 1 attribute in use= expression using "current()/*/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-root', '2' )"> Found 2 attributes in use= expression using "current()/*/@*" </xsl:for-each> <xsl:for-each select="key( 'atts-root', '3' )"> Found 3 attributes in use= expression using "current()/*/@*" </xsl:for-each> </xsl:template>
X:\samp>call ..\prog\xsltjavasaxon key-current.xml key-current.xsl saxon.out Invoking Saxon jar....
X:\samp>call ..\prog\msxml key-current.xml key-current.xsl msxml.out Invoking MSXML....
X:\samp>type saxon.out <?xml version="1.0" encoding="utf-8"?> Found 2 attributes in use= expression using "./@*"
X:\samp>type xalan.out <?xml version="1.0" encoding="UTF-8"?>
X:\samp>type msxml.out <?xml version="1.0" encoding="UTF-16"?> Found 2 attributes in use= expression using "./@*"
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO Next public training: 2002-12-08,2003-02-03,06,03-03,06
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: Is it possible to kno, Dion Houston | Thread | RE: Different xsl:key implementatio, Richard Lander |
RE: [xsl] Re: Is it possible to kno, Dion Houston | Date | RE: [xsl] named template that retur, James Carlyle |
Month |