sax

How to select saxon TransformerFactory in Java

三世轮回 提交于 2019-11-29 21:43:57
In my web application I need to use Saxon TransformerFactory in order to use XSLT 2.0 but I can't use setProperty method because I don't have this right on the web server and there is a Security Manager. So I have read that it should be possible to do this: Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.transform.TransformerFactory in jars available to the runtime. I found this file in WEB-INF/lib/saxon9.jar but when I istantiate a TransformerFactory, the

error in updating android sdk (org.xml.sax.SAXParseException)

老子叫甜甜 提交于 2019-11-29 16:27:53
There is a common problem in using android sdk manager but there isn't any solution for this problem all over the web even in the stackoverflow : for updating components of android sdk I write in the command prompt: C:\sdk\tools\bin>sdkmanager --list the erros that appear are these: Warning: Errors during XML parse: Warning: White spaces are required between publicId and systemId. Warning: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId. Warning: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax

How to use ESC () character in XML?

倖福魔咒の 提交于 2019-11-29 15:17:15
I'm trying this: <root> text: &#27; </root> But parser says: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 12; Character reference "&#27" is an invalid XML character. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) How to use it there? You cannot ( in XML 1.0) . In XML 1.1 there is a slightly larger range of characters you can use, and the characters are expressed differently , but even then, &#27; is 'restricted' (hex it is &#x1B;

Remove multiple nodes from an xml file using sax and java

大城市里の小女人 提交于 2019-11-29 15:15:09
问题 I am new to XML parsing using Java and SAX parser. I have a really big XML file and because of its size I have been advised to use SAX parser. I have finished parsing part of my tasks and it works as expected. Now, there is one task left with XML job: deleting/updating some nodes upon user's request. I am able to find all tags by their names, change their data attributes, etc. If I am able to do these with SAX, deleting also may be possible. Sample XML describes some functionality under some

SAXParseException: Content is not allowed in prolog

余生颓废 提交于 2019-11-29 13:44:51
I need to add the following file to my Tomcat's '/conf' directory: <?xml version="1.0" encoding="UTF-8"?> <Context useHttpOnly="false" path="/bbc"> <Realm className="com.bbc.tomcat.BBCSecurityRealm"/> </Context> After adding this file, I get the following error when Tomcat starts up" ERROR ecmdefault util.digester.Digester 18:37:14,477 localhost-startStop-1 : Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException

SAX解析XML

亡梦爱人 提交于 2019-11-29 12:55:09
一、使用SAX解析xml文件 新建一个类,继承之DefaultHandler: 示例代码如下: package org.demo.saxxml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class MyContentsHandler extends DefaultHandler { String Name,Sex; String tagName; String xmlContent=""; @Override //解析每个标签的时候调用的方法 public void characters(char[] ch, int start, int length) throws SAXException { if(tagName.equals("Name")){ Name=new String(ch,start,length); System.out.println(Name); }else if(tagName.equals("Sex")){ Sex=new String(ch,start,length); } super.characters(ch, start, length); } /

Keep numeric character entity characters such as `

` when parsing XML in Java

主宰稳场 提交于 2019-11-29 11:13:52
I am parsing XML that contains numeric character entity characters such as (but not limited to) < > (line feed carriage return < >) in Java. While parsing, I am appending text content of nodes to a StringBuffer to later write it out to a textfile. However, these unicode characters are resolved or transformed into newlines/whitespace when I write the String to a file or print it out. How can I keep the original numeric character entity characters symbols when iterating over nodes of an XML file in Java and storing the text content nodes to a String? Example of demo xml file: <?xml version=

OpenXML Sax method for exporting 100K+ rows to Excel fast

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:21:33
问题 I have been trying to improve the performance of the SAX method for writing to an xlsx. I know there is a limit of 1048576 rows in Excel. I have hit this limit only a few times. In most cases though I only write out about 125K to 250K rows (a large dataset). The code that I have tried doesn't seem to be as fast as it could be because of the many times it will write to the file. I would hope that there is some caching involved but it still seems like there is way too much disk access in the

SAX parsing - efficient way to get text nodes

笑着哭i 提交于 2019-11-29 10:09:28
问题 Given this XML snippet <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> In SAX, it is easy to get attribute values: @Override public void startElement (String uri, String localName, String qName, Attributes attributes) throws SAXException{ if(qName.equals("book")){ String bookId = attributes.getValue("id"); ... } } But to get the value of a text node, e.g. the value of the <author> tag, it is quite hard... private StringBuffer curCharValue = new

How to get element's value from XML using SAX parser in startElement?

落花浮王杯 提交于 2019-11-29 07:12:58
Is it possible to get the content of an element from a XML file in startElement function that is the override function of the SAX handler? Below is the specification. 1) XML file <employees> <employee id="111"> <firstName>Rakesh</firstName> <lastName>Mishra</lastName> <location>Bangalore</location> </employee> <employee id="112"> <firstName>John</firstName> <lastName>Davis</lastName> <location>Chennai</location> </employee> <employee id="113"> <firstName>Rajesh</firstName> <lastName>Sharma</lastName> <location>Pune</location> </employee> </employees> 2) startElement function @Override public