You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Noble Paul നോബിള് नोब्ळ् <no...@gmail.com> on 2010/03/01 05:42:47 UTC
Re: Using XSLT with DIH for a URLDataSource
this is the only one place this should be a problem.'xsl' is not a
very commonly used attribute
On Fri, Feb 26, 2010 at 10:46 AM, Lance Norskog <go...@gmail.com> wrote:
> There could be a common 'open an url' utility method. This would help
> make the DIH components consistent.
>
> 2010/2/24 Noble Paul നോബിള് नोब्ळ् <no...@gmail.com>:
>> you are right. The StreamSource class is not throwing the proper exception
>>
>> Do we really have to handle this.?
>>
>> On Thu, Feb 25, 2010 at 9:06 AM, Lance Norskog <go...@gmail.com> wrote:
>>> [Taken off the list]
>>>
>>> The problem is that the XSLT code swallows the real exception, and
>>> does not return it as the "deeper" exception. To show the right
>>> error, the code would open a file name or an URL directly. The problem
>>> is, the code has to throw an exception on a file or an URL and try the
>>> other, then decide what to do.
>>>
>>> try {
>>> URL u = new URL(xslt);
>>> iStream = u.openStream();
>>> } catch (MalformedURLException e) {
>>> iStream = new FileInputStream(new File(xslt));
>>> }
>>> TransformerFactory transFact = TransformerFactory.newInstance();
>>> xslTransformer = transFact.newTransformer(new StreamSource(iStream));
>>>
>>>
>>> On Mon, Feb 22, 2010 at 6:24 AM, Roland Villemoes <rv...@alpha-solutions.dk> wrote:
>>>> You're right!
>>>>
>>>> I was as simple (stupid!) as that,
>>>>
>>>> Thanks a lot.... (for your time .. very appreciated)
>>>>
>>>> Roland
>>>>
>>>> -----Oprindelig meddelelse-----
>>>> Fra: noble.paul@gmail.com [mailto:noble.paul@gmail.com] På vegne af Noble Paul ??????? ??????
>>>> Sendt: 22. februar 2010 14:01
>>>> Til: solr-user@lucene.apache.org
>>>> Emne: Re: Using XSLT with DIH for a URLDataSource
>>>>
>>>> The xslt file looks fine . is the location of the file correct ?
>>>>
>>>> On Mon, Feb 22, 2010 at 2:57 PM, Roland Villemoes <rv...@alpha-solutions.dk> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> (thanks a lot)
>>>>>
>>>>> Yes, The full stacktrace is this:
>>>>>
>>>>> 22-02-2010 08:37:00 org.apache.solr.handler.dataimport.DataImporter doFullImport
>>>>> SEVERE: Full Import failed
>>>>> org.apache.solr.handler.dataimport.DataImportHandlerException: Error initializing XSL Processing Document # 1
>>>>> at org.apache.solr.handler.dataimport.XPathEntityProcessor.initXpathReader(XPathEntityProcessor.java:103)
>>>>> at org.apache.solr.handler.dataimport.XPathEntityProcessor.init(XPathEntityProcessor.java:76)
>>>>> at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:71)
>>>>> at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:319)
>>>>> at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:242)
>>>>> at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:180)
>>>>> at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:331)
>>>>> at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:389)
>>>>> at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:203)
>>>>> at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
>>>>> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
>>>>> at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338)
>>>>> at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)
>>>>> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>>> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>>> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>>> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>>> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>>>> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>>> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>>> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>>>>> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
>>>>> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>>>>> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
>>>>> at java.lang.Thread.run(Thread.java:619)
>>>>> Caused by: javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
>>>>> at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:825)
>>>>> at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:614)
>>>>> at org.apache.solr.handler.dataimport.XPathEntityProcessor.initXpathReader(XPathEntityProcessor.java:98)
>>>>> ... 24 more
>>>>> 22-02-2010 08:37:00 org.apache.solr.update.DirectUpdateHandler2 rollback
>>>>>
>>>>>
>>>>> My import feed (for testing is this):
>>>>> <?xml version='1.0' encoding='utf-8'?>
>>>>> <products>
>>>>> <product id='738' rank='10'>
>>>>> <brand id='48'><![CDATA[World's Best]]></brand><name><![CDATA[Kontakt Cream-Special 4 x 10]]></name>
>>>>> <categories primarycategory='17'>
>>>>> <category id='7'>
>>>>> <name><![CDATA[Jeans & Bukser]]></name>
>>>>> <category id='17'>
>>>>> <name><![CDATA[Jeans]]></name>
>>>>> </category>
>>>>> </category>
>>>>> <category id='8'>
>>>>> <name><![CDATA[Nyheder]]></name>
>>>>> </category>
>>>>> </categories>
>>>>> <description><![CDATA[4 pakker med 10 stk. glatte kondomer, med reservoir og creme.]]></description><price currency='SEK'>310.70</price><salesprice currency='SEK'>233.03</salesprice><color id='227'><![CDATA[4 x 10 kondomer]]></color><size id='6'><![CDATA[Large]]></size><productUrl><![CDATA[http://www.website.se/butik/visvare.asp?id=738]]></productUrl><imageUrl><![CDATA[http://www.website.se/varebilleder/738_intro.jpg]]></imageUrl><lastmodified>11-11-2008 15:10:31</lastmodified></product>
>>>>> <product id='320' rank='10'>
>>>>> <categories primarycategory='17'>
>>>>> <category id='7'>
>>>>> <name><![CDATA[Jeans & Bukser]]></name>
>>>>> <category id='17'>
>>>>> <name><![CDATA[Jeans]]></name>
>>>>> </category>
>>>>> </category>
>>>>> <category id='8'>
>>>>> <name><![CDATA[Nyheder]]></name>
>>>>> </category>
>>>>> </categories>
>>>>> <brand id='1'><![CDATA[JBS]]></brand><name><![CDATA[JBS trusser]]></name><category id='39'><![CDATA[Trusser]]></category><description><![CDATA[Gråmeleret JBS trusser model Classic med gylp.]]></description><price currency='SEK'>154.96</price><salesprice currency='SEK'>154.96</salesprice><color id='28'><![CDATA[Gråmeleret]]></color><size id='5'><![CDATA[Medium]]></size><productUrl><![CDATA[http://www.website.se/butik/visvare.asp?id=320]]></productUrl><imageUrl><![CDATA[http://www.website.se/varebilleder/320_intro.jpg]]></imageUrl><lastmodified>18-08-2009 15:44:46</lastmodified></product>
>>>>> </products>
>>>>>
>>>>>
>>>>> And my test.xslt (cut down to almost nothing just to move further and see that XSLT was working):
>>>>>
>>>>> <?xml version='1.0' encoding='UTF-8'?>
>>>>> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
>>>>> <xsl:template match='/'>
>>>>> <products>
>>>>> <xsl:apply-templates select="./products/product"/>
>>>>> </products>
>>>>> </xsl:template>
>>>>>
>>>>> <xsl:template match="product">
>>>>> <product>
>>>>> <xsl:attribute name='id'>
>>>>> <xsl:value-of select="@id"/>
>>>>> </xsl:attribute>
>>>>> <xsl:attribute name='rank'>
>>>>> <xsl:value-of select="@rank"/>
>>>>> </xsl:attribute>
>>>>> </product>
>>>>> </xsl:template>
>>>>>
>>>>> </xsl:stylesheet>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----Oprindelig meddelelse-----
>>>>> Fra: Shalin Shekhar Mangar [mailto:shalinmangar@gmail.com]
>>>>> Sendt: 22. februar 2010 10:08
>>>>> Til: solr-user@lucene.apache.org
>>>>> Emne: Re: Using XSLT with DIH for a URLDataSource
>>>>>
>>>>> On Mon, Feb 22, 2010 at 1:18 PM, Roland Villemoes <rv...@alpha-solutions.dk>wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have to load data for Solr from a UrlDataSource supplying me with a XML
>>>>>> feed.
>>>>>>
>>>>>> In the simple case where I just do simple XSLT select this works just fine.
>>>>>> Just as shown on the wiki (http://wiki.apache.org/solr/DataImportHandler)
>>>>>>
>>>>>> But I need to do some manipulation of the XML feed first, So I am trying to
>>>>>> a transform first using:
>>>>>>
>>>>>>
>>>>>> <snip>
>>>>>
>>>>>
>>>>>> But no matter what I do in my "test.xslt" - I get the same error:
>>>>>>
>>>>>> ...
>>>>>> org.apache.solr.handler.dataimport.DataImportHandlerException: Error
>>>>>> initializing XSL Processing Document # 1
>>>>>> ...
>>>>>> Caused by: javax.xml.transform.TransformerConfigurationException: Could not
>>>>>> compile stylesheet
>>>>>>
>>>>>>
>>>>>> Anyone that can help me out here? Or has a running example using XSLT with
>>>>>> DIH?
>>>>>>
>>>>>>
>>>>> Can you send the complete stacktrace?
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Shalin Shekhar Mangar.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> -----------------------------------------------------
>>>> Noble Paul | Systems Architect| AOL | http://aol.com
>>>>
>>>
>>>
>>>
>>> --
>>> Lance Norskog
>>> goksron@gmail.com
>>>
>>
>>
>>
>> --
>> -----------------------------------------------------
>> Noble Paul | Systems Architect| AOL | http://aol.com
>>
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>
--
-----------------------------------------------------
Noble Paul | Systems Architect| AOL | http://aol.com