sax

How to select saxon TransformerFactory in Java

In my web application I need to use Saxon TransformerFactory to use XSLT 2.0 but I can't use setProperty method because I haven't this right on the web server and there is a Security Manager. So i have read that it's possible to do this: Use the Services API (as detailed in the JAR specification), if available, to determine the clas...

How to tell Java SAX Parser to ignore invalid character references?

When trying to parse incorrect XML with a character reference such as &#x1, Java's SAX Parser dies a horrible death with a fatal error such as org.xml.sax.SAXParseException: Character reference "&#x1" is an invalid XML character. Is there any way around this? Will I have to clean up the XML file ...

Return an object after parsing xml with SAX

I have some large XML files to parse and have created an object class to contain my relevant data. Unfortunately, I am unsure how to return the object for later processing. Right now I pickle my data and moments later depickle the object for access. This seems wasteful, and there surely must be a way of grabbing my data without hittin...

Android: Sax: IO exception on device but in emulator running fine

Hi i run the following program in my emulator and got my desired output. MyHandler handler=new MyHandler(); XMLReader xr = parser.getXMLReader(); xr.setContentHandler(handler); xr.parse(new InputSource(XML_FILE_URL)); tv.setText(handler.getParsedData()); But when i run it on my device (HTC my touch s...

Is XMLReader a SAX parser, a DOM parser, or neither?

I am testing various methods to read (possibly large, and very often) XML configuration files in PHP. No writing is ever needed. I have two successful implementations, one using SimpleXML (which I know is a DOM parser) and one using XMLReader. I know that a DOM reader must read the whole tree and therefore uses more memory. My tests ...

libxml2 SAX query

I am trying to parse an XML file using the SAX interface of libxml2 in C. My problem is that whitespace characters between end of a tag and start of a new tag are causing the callback "Characters" to be executed...Hi All, i.e. <?xml version="1.0"?> <doc> <para>Hello, world!</para> </doc> produces these events: ...

creating and adding a new child element to an xml document using the SAX interface of libxml2

Hello everyone. My problem is that I need to parse an HTML document chunk by chunk and add a comment in the head element of the document. I am using C and I found that libxml2 is the best library out there for this purpose. As I am receiving only chunks of data at a time I thought using a SAX parser would be a better option. Howeve...

Java SAX parser progress monitoring

I'm writing a SAX parser in Java to parse a 2.5GB XML file of wikipedia articles. Is there a way to monitor the progress of the parsing in Java? ...

Streaming SAX XML Processing on iPhone

NSXMLParser allows SAX parsing of either an NSData block or from a URL source. The problem is that both these methods require the entire XML source to be known before parsing begins. Suppose I have a stream of XML Data (say a sequence of NSData objects) and I want to process the stream using NSXMLParser or another cocoa class, how can ...

Is there a fast XML parser in Python that allows me to get start of tag as byte offset in stream?

I am working with potentially huge XML files containing complex trace information from on of my projects. I would like to build indexes for those XML files so that one can quickly find sub sections of the XML document without having to load it all into memory. If I have created a "shelve" index that could contains information like "boo...

SAX parsing in android

Hello! I have xml file that looks like this: <ns:retrieveLastResponse> <ns:return xsi:type="ax21:MinusEntry"> <ax21:entrydate>2010-07-02T17:29:35.492+02:00</ax21:entrydate> <ax21:minus>true</ax21:minus> <ax21:password>SECRET</ax21:password> <ax21:text>Some text</ax21:text> <ax21:username>John Doe</ax21:username> </ns:return> <...

Can't add a value to ArrayList because it's in an Inner Class?

I am writing a file that can parse rdf and owl files. I am using SAX and Java. My problem is on the line activeObject.add(file); I get the error "Syntax error on tokens, Misplaced construct(s)" - I don't know what this means. And it doesn't seem to make sense, any help would be much appreciated. PS: I might be completely wrong about w...

Incorrect SAXParseException for pattern check

I am getting this SAXParseException which seems inherently wrong [org.xml.sax.SAXParseException: cvc-pattern-valid: Value 'ARC1350000114' is not facet-valid with respect to pattern '[a-z,A-Z]{3}[0-9]{10}' for type 'OrderId'.] The problem seems to disappear after a restart. This ghostly nature of the problem makes me a bit nervous. Has...

Sax Parser: processingInstruction() not called

Hi, maybe this is a n00b-question. I try to parse an xml-file like that: <?xml version="1.0" encoding="UTF-8" ?> <test> <a></a> </test> with the following code: public static void parse(File f) { final DefaultHandler handler = new DefaultHandler() { @Override public void processingInstruction(String target, Str...

Using SAX (Java) to parse multiple XML messages from a single TCP-stream

I'm in a position where I use Java to connect to a TCP port and am streamed XML documents one after another, each delimited with the <?xml start of document tag. An example which demonstrates the format: <?xml version="1.0"?> <person> <name>Fred Bloggs</name> </person> <?xml version="1.0"?> <person> <name>Peter Jones</name> </p...

Trying to Understand Android's Sax Parser

I have used the Java Sax parser, but am trying to implement Android's with this XML. <?xml version="1.0" encoding="utf-8"?> <adc_database xmlns="http://www.weather.com"&gt; <units> <temp>F</temp> <dist>MI</dist> <speed>MPH</speed> <pres>IN</pres> <prec>IN</prec> </units> <local> <city>S...

Configure Xerces SAX parser to tolerate an XML syntax error

I am getting this error when parsing an incorrectly-generated XML document: org.xml.sax.SAXParseException: The value of attribute "bar" associated with an element type "foo" must not contain the '<' character. I know what is causing the problem. It is this line: <foo bar="x<y">42</foo> It should have been <foo bar="x&lt;y">42</fo...

Using SAX to run a transform on a node

Have an extended Java app which does a lot of modifications including merging xml files. This is done using dom classes and seems to work fine. In the end I want to format the resultant xml so that it is more easily read and store as a String. Started out doing this with dom also, but it puts a limit on the size of the files I can format...

Can SAX use a local resource XML file?

All of the android examples for XmlPullParser pull from a local resource file, and all of the SAX examples pull the XML from a URL. I've been told SAX is faster, so I'm trying to use that to pull data from a local resource file (res/xml/thefile.xml) The example code I'm working off of is here. So in that example, the code I want to chan...

SAXParser '&' concatenation problem

I am presently using SAXParser with SAXParserFactory, and I have run into a problem with strings being cuttoff at '&' symbols. For example: "Nation Created Our World & everything in it" becomes "everything in it". Obviously, I dont want this to happen. In the xml input, the character is properly escaped as &amp;. How can I resolve this...