sax

How to convert from parsing with Dom to parsing with SAX

I'm parsing an XML document into my own structure using DOM, but in another question I was advised to use SAX, how would I convert the following: public static DomTree<String> createTreeInstance(String path) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory docBuilderFactory = DocumentBuilde...

Using XML parser implementation as OSGi service

Hello, I am developing an application using OSGi (Equinox platform), and one of the bundles needs to parse XML files. So far I implemented this with SAX (javax.xml.parsers.SAXParserFactory) and I would like to retrieve the SAXParserFactory from the platform. I saw the OSGi standard provides for a XMLParserActivator to allow JAXP implem...

Really simple command line SAX parser for XML files

I've used xmlstartlet to process XML files before. You can give it a simple comannd line and it will generate (internally) an XSLT template and apply that to an XML file. However now I have a large XML file, so I really need to use SAX for this, not XSLT. Rather than write a simple programme to do this, I'm wondering if there is a more ...

Java - SAX parser on a XHTML document

Hey, I'm trying to write a SAX parser for an XHTML document that I download from the web. At first I was having a problem with the doctype declaration (I found out from here that it was because W3C have intentionally blocked access to the DTD), but I fixed that with: XMLReader reader = parser.getXMLReader(); reader.setFeature("http://...

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

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, ...

How do I use XML::LibXML to parse XML using SAX?

The only example code I have found so far is so old it won't work anymore (uses deprecated classes). All I need is something basic that demonstrates: Loading and parsing the XML from a file Defining the SAX event handler(s) Reading the attributes or text values of the element passed to the event handler ...

SAX Code Efficiency

I have a relatively general question regarding SAX. I understand how it works, and based on tutorials I've read, I've learned to keep the state by having a ton of data members like inNode that are booleans and then in each event handler, check each boolean and handle the parameters accordingly. To me, this seems really inefficient, is ...

How to stop parsing xml document with SAX at any time?

I parse a big xml document with Sax, I want to stop parsing the document when some condition establish? How to do? ...

SAX parser in java

can SAX parser handle self closing tag? or will it cause an error? eg <br/> or <hr/> ...

How do I get libxml2's SAX2 interface to let me see &lt; et al?

I have some code using libxml2's SAX2 interface. I want to be able to see < type entities as entity references and not as characters but it appears that no matter what I do, libxml2 will turn &lt; into a < and then hand it to my characters callback instead of calling my reference callback. Any ideas as to how I can force libxml2 to cal...

XML Parser for Ruby

Looking for something similar to xerces for parsing an xml file in ruby. I saw the native processor REXML and another called hpricot (though I can't find any documentation on hpricot, the links all appear to be dead). I'm looking for something that would parse an xml document via SAX2 in ruby. TIA. ...

Using cocoa how do I get SAX to distinguish endElements in XML when they are the same ?

From the XML below I'm trying to retrieve the second element in the sequence. Notice the end node is the same as the start in each entry, this is making its retrieval a bit tricky. I've tried setting a for loop at the startElementSAX function to evaluate and pick-up the Width="60" attribute. Although this will sort the data correctly i...

Jumping between XML tags

Hi, This is a doubt in SAX. I want to process the children tags in a XML file,only if it matches the parent tag. For ex: <version> <parent tag-1> <tag 1> <tag 2> </parent tag-1 > <parent tag-2> <tag 1> <tag 2> </parent tag-2> </version> In the above code, I want to match the parent tag f...

getting more informations from sax validator

Can i get for example the node structure or something like this from the validator? Something like a listener or an handler. The exception is not enough. I have to select the node where the error occured. Thats what i build so far. def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) def schema = factory.newSchema...

Umlaut in Java SAX Parser

Hello everybody! I am currently having trouble with German umlaut values in a XML document I received. It displays / saves the value as a "ü" instead of a "ü". The XML Encoding is set to UTF-8 which should be capable of displaying umlauts. Also I couldn't find any option to set a locale on the SAX parser. Is there any other way I c...

Poco C++ SAX parser: how to get element "inner text"?

I've been going over the Poco SAX parser header files a few times but I can't seem to find any info on how to obtain an element's inner text. For example: <description>This is the inner text.</description> Can anyone point me in the right direction? ...

Schema validation, how to display user friendly validation messages?

Hello all , Is there a way to avoid or set up a schema to display better user friendly messages? I am parsing the string and using reg ex to interpret them, but there might be a better way. Ex. "cvc-complex-type.2.4.b: The content of element 'node' is not complete. One of '{\"\":offer,\"\":links}' is expected." Instead I want:...

Programmatically creating an XML Document using an XSD

Hi I need to create XML documents using built-in java org.w3c.dom or jdom packages conforming to a set of XSD files. The XSD files are similar but not the same. In essence, I need to create the XML file as per the XSD given to me dynamically. What is the best way to do it. I have checked the Validator package, it does not have any fea...

python sax: is there a way to halt the parsing from inside a content handler?

Is there a way to halt the parsing from inside a content handler? Or is throwing an exception the only way? Note that I am using xml.sax.parseString. ...

How to validate XML using SAX?

How do the SAX API-s validate XML against a schema/DTD? My understanding is the SAX API-s read an XML doc chuck by chunk and do not store the previously read chunks in memory. So I'm not clear how the API could validate the doc without keeping it all in memory. ?? ...