Created
September 8, 2011 14:58
-
-
Save wardbekker/1203611 to your computer and use it in GitHub Desktop.
Handle the sax_event when a startElement is found with the name "row"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sax_event({startElement, [] , "row", [], Attributes}) -> | |
{_,_,_,_,StringId} = lists:keyfind( "Id", 2, Attributes ), | |
Id = erlang:list_to_integer(StringId), | |
AttributesDict = lists:foldl( | |
fun( {attribute, AttributeName,_,_,AttributeValue}, AccIn )-> | |
dict:store(AttributeName, AttributeValue, AccIn) | |
end, | |
dict:new(), | |
Attributes), | |
CompleteAttributesDict = case dict:is_key("Title", AttributesDict) of | |
true -> AttributesDict; | |
false -> dict:store( | |
"Title", "No title present", AttributesDict | |
) | |
end, | |
gen_server:cast( document_ser, { add_document, Id, CompleteAttributesDict }), | |
dict:map( | |
fun(AttributeName, AttributeValue)-> | |
add_attribute_tokens(Id, AttributeName, AttributeValue) | |
end, | |
CompleteAttributesDict | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment