Language

max-xml-size Sample

 

This example illustrates how to use the max-xml-size property to limit the size of the XML data that can be parsed by the SAX reader. The value of this property is specified in kilobytes. The default value is 0. A value of 0 means "unlimited". An error is reported if you try to load XML data that is larger than the size that is defined by this property.

Example

When you try to use the following JScript code to load data.xml, you receive the following error message:

Operation aborted: max-xml-size constraint violated.  

You receive the error message because data.xml is larger than 1 KB.

JScript File (testdata.js)

var saxReader = new ActiveXObject("Msxml2.SAXXMLReader.6.0");
//max-xml-size is defined as 1KB
saxReader.putProperty("max-xml-size", 1)
saxReader.parseURL("data.xml");

XML File (data.xml)

<?xml version='1.0'?>
<book-review>
   <book>
      <title>A Good Book</title>
      <author>The Good Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Good Day</date>
      <Review>
          <title>A Good Book</title> by <author>The Good Writer</author>, 
          published by <publisher>The Publisher</publisher> on <date>A 
          Good Day</date>, is indeed a good book.
      </Review>
   </book>
   <book>
      <title>A Bad Book</title>
      <author>The Bad Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Bad Day</date>
      <Review>
         <title>A Bad Book</title> by <author>The Bad Writer</author>, 
         published by <publisher>The Publisher</publisher> on <date>A Bad 
         Day</date>, is indeed a bad book.
      </Review>
   </book>
   <book>
      <title>A So-so Book</title>
      <author>The So-so Writer</author>
      <publisher>The Publisher</publisher>
      <date>A So-so Day</date>
      <Review>
         <title>A So-so Book</title> by <author>The So-so Writer</author>, 
         published by <publisher>The Publisher</publisher> on 
         <date>A So-so Day</date>, is indeed a so-so book.
      </Review>
   </book>
</book-review>

See Also

SAX2 Security