[xsd-users] Calculating progress on "xsd-parser" parsed files

David White dawhite32 at gmail.com
Thu Mar 26 19:45:25 EDT 2009


Excellent!  I cannot think of one reason why I would want to use any
other XML binding software!

Keep up the good work on this great project. David.


On Thu, Mar 26, 2009 at 9:10 PM, Boris Kolpackov
<boris at codesynthesis.com> wrote:
> Hi David,
>
> David White <dawhite32 at gmail.com> writes:
>
>> Is it possible to get an indication of conversion process with
>> xsd / xerces?
>
> There is no built-in support for this though it is relatively
> easy to do. There are also several ways you can do it. You can
> use the underlying SAX2 parser's (SAX2XMLReader) getSrcOffset()
> function along with the total file length to determine the
> progress. Or you can use the file stream position to get the
> same information. In either case the overall structure of the
> code will be the same. You probably have a top-level parser
> with one of its callbacks being called periodically as parsing
> progresses. Something along these lines:
>
> <complexType name="root">
>  <sequence>
>    <element name="record" maxOccurs="unbounded">
>
>      ...
>
>    </element>
>  </sequence>
> </complexType>
>
> <element name="root" type="root"/>
>
> You can pass the file stream or SAX2 parser reference to the
> parser for this top-level type and then calculate the progress
> each time the callback is called, something along these lines:
>
> struct root_pimpl: root_pskel
> {
>  root_pimpl (std::ifstream& is, size_t size)
>    : is_ (is), size_ (size)
>  {
>  }
>
>  virtual void
>  record (...)
>  {
>    // Callculate the progress.
>    //
>    size_t cur = is_.tellg ();
>    ...
>  }
>
> private:
>  std::ifstream& is_;
>  size size_;
> };
>
> int
> main ()
> {
>  ifstream ifs;
>  ifs.exceptions (ios_base::failbit);
>  ifs.open (file, ios::in | ios::ate);
>  size_t size (ifs.tellg ());
>  ifs.seekg (0, ios::beg);
>
>  root_pimpl root_p (ifs, size);
>
>  ...
>
>  xml_schema::document doc (root_p, "root");
>
>  ...
> }
>
> Boris
>




More information about the xsd-users mailing list