xsl-list
[Top] [All Lists]

grouping in a separate data file

2005-05-28 21:07:08
Hi,
I'm trying to use the muench method to group elements that exist in a
separate document that I reference in the key with document().  I can
make it work when the xsl document is directly transforming the XML
document (code 'a' below), but not when the xml document that is the
target of the grouping is a secondary document (see code 'b' below).

With the code b example, the parsing fails on the key - saying that the
xpath expression is invalid.  I've tried using a full URI and using the
second argument of the document function to set the URI reference, all
to no avail.

Any suggestions are appreciated. Thanks in advance.

CODE 'A' (this is test.xsl, parsing m.xml)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"/>

<xsl:key name="foo" match="check[not(@s508='')]" use="@g1"/>

<xsl:template match="standardsmatrix">
<html><head></head>
<body>
<p>
        Count: <xsl:value-of select="count(check[generate-id(.) =
generate-id(key('foo',@g1)[1])])"/><br />
        <xsl:for-each select="check[generate-id(.) =
generate-id(key('foo',@g1)[1])]">
                <xsl:value-of select="@g1"/><br />
        </xsl:for-each>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>



CODE 'B' (this is test.xsl, parsing test.xml and referring to m.xml via
document().)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"/>

<xsl:key name="foo"
match="document('m.xml')/standardsmatrix/check[not(@g1='')]" use="@g1"/>

<xsl:template match="report">
<html><head></head>
<body>
<p>
        Count: <xsl:value-of
select="count(document('m.xml')/standardsmatrix/check[generate-id(.) =
generate-id(key('foo',@g1)[1])])"/><br />
        <xsl:for-each
select="document('m.xml')/standardsmatrix/check[generate-id(.) =
generate-id(key('foo',@g1)[1])]">
                <xsl:value-of 
select="document('m.xml')/standardsmatrix/check/@g1"/><br />
        </xsl:for-each>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • grouping in a separate data file, Andrew Kirkpatrick <=