lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mharw...@apache.org
Subject svn commit: r382170 - in /lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser: ./ builders/
Date Wed, 01 Mar 2006 21:49:20 GMT
Author: mharwood
Date: Wed Mar  1 13:49:17 2006
New Revision: 382170

URL: http://svn.apache.org/viewcvs?rev=382170&view=rev
Log:
Added more helper methods to DOMUtils and cleaned up error handling in builders - thanks Chris.
Moved FilteredQueryBuilder.java to "builders" package with all other builders

Added:
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/FilteredQueryBuilder.java
Removed:
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/FilteredQueryBuilder.java
Modified:
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CoreParser.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNearBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNotBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanTermBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermQueryBuilder.java
    lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CoreParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CoreParser.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CoreParser.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/CoreParser.java
Wed Mar  1 13:49:17 2006
@@ -10,6 +10,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.xmlparser.builders.BooleanQueryBuilder;
 import org.apache.lucene.xmlparser.builders.ConstantScoreQueryBuilder;
+import org.apache.lucene.xmlparser.builders.FilteredQueryBuilder;
 import org.apache.lucene.xmlparser.builders.RangeFilterBuilder;
 import org.apache.lucene.xmlparser.builders.SpanFirstBuilder;
 import org.apache.lucene.xmlparser.builders.SpanNearBuilder;

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/DOMUtils.java
Wed Mar  1 13:49:17 2006
@@ -11,6 +11,65 @@
 
 public class DOMUtils
 {
+    public static Element getChildByTagOrFail(Element e, String name)	throws ParserException
+	{
+		Element kid = getChildByTagName(e, name);
+		if (null == kid)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" child element");
+		}
+		return kid;
+	}
+     
+     public static Element getFirstChildOrFail(Element e) throws ParserException
+	{
+		Element kid = getFirstChildElement(e);
+		if (null == kid)
+		{
+			throw new ParserException(e.getTagName()
+					+ " does not contain a child element");
+		}
+		return kid;
+	}
+     
+	public static String getAttributeOrFail(Element e, String name)	throws ParserException
+	{
+		String v = e.getAttribute(name);
+		if (null == v)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" attribute");
+		}
+		return v;
+	}
+    public static String getAttributeWithInheritanceOrFail(Element e,	String name) throws
ParserException
+	{
+		String v = getAttributeWithInheritance(e, name);
+		if (null == v)
+		{
+			throw new ParserException(e.getTagName() + " missing \"" + name
+					+ "\" attribute");
+		}
+		return v;
+	}
+    public static String getNonBlankTextOrFail(Element e) throws ParserException
+	{
+		String v = getText(e);
+		if (null != v)
+			v = v.trim();
+		if (null == v || 0 == v.length())
+		{
+			throw new ParserException(e.getTagName() + " has no text");
+		}
+		return v;
+	}
+ 
+     
+     
+     
+	
+	
 	/* Convenience method where there is only one child Element of a given name */
 	public static Element getChildByTagName(Element e, String name)
 	{

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanQueryBuilder.java
Wed Mar  1 13:49:17 2006
@@ -37,18 +37,9 @@
 			Element clauseElem=(Element) nl.item(i);
 			BooleanClause.Occur occurs=getOccursValue(clauseElem);
 			
-			//find the first element child which should contain a Query 
-			Element clauseQuery=DOMUtils.getFirstChildElement(clauseElem); 
-			if(clauseQuery!=null)
-			{
-				Query q=factory.getQuery(clauseQuery);
-				bq.add(new BooleanClause(q,occurs));
-				
-			}
-			else
-			{
-				throw new ParserException("BooleanClause missing child query element ");
-			}
+ 			Element clauseQuery=DOMUtils.getFirstChildOrFail(clauseElem);
+ 			Query q=factory.getQuery(clauseQuery);
+ 			bq.add(new BooleanClause(q,occurs));			
 		}
 		
 		return bq;

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BoostingQueryBuilder.java
Wed Mar  1 13:49:17 2006
@@ -22,34 +22,18 @@
 	public Query getQuery(Element e) throws ParserException
 	{
 		
-		Element mainQueryElem=DOMUtils.getChildByTagName(e,"Query");
-		if(mainQueryElem==null)
-		{
-			throw new ParserException("BoostingQuery missing a \"Query\" child element");
-		}
-		mainQueryElem=DOMUtils.getFirstChildElement(mainQueryElem);
-		if(mainQueryElem==null)
-		{
-			throw new ParserException("BoostingQuery \"Query\" element missing a child element");
-		}
-		Query mainQuery=factory.getQuery(mainQueryElem);
-		
+        Element mainQueryElem=DOMUtils.getChildByTagOrFail(e,"Query");
+ 		mainQueryElem=DOMUtils.getFirstChildOrFail(mainQueryElem);
+  		Query mainQuery=factory.getQuery(mainQueryElem);
 
-		Element boostQueryElem=DOMUtils.getChildByTagName(e,"BoostQuery");
-		float boost=DOMUtils.getAttribute(boostQueryElem,"boost",defaultBoost);
-		if(boostQueryElem==null)
-		{
-			throw new ParserException("BoostingQuery missing a \"BoostQuery\" child element");
-		}
-		boostQueryElem=DOMUtils.getFirstChildElement(boostQueryElem);
-		if(boostQueryElem==null)
-		{
-			throw new ParserException("BoostingQuery \"BoostQuery\" element missing a child element");
-		}
-		Query boostQuery=factory.getQuery(boostQueryElem);
-		
-		BoostingQuery bq = new BoostingQuery(mainQuery,boostQuery,boost);
-		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+ 		Element boostQueryElem=DOMUtils.getChildByTagOrFail(e,"BoostQuery");
+  		float boost=DOMUtils.getAttribute(boostQueryElem,"boost",defaultBoost);
+ 		boostQueryElem=DOMUtils.getFirstChildOrFail(boostQueryElem);
+  		Query boostQuery=factory.getQuery(boostQueryElem);
+  		
+  		BoostingQuery bq = new BoostingQuery(mainQuery,boostQuery,boost);
+
+  		bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
 		return bq;
 
 	}

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/ConstantScoreQueryBuilder.java
Wed Mar  1 13:49:17 2006
@@ -19,14 +19,13 @@
 
 	public Query getQuery(Element e) throws ParserException
 	{
-		Element filterElem=DOMUtils.getFirstChildElement(e);
-		if(filterElem==null)
-		{
-			throw new ParserException("ConstantScoreQuery missing child element with filter");
-		}
-		Query q=new ConstantScoreQuery(filterFactory.getFilter(filterElem));
-		q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-		return q;
+ 		Element filterElem=DOMUtils.getFirstChildOrFail(e);
+  		Query q=new ConstantScoreQuery(filterFactory.getFilter(filterElem));
+
+  		q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+
+  		return q;
+		
 	}
 
 }

