mirror of https://github.com/apache/lucene.git
Adjust mappers with dependencies to conditionally load
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@538603 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4514690cf5
commit
2e0bab1770
|
@ -10,11 +10,18 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'hpricot'
|
||||
begin
|
||||
require 'hpricot'
|
||||
|
||||
# For files with the first line containing field names
|
||||
class Solr::Importer::HpricotMapper < Solr::Importer::Mapper
|
||||
def field_data(doc, path)
|
||||
doc.search(path.to_s).collect { |e| e.inner_html }
|
||||
class Solr::Importer::HpricotMapper < Solr::Importer::Mapper
|
||||
def field_data(doc, path)
|
||||
doc.search(path.to_s).collect { |e| e.inner_html }
|
||||
end
|
||||
end
|
||||
rescue LoadError => e # If we can't load hpricot
|
||||
class Solr::Importer::HpricotMapper
|
||||
def initialize(mapping, options={})
|
||||
raise "Hpricot not installed."
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,18 +10,26 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'xml/libxml'
|
||||
begin
|
||||
require 'xml/libxml'
|
||||
|
||||
# For files with the first line containing field names
|
||||
class Solr::Importer::XPathMapper < Solr::Importer::Mapper
|
||||
def field_data(doc, xpath)
|
||||
doc.find(xpath.to_s).collect do |node|
|
||||
case node
|
||||
when XML::Attr
|
||||
node.value
|
||||
when XML::Node
|
||||
node.content
|
||||
# For files with the first line containing field names
|
||||
class Solr::Importer::XPathMapper < Solr::Importer::Mapper
|
||||
def field_data(doc, xpath)
|
||||
doc.find(xpath.to_s).collect do |node|
|
||||
case node
|
||||
when XML::Attr
|
||||
node.value
|
||||
when XML::Node
|
||||
node.content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue LoadError => e # If we can't load libxml
|
||||
class Solr::Importer::XPathMapper
|
||||
def initialize(mapping, options={})
|
||||
raise "libxml not installed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue