tags:

views:

77

answers:

2

For some reason, YQL's XSLT table can't parse my stylesheet. I have used the stylesheet successfully with the W3C's XSLT service. Here's an example of the problem in YQL Console. Why does this not work in YQL?

Also, I have yet to figure out how to pass the results of a YQL query to the XSLT table as the XML to be transformed while also specifying a stylesheet url. Current workaround is to abuse the W3C's service.

+1  A: 

Your stylesheet is defined as 1.0 but you're using replace() and tokenize() which is part of the 2.0 standard. However it is a fully valid XSLT/XPath 2.0 stylesheet.

Per T
Thanks. It was unclear in the XPath function documentation that these are 2.0 functions. I've tried changing the declaration, but YQL still does not like it. I guess their implementation is 1.0.
robartsd
Rewriting stylesheet to 1.0 allowed it to work in YQL.
robartsd
+1  A: 

As an addition to Per T answer, change this:

<xsl:variable name="r">
<xsl:value-of select="replace(tr/td/p/a/following-sibling::text(),
                              '\s*-\s*(\d+)\.(\d+)\.(\d+)\s*',
                              '$1,$2,$3')" />
</xsl:variable>

With this:

<xsl:variable name="r" 
        select="translate(tr/td/p/a/following-sibling::text(),'. -',',')">

These:

tokenize($r,',')[1]

tokenize($r,',')[2]

tokenize($r,',')[3]

With these:

substring-before($r,',')

substring-before(substring-after($r,','),',')

substring-after(substring-after($r,','),',')

Note: This is just in case you don't know the amount of digit in advance, otherwise you could do:

substring($r,1,2)

substring($r,4,2)

substring($r,7)

Also, this

replace(tr/td/p[@class='t11bold']/a,'\s+',' ')

It should be just this:

normalize-space(tr/td/p[@class='t11bold']/a)

And finaly this:

replace($d,'^[^\[]*\[\s*(\d+:\d{2})?\s*-?\s*([^\]]*)\]\s*$','$2')

Could be:

normalize-space(substring-after(substring-before(substring-after($d,'['),']'),'-'))
Alejandro
robartsd
Your suggestions were very helpful in rewriting the stylesheet to 1.0.
robartsd