According to [erlang-bugs] xmerl and standard HTML entity refs, currently xmerl_scan only recognizes the very limited set of entity references. In brief, if you try to xmerl:scan xml text that includes standard HTML entity refs, such as nbsp, iexcl, pound, frac14, etc. you'll encounter something like:
16> edoc:file("exprecs.erl").
2670- fatal: {unknown_entity_ref,nbsp}
2580- fatal: error_scanning_entity_ref
exprecs.erl, in module header: at line 28: error in XML parser: {fatal,
{error_scanning_entity_ref,
{file,file_name_unknown},
{line,86},
{col,18}}}.
** exited: error **
Ulf Wiger said:
...
I realize that xmerl can be customized with a rules function which, for
example, can handle entity references...
So I take a try by writing a piece of code (html_entity_refs.erl) to parse a HTML entity ref DTD file to ets rules, then:
xmerl_scan:string(XmlText, [{rules, html_entity_refs:get_xmerl_rules()}]).
Yes, this works. But for a 3MB testing file, the parsing took about 30 seconds.
How about convert these entity refs to utf-8 chars first, then apply xmerl_scan to it?
I wrote another piece of code, and now:
xmerl_scan:string(html_entity_refs:decode_for_xml(XmlText)).
This time, the decoding+parsing time is about 5 seconds, it's 6 times faster than ets rules solution.
The html_entity_refs.erl can be got from:
http://caoyuan.googlecode.com/svn/trunk/erlang/html_entity_refs.erl
分享到:
相关推荐
ASP.NET MVC with Entity Framework and CSS by Lee Naylor 2016 | ISBN: 1484221362 | English | 608 pages | True PDF | 30 MB This book will teach readers how to build and deploy a fully working example ...
This book will teach readers how to build and deploy a fully working example retail website using Microsoft ASP.NET MVC and Entity Framework technologies and recommendations. This book contains ...
ASP.NET MVC with Entity Framework and CSS.pdf Apress Lee Naylor
ASP.NET MVC with Entity Framework and CSS pdf图书+源代码
ASP.NET MVC with Entity Framework and CSS Lee Naylor | 2016 | EPUB| ISBN: 1484221362 | 608 pages | This book will teach readers how to build and deploy a fully working example retail website using ...
A Joint Framework for Entity Discovery and Linking in Chinese Questions
ASP.NET MVC with Entity Framework and CSS 英文pdf 2016版
A comprehensive guide to the Entity Framework with insight into its latest features and optimizations for responsive data access in your projects About This Book Create Entity data models from your ...
Entity Framework 4.0 and ASP.NET Web Forms to create web application step by step.
Data access is an integral part of any ... You'll learn how to retrieve data by querying the Entity Data Model and understand how to use LINQ to Entities and Entity SQL to query the Entity Data Model.
arXiv:1803.04035v2 [cs.DB] 20 Mar 2018Entity Resolution and Federated Learning g
This book will provide .NET developers with this knowledge and guide them through working efficiently with data using Entity Framework Core. Key Features Learn how to use the new features of Entity...
这个资源是使用Entity Framework的时候方便查看Entity Framework生成的SQL语句用的工具,有了这个工具,才能方便的查找性能瓶颈。
Written by JuliaLerman, the leading independent authority on the framework,Programming Entity Framework covers it all -- from the Entity DataModel and Object Services to WCF Services, MVC Apps, and ...
Model, map, and access data effectively with Entity Framework Core 2, the latest evolution of Microsoft’s object-relational mapping framework that allows developers to access data using .NET objects,...
This book is a clear and concise guide to the ADO.NET Entity Framework. Packed with plentiful code examples, this book helps you to learn the ADO.NET Entity Framework and ADO.NET Data Services and ...
This book will provide .NET developers with this knowledge and guide them through working efficiently with data using Entity Framework Core. You will start off by learning how to efficiently use ...
Entity Framework 6 Recipes provides an exhaustive collection of ready-to-use code solutions for Entity Framework, Microsoft's model-centric, data-access platform for the .NET Framework and ASP.NET ...
Entity Framework 6 Recipes Entity Framework 6 Recipes