Hello,
I currently have set up Solr working and I am doing tests with the XSL
stylesheets.

I had no problem in generating HTML files, but while trying to generate Json
files I noticed something odd..

I am calling Solr with the following URL:
http://172.16.0.30:8983/solr/gcontacts/select?q=apache*~&fl=all_text&wt=xslt&tr=example.xsl

What I noticed is, that no matter what you place in the XSLT file, you
ALWAYS get
<?xml version="1.0" encoding="UTF-8"?>
as the first line of the document. Is there a way to avoid this?

This is the XSL that I am using:

<xsl:stylesheet version='1.0'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
>
  <xsl:output media-type="text/json; charset=UTF-8" />

  <xsl:template match='/'>
      searchAsYouType.handleAjaxResponse({"query":"term",
"results":[<xsl:apply-templates select="response/result/doc"/>]})
  </xsl:template>

  <xsl:template match="doc">
    <xsl:variable name="pos" select="position()"/>
        <xsl:apply-templates>
          <xsl:with-param name="pos"><xsl:value-of
select="$pos"/></xsl:with-param>
        </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="doc/arr" priority="100">
        <xsl:for-each select="*">
            {"name":"<xsl:value-of
select="."/>","type":"text/html","content":"","moreDetailsUrl":"
http://somedomain.com/","style":"normal"},
        </xsl:for-each>
  </xsl:template>

  <xsl:template match="*"/>

</xsl:stylesheet>

This produces the following text:
<?xml version="1.0" encoding="UTF-8"?>
      searchAsYouType.handleAjaxResponse({"query":"term", "results":[
            {"name":"Apache
Server","type":"text/html","content":"","moreDetailsUrl":"
http://somedomain.comn/","style":"normal"},
 ...

Since the first line is <?xml version="1.0" encoding="UTF-8"?>, it is
killing my script.

did I miss something?

Thanks for the help.

Reply via email to