Added: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/FilteredQueryBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/FilteredQueryBuilder.java?rev=382170&view=auto
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/FilteredQueryBuilder.java
(added)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/FilteredQueryBuilder.java
Wed Mar  1 13:49:17 2006
@@ -0,0 +1,48 @@
+/*
+ * Created on 25-Jan-2006
+ */
+package org.apache.lucene.xmlparser.builders;
+
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.FilteredQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.xmlparser.DOMUtils;
+import org.apache.lucene.xmlparser.FilterBuilder;
+import org.apache.lucene.xmlparser.ParserException;
+import org.apache.lucene.xmlparser.QueryBuilder;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author maharwood
+ */
+public class FilteredQueryBuilder implements QueryBuilder {
+	
+	private FilterBuilder filterFactory;
+	private QueryBuilder queryFactory;
+
+	public FilteredQueryBuilder(FilterBuilder filterFactory, QueryBuilder queryFactory)
+	{
+		this.filterFactory=filterFactory;
+		this.queryFactory=queryFactory;
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.lucene.xmlparser.QueryObjectBuilder#process(org.w3c.dom.Element)
+	 */
+	public Query getQuery(Element e) throws ParserException {	
+ 	    Element filterElement=DOMUtils.getChildByTagOrFail(e,"Filter");
+ 	    filterElement=DOMUtils.getFirstChildOrFail(filterElement);
+ 	    Filter f=filterFactory.getFilter(filterElement);
+ 
+ 	    Element queryElement=DOMUtils.getChildByTagOrFail(e,"Query");
+ 	    queryElement=DOMUtils.getFirstChildOrFail(queryElement);
+ 	    Query q=queryFactory.getQuery(queryElement);
+ 	    
+ 	    FilteredQuery fq = new FilteredQuery(q,f);
+ 	    fq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+ 	    return fq;		
+	}
+
+}

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNearBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNearBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNearBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNearBuilder.java
Wed Mar  1 13:49:17 2006
@@ -19,12 +19,8 @@
 	
 	public SpanQuery getSpanQuery(Element e) throws ParserException
 	{
-		String slopString=e.getAttribute("slop");
-		if((slopString==null)||(slopString.length()==0))
-		{
-			throw new ParserException("SpanTermQuery missing slop property ");			
-		}
-		int slop=Integer.parseInt(slopString);
+ 		String slopString=DOMUtils.getAttributeOrFail(e,"slop");
+  		int slop=Integer.parseInt(slopString);
 		boolean inOrder=DOMUtils.getAttribute(e,"inOrder",false);
 		ArrayList spans=new ArrayList();
 		for (Node kid = e.getFirstChild(); kid != null; kid = kid.getNextSibling())

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNotBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNotBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNotBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanNotBuilder.java
Wed Mar  1 13:49:17 2006
@@ -21,26 +21,14 @@
     }
 	public SpanQuery getSpanQuery(Element e) throws ParserException
 	{
-	    Element includeElem=DOMUtils.getChildByTagName(e,"Include");
-	    if(includeElem!=null)
-		{
-	        includeElem=DOMUtils.getFirstChildElement(includeElem);
-		}
-	    if(includeElem==null)
-	    {
-			throw new ParserException("SpanNotQuery missing Include child Element");	        
-	    }
-	    Element excludeElem=DOMUtils.getChildByTagName(e,"Exclude");
-	    if(excludeElem!=null)
-		{
-	        excludeElem=DOMUtils.getFirstChildElement(excludeElem);
-		}
-	    if(excludeElem==null)
-	    {
-			throw new ParserException("SpanNotQuery missing Exclude child Element");	        
-	    }
-	    SpanQuery include=factory.getSpanQuery(includeElem);
-	    SpanQuery exclude=factory.getSpanQuery(excludeElem);
+  	    Element includeElem=DOMUtils.getChildByTagOrFail(e,"Include");
+        includeElem=DOMUtils.getFirstChildOrFail(includeElem);
+
+  	    Element excludeElem=DOMUtils.getChildByTagOrFail(e,"Exclude");
+        excludeElem=DOMUtils.getFirstChildOrFail(excludeElem);
+
+  	    SpanQuery include=factory.getSpanQuery(includeElem);
+  	    SpanQuery exclude=factory.getSpanQuery(excludeElem);
 	    
 		SpanNotQuery snq = new SpanNotQuery(include,exclude);
 		

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanOrTermsBuilder.java
Wed Mar  1 13:49:17 2006
@@ -30,13 +30,8 @@
     }
 	public SpanQuery getSpanQuery(Element e) throws ParserException
 	{
-		String fieldName=DOMUtils.getAttributeWithInheritance(e,"fieldName");
-		if(fieldName==null)
-		{
-			throw new ParserException("Error: SpanOrTermsBuilder missing \"fieldName\" property");
-		}
-
-		String value=DOMUtils.getText(e);
+ 		String fieldName=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
+ 		String value=DOMUtils.getNonBlankTextOrFail(e);
 		
 		try
 		{

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanTermBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanTermBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanTermBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/SpanTermBuilder.java
Wed Mar  1 13:49:17 2006
@@ -12,20 +12,13 @@
 
 	public SpanQuery getSpanQuery(Element e) throws ParserException
 	{
-		String fieldName=DOMUtils.getAttributeWithInheritance(e,"fieldName");
-		String value=DOMUtils.getText(e);
-		if((fieldName==null)||(fieldName.length()==0))
-		{
-			throw new ParserException("SpanTermQuery missing fieldName property ");
-		}
-		if((value==null)||(value.length()==0))
-		{
-			throw new ParserException("TermQuery missing value property ");
-		}
-		SpanTermQuery stq = new SpanTermQuery(new Term(fieldName,value));
+ 		String fieldName=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
+ 		String value=DOMUtils.getNonBlankTextOrFail(e);
+  		SpanTermQuery stq = new SpanTermQuery(new Term(fieldName,value));
+  		
+  		stq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+		return stq;		
 		
-		stq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-		return stq;
 	}
 
 }

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermQueryBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermQueryBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermQueryBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermQueryBuilder.java
Wed Mar  1 13:49:17 2006
@@ -18,20 +18,14 @@
 public class TermQueryBuilder implements QueryBuilder {
 
 	public Query getQuery(Element e) throws ParserException {
-		String field=DOMUtils.getAttributeWithInheritance(e,"fieldName");
-		String value=DOMUtils.getText(e);
-		if((field==null)||(field.length()==0))
-		{
-			throw new ParserException("TermQuery element missing fieldName attribute");
-		}
-		if((value==null)||(value.length()==0))
-		{
-			throw new ParserException("TermQuery element missing child text property ");
-		}
-		TermQuery tq = new TermQuery(new Term(field,value));
 		
-		tq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
-		return tq;
+        String field=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
+ 		String value=DOMUtils.getNonBlankTextOrFail(e);
+  		TermQuery tq = new TermQuery(new Term(field,value));
+  		tq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
+
+  		return tq;
+		
 	}
 
 }

Modified: lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java?rev=382170&r1=382169&r2=382170&view=diff
==============================================================================
--- lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java
(original)
+++ lucene/java/trunk/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/TermsFilterBuilder.java
Wed Mar  1 13:49:17 2006
@@ -42,15 +42,12 @@
 		NodeList nl = e.getElementsByTagName("Field");
 		for(int i=0;i<nl.getLength();i++)
 		{
-			Element fieldElem=(Element) nl.item(i);
-			String fieldName=DOMUtils.getAttributeWithInheritance(fieldElem,"fieldName");
 			
-			if(fieldName==null)
-			{
-				throw new ParserException("TermsFilter missing \"fieldName\" element");				
-			}
-			String text=DOMUtils.getText(fieldElem).trim();
-			TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
+  			Element fieldElem=(Element) nl.item(i);
+ 			String fieldName=DOMUtils.getAttributeWithInheritanceOrFail(fieldElem,"fieldName");
+ 			String text=DOMUtils.getNonBlankTextOrFail(fieldElem);
+  			TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
+			
 			try
 			{
 			Token token=ts.next();



Mime
View raw message