sax

Java XML Parsing: Avoid entity reference resolution

*爱你&永不变心* 提交于 2019-11-26 20:50:01
问题 I am currently parsing XHTML documents with a DOM parser, like: final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); final DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(MY_ENTITY_RESOLVER); db.setErrorHandler(MY_ERROR_HANDLER); ... final Document doc = db.parse(inputSource); And my problem is that when my document contains an entity reference like, for example: <p>€</p> My parser creates a Text node for that content

Java: How to display an XML file in a JTree

佐手、 提交于 2019-11-26 20:46:43
问题 I would like to have a way to display the contents of an XML file in a JTree . I have already accomplished this using DOM, by implementing a custom TreeModel (and TreeCellRenderer ). However it is very clunky (much workaround-ery and hackery) and rather rough around the edges. Is anyone aware of a way to get a JTree to display the contents of an XML file, parsed with SAX? Thanks! 回答1: Here's the code that I use. It is based on the API of Dom4J, but you can easily convert it to the APIs of

Efficient XSLT pipeline in Java (or redirecting Results to Sources)

夙愿已清 提交于 2019-11-26 19:37:21
问题 I have a series of XSL 2.0 stylesheets that feed into each other, i.e. the output of stylesheet A feeds B feeds C. What is the most efficient way of doing this? The question rephrased is: how can one efficiently route the output of one transformation into another. Here's my first attempt: @Override public void transform(Source data, Result out) throws TransformerException{ for(Transformer autobot : autobots){ if(autobots.indexOf(autobot) != (autobots.size()-1)){ log.debug("Transforming prelim

Python sax to lxml for 80+GB XML

雨燕双飞 提交于 2019-11-26 19:32:18
问题 How would you read an XML file using sax and convert it to a lxml etree.iterparse element? To provide an overview of the problem, I have built an XML ingestion tool using lxml for an XML feed that will range in the size of 25 - 500MB that needs ingestion on a bi-daily basis, but needs to perform a one time ingestion of a file that is 60 - 100GB's. I had chosen to use lxml based on the specifications that detailed a node would not exceed 4 -8 GB's in size which I thought would allow the node

When should I choose SAX over StAX?

爱⌒轻易说出口 提交于 2019-11-26 18:47:53
问题 Streaming xml-parsers like SAX and StAX are faster and more memory efficient than parsers building a tree-structure like DOM-parsers. SAX is a push parser, meaning that it's an instance of the observer pattern (also called listener pattern). SAX was there first, but then came StAX - a pull parser, meaning that it basically works like an iterator. You can find reasons why to prefer StAX over SAX everywhere, but it usually boils down to: "it's easier to use". In the Java tutorial on JAXP StAX

Parsing local XML file using Sax in Android

 ̄綄美尐妖づ 提交于 2019-11-26 17:43:50
问题 Can anyone tell me how to parse a local XML file stored in the system using SAX, with an example code? Please also tell me where can I find information on that. 回答1: To read from XML in your app, create a folder in your res folder inside your project called "xml" (lower case). Store your xml in this newly created folder. To load the XML from your resources, XmlResourceParser myxml = mContext.getResources().getXml(R.xml.MyXml);//MyXml.xml is name of our xml in newly created xml folder,

Can SAX Parsers use XPath in Java?

房东的猫 提交于 2019-11-26 14:31:51
问题 I'm trying to migrate one of my classes which uses DOM parsing with lots of XPath expressions to SAX parsing. DOM Parsing was good for me but some of the files i try to parse are too big and they cause server timeouts. I want to reuse the XPath with the SAX parsing but i'm not sure if it is possible and if not possible could you please help me because i have no idea how the following code will be when i use only SAX : Document doc = bpsXml.getDocument(); String supplierName = BPSXMLUtils

Parsing broken XML with lxml.etree.iterparse

江枫思渺然 提交于 2019-11-26 13:18:46
问题 I'm trying to parse a huge xml file with lxml in a memory efficient manner (ie streaming lazily from disk instead of loading the whole file in memory). Unfortunately, the file contains some bad ascii characters that break the default parser. The parser works if I set recover=True, but the iterparse method doesn't take the recover parameter or a custom parser object. Does anyone know how to use iterparse to parse broken xml? #this works, but loads the whole file into memory parser = lxml.etree

What are the differences between DOM, SAX and StAX XML parsers? [closed]

大兔子大兔子 提交于 2019-11-26 11:28:21
问题 I\'m developing a RSS feed aggregator with Apache Tomcat. I was wondering which parser to use in order to read RSS feeds. Should I use DOM, SAX or StAX? I know that there are libraries specific to read RSS feeds with java but since this is a university project I am not supposed to use those. Thank you. 回答1: It mostly depends on your needs. Each has it's own features. DOM - pull the whole thing into memory and walk around inside it. Good for comparatively small chunks of XML that you want to

IPWorks V6 &amp;&amp; Sax CommStudio Fall 2005 破解

江枫思渺然 提交于 2019-11-26 11:08:55
最近刚刚搞定 这两个,一并上去了。 需要的朋友可以研究一下。 【 IPWorks V6 】 【 Sax CommStudio Fall 2005 】 注意:不要用于商业开发 转载于:https://www.cnblogs.com/liuxzh1026/archive/2006/11/05/550525.html 来源: https://blog.csdn.net/weixin_30762087/article/details/98801160