Skip to content

Instantly share code, notes, and snippets.

@wardbekker
Created September 8, 2011 14:58
Show Gist options
  • Save wardbekker/1203611 to your computer and use it in GitHub Desktop.
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"
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