title: Xpath 'instance of' not working in solr xslt
body: <p>I want use xslt in solr to output result in json without specific solr attributes.</p>
  
  <pre><code>    {
        "techproducts": [
           {
              "id": "GB18030TEST",
              "price": "0.0"
           },
           {
              "id": "SOLR1000",
              "price": "0.0"
           },
           {
              "id": "UTF8TEST",
              "price": "0.0"
           }
        ],
        "paging": {
          "count": 3
        }
      }
  </code></pre>
  
  <p>The test of type of field (numeric or boolean) <code>test=". instance of xs:integer"</code> in order to add or not quotes <strong>do not work</strong> and generate a 500 error.</p>
  
  <pre><code>http://localhost:8090/solr/techproducts/select?q=*&amp;fq=price:0&amp;fl=id,price&amp;wt=xslt&amp;tr=json_paginate.xsl
  
   Caused by: javax.xml.transform.TransformerConfigurationException: solrres:/xslt/json_paginate.xsl: line 37: Attribut 'test' obligatoire manquant.
  </code></pre>
  
  <p><strong>Any suggestions?</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" &gt;
  
    &lt;xsl:strip-space elements="*"/&gt;
    &lt;xsl:output method="text" indent="no" media-type="application/json"/&gt;
  
      &lt;xsl:template match='/'&gt;
          &lt;xsl:text&gt;{"techproducts":[&lt;/xsl:text&gt;
          &lt;xsl:apply-templates select="response/result/doc"/&gt;
          &lt;xsl:text&gt;],&lt;/xsl:text&gt;
          &lt;xsl:text&gt;"paging":{"count":&lt;/xsl:text&gt;&lt;xsl:value-of select="response/result/@numFound"/&gt;&lt;xsl:text&gt;}}&lt;/xsl:text&gt;
      &lt;/xsl:template&gt; 
  
    &lt;xsl:template match="doc"&gt; 
      &lt;xsl:variable name="pos" select="position()"/&gt;
      &lt;xsl:if test="position() &amp;gt; 1"&gt;
          &lt;xsl:text&gt;,&lt;/xsl:text&gt;
         &lt;/xsl:if&gt;
  
      &lt;xsl:text&gt;{&lt;/xsl:text&gt;
          &lt;xsl:apply-templates&gt;
              &lt;xsl:with-param name="pos"&gt;&lt;xsl:value-of select="$pos"/&gt;&lt;/xsl:with-param&gt;
          &lt;/xsl:apply-templates&gt;
      &lt;xsl:text&gt;}&lt;/xsl:text&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="doc/*"&gt;
      &lt;xsl:if test="position() &amp;gt; 1"&gt;
          &lt;xsl:text&gt;,&lt;/xsl:text&gt;
         &lt;/xsl:if&gt;
      &lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;xsl:value-of select="@name"/&gt;&lt;xsl:text&gt;":&lt;/xsl:text&gt;
  
      &lt;xsl:choose&gt;
          &lt;!-- if integer, do not add quotes --&gt;
          &lt;xsl:when test=". instance of xs:integer"&gt;
              &lt;xsl:value-of select="."/&gt;
          &lt;/xsl:when&gt;
          &lt;!-- if boolean, do not add quotes --&gt;
          &lt;xsl:when test=". instance of xs:boolean"&gt;
              &lt;xsl:value-of select="."/&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
              &lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;xsl:value-of select="."/&gt;&lt;xsl:text&gt;"&lt;/xsl:text&gt;          
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
  
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p><strong>To solve the problem :</strong> 
  I have upgraded xslt version in solr <code>http://wiki.apache.org/solr/XsltResponseWriter</code> and used </p>
  
  <pre><code>&lt;xsl:choose&gt;
      &lt;!-- if decimal, do not add quotes --&gt;
      &lt;xsl:when test=". castable as xs:decimal"&gt;
          &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:when&gt;
      &lt;!-- if boolean, do not add quotes --&gt;
      &lt;xsl:when test=". castable as xs:boolean"&gt;
          &lt;xsl:value-of select="."/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
          &lt;xsl:text&gt;"&lt;/xsl:text&gt;&lt;xsl:value-of select="."/&gt;&lt;xsl:text&gt;"&lt;/xsl:text&gt;          
      &lt;/xsl:otherwise&gt;
  &lt;/xsl:choose&gt;
  </code></pre>