[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Genx


genx 6.0

----- Original Message ----- 
From: "Toni Uusitalo" <toni.uusitalo@p...>

> I vote for abstract "streaming writer" callback, no FILE* streams but 
> something like:
> 
> typedef int (*PFNOUTPUTCALLBACK)(void *UserData, utf8Byte *buf, int cBytes, 
> int *cBytesWritten);

I agree. I have actually implemented an XML writer API in Delphi,
initially modelled after the one available in .NET, and I also
decided to use an (abstract) IWriter interface for the target,
as it allows you to plug in various output targets, like streams
or encoding transformers.

Btw, instead of void *UserData, maybe one registers an opaque
WriterTarget pointer, using something like:

  void genxSetWriterTarget(genxWriter w, const void * writertarget); 

One should have, IMO, additional calls, to enable the target to deal
with at least the start and end of the document. For instance, some
encoding transformer need to write a prolog (UTF-16 BOM) or maybe even an epilog.

The IWriter interface I used has these methods:
- Reset
- Close
- Write
- Flush
- State  // returns current state, one of Initialized, Open, Closing, Closed

However, the XML writer needs to deal with Write and Close only,
since the start of the document can be inferred when Write is called
on a "Closed" writer target. I believe, the rest is up to the application.

For your call-back above this could be done with adding a boolean
flag isLast to the parameters (indicating the last buffer).
One could also add a separate call-back instead.

> You could also wrap for example gnu libiconv calls in this callback to 
> output in different encoding than UTF-8/16
> (of course you have to work with UTF-8/wchar internally for name char 
> checking etc.). There could
> be FILE* stream callback and maybe libiconv callback provided "in the box" 
> for genx?

Exactly.

Karl

  • Follow-Ups:
    • Re: Genx
      • From: Toni Uusitalo <toni.uusitalo@p...>
  • References:
    • Genx
      • From: Tim Bray <tbray@t...>
    • Re: Genx
      • From: Toni Uusitalo <toni.uusitalo@p...>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.