xml_safe_checker

XML safe checker

Usage no npm install needed!

<script type="module">
  import xmlSafeChecker from 'https://cdn.skypack.dev/xml_safe_checker';
</script>

README

XML safe checker


This stream module was written to avoid out of memory errors, when working with very large XML elements with 'saxpath' stream module or other ones. For XML safe checker module, we specify max. amount of bytes, that would be contained inside choosen element. XML safe checker is writtable stream type, which throws error when element's and it's subelement's size exceeds. This module, while runs, occupies very little memory.

Note

New functionality: you can check for many XML element names with one transversal of stream. This module is being frequently updated and newly found errors/bugs will be fixed as soon they are discovered.

Donate

My income consists of donations for my projects. If this module is useful to you, consider making a donation!

You can donate using PayPal or Wire transfer.

Usage with 'saxpath' module

With next code, 'saxpath' will retreve all XML elements, named 'book', that are contained inside root element 'books'.

var streamer = new saxpath.SaXPath(saxParser, '/books/book' );

If you have other elements beside 'book' inside XML file, that are very large, there would be no problem with them. 'Saxpath' will simply skip them, stream's behaviour will be non-blocking and while skipping ones, not being 'book', will not use memory.

Problem could be, when there is 'book' element that is very large. Here out of memory error could be thrown. Here comes in play 'XML safe checker' module. Before running 'saxpath' stream, we check our XML file with 'XML safe checker' and if it doesn't throw error, we can safely use 'saxpath' afterwards.

Example

Please see 'example' subfolder, included with module.