2

Firefox tells me "Error during XSLT transformation: XSLT transformation failed." for an XML file that uses the following XSL file:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dxp='http://schemas.google.com/analytics/2009' 
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:fn='http://www.w3.org/2005/xpath-functions'>
<xsl:output method="html"/>
<xsl:template match="/">
<html><head><title>...</title></head><body>
<table frame='border' rules='all'>
<tr><th>site</th><th>week</th><th>pages</th><th>pageviews</th></tr>
<xsl:for-each select='feeds/feed/week'>
  <xsl:for-each-group select='entry' group-by='fn:concat(
    if (fn:matches(dxp:dimension[@name="ga:pagePath"]/@value, "^/sales"))
      then "/sales"
      else "non-/sales",
    " referred from ",
    if (fn:matches(dxp:dimension[@name="ga:referralPath"]/@value, "^/forsale"))
      then "/forsale"
      else "non-/forsale"
    )'>
    <tr>
      <td><xsl:value-of select='../dxp:tableName'/></td>
      <td>
        <xsl:value-of select='../dxp:startDate'/>-<xsl:value-of select='../dxp:endDate'/>
      </td>
      <td><xsl:value-of select='current-grouping-key()'/></td>
      <td><xsl:value-of select="sum(current-group()/dxp:metric/@value)"/></td>
    </tr>
  </xsl:for-each-group>
</xsl:for-each>
</table></body></html>
</xsl:template>
</xsl:stylesheet>

I can't figure out what might be wrong with this. Anyone know?

(Obviously, if further info is needed from me in order that someone be able to answer this, I'll be glad to provide that info: please comment asking for it. I don't even know what kind of info might be helpful.)


EDIT: Someone mentioned in an answer that my including the XML file might help. It's very long, but its general structure is:

<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='./foo.xsl'?>
<feeds xmlns:dxp='http://schemas.google.com/analytics/2009' 
xmlns:gd='http://schemas.google.com/g/2005' >
<feed><week>
    <id>http://www.google.com/analytics/feeds/data?ids=ga:bar&amp;dimensions=ga:pagePath,ga:referralPath&amp;metrics=ga:pageviews&amp;filters=ga:medium%3D@referral&amp;start-date=2011-12-11&amp;end-date=2011-12-17</id>
    <link rel='self' type='application/atom+xml' href='https://www.google.com/analytics/feeds/data?max-results=10&amp;end-date=2011-12-17&amp;start-date=2011-12-11&amp;metrics=ga%3Apageviews&amp;ids=ga%3Abar&amp;dimensions=ga%3ApagePath%2Cga%3AreferralPath&amp;filters=ga%3Amedium%3D%40referral'/>
    <link rel='next' type='application/atom+xml' href='https://www.google.com/analytics/feeds/data?start-index=11&amp;max-results=10&amp;end-date=2011-12-17&amp;start-date=2011-12-11&amp;metrics=ga%3Apageviews&amp;ids=ga%3Abar&amp;dimensions=ga%3ApagePath%2Cga%3AreferralPath&amp;filters=ga%3Amedium%3D%40referral'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='9999'/>
        <dxp:tableName>bar</dxp:tableName>
    <dxp:endDate>2011-12-17</dxp:endDate>
    <dxp:startDate>2011-12-11</dxp:startDate>
    <entry gd:etag='W/&quot;baz.&quot;' gd:kind='analytics#datarow'>
        <dxp:dimension name='ga:pagePath' value='/'/>
        <dxp:dimension name='ga:referralPath' value='/'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='999'/>
    </entry>
    <entry gd:etag='W/&quot;baz.&quot;' gd:kind='analytics#datarow'>
        <dxp:dimension name='ga:pagePath' value='/'/>
        <dxp:dimension name='ga:referralPath' value='/xyzzy1'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='999'/>
    </entry>
</week>
</feed>
<feed><week>
    <id>http://www.google.com/analytics/feeds/data?ids=ga:bar2&amp;dimensions=ga:pagePath,ga:referralPath&amp;metrics=ga:pageviews&amp;filters=ga:medium%3D@referral&amp;start-date=2011-12-11&amp;end-date=2011-12-17</id>
    <link rel='self' type='application/atom+xml' href='https://www.google.com/analytics/feeds/data?max-results=10&amp;end-date=2011-12-17&amp;start-date=2011-12-11&amp;metrics=ga%3Apageviews&amp;ids=ga%3Abar2&amp;dimensions=ga%3ApagePath%2Cga%3AreferralPath&amp;filters=ga%3Amedium%3D%40referral'/>
    <link rel='next' type='application/atom+xml' href='https://www.google.com/analytics/feeds/data?start-index=11&amp;max-results=10&amp;end-date=2011-12-17&amp;start-date=2011-12-11&amp;metrics=ga%3Apageviews&amp;ids=ga%3Abar2&amp;dimensions=ga%3ApagePath%2Cga%3AreferralPath&amp;filters=ga%3Amedium%3D%40referral'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='9999'/>
        <dxp:tableName>bar2</dxp:tableName>
    <dxp:endDate>2011-12-17</dxp:endDate>
    <dxp:startDate>2011-12-11</dxp:startDate>
    <entry gd:etag='W/&quot;baz.&quot;' gd:kind='analytics#datarow'>
        <dxp:dimension name='ga:pagePath' value='/'/>
        <dxp:dimension name='ga:referralPath' value='/'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='999'/>
    </entry>
    <entry gd:etag='W/&quot;baz.&quot;' gd:kind='analytics#datarow'>
        <dxp:dimension name='ga:pagePath' value='/'/>
        <dxp:dimension name='ga:referralPath' value='/xyzzy2'/>
        <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='999'/>
    </entry>
</week>
</feed>
</feeds>
msh210
  • 256
  • 6
  • 23

2 Answers2

1

Why do you think that Firefox uses an XSLT 2.0 processor?

AFAIK, this isn't so.

Obviously, an XSLT 1.0 processor raises some kind of error when given an XSLT 2.0 transformation that contains non-XSLT 1.0 instructions, such as <xsl:for-each-group> .

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • Can anyone confirm for certain whether Firefox (9.0.1) can handle XSLT 2.0? – msh210 Dec 22 '11 at 15:57
  • @msh210: Better search for "XSLT 2.0 support in Firefox" and confirm that there isn't any official announcement for such support. That no major browser today supports XSLT 2.0 is a well-known fact -- I wonder why you believe XSLT 2.0 is supported. – Dimitre Novatchev Dec 22 '11 at 16:47
0

Do you have an example xml file lying around :) Might help investigating what is wrong with the xsl.

At my first look, I saw a namespace prefix ga, which is not mentioned in the namespace list in the xsl:stylesheet element in your xsl.

I also doubt if the group-by attribute in the xsl:for-each-group works. Seems like you try to dynamically set the value of the group-by attribute by concatenating some xpath results to compose an xpath expression. That is not possible.

Peter Hofman
  • 673
  • 4
  • 17