From bf6b63d2a72d37bee0248e5a2c39d933454d617a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 8 Mar 2013 15:32:48 +0200 Subject: Add support for writing XML declaration --- genx.c | 37 +++++++++++++++++++++++++++++++++++++ genx.h | 8 ++++++++ 2 files changed, 45 insertions(+) diff --git a/genx.c b/genx.c index 4a002da..dfee0df 100644 --- a/genx.c +++ b/genx.c @@ -2098,6 +2098,43 @@ genxStatus genxEndDocument(genxWriter w) return GENX_SUCCESS; } +genxStatus genxXmlDeclaration(genxWriter w, + constUtf8 ver, + constUtf8 enc, + constUtf8 stl) +{ + if (w->sequence != SEQUENCE_PRE_DOC) + return w->status = GENX_SEQUENCE_ERROR; + + if ((w->status = genxCheckText(w, ver)) != GENX_SUCCESS) + return w->status; + + if (enc != NULL && (w->status = genxCheckText(w, enc)) != GENX_SUCCESS) + return w->status; + + if (stl != NULL && (w->status = genxCheckText(w, stl)) != GENX_SUCCESS) + return w->status; + + SendCheck (w, "\n"); + + return GENX_SUCCESS; +} + genxStatus genxComment(genxWriter w, constUtf8 text) { int i; diff --git a/genx.h b/genx.h index 0d4fd48..d41c4d0 100644 --- a/genx.h +++ b/genx.h @@ -195,6 +195,14 @@ genxStatus genxStartDocSender(genxWriter w, genxSender * sender); genxStatus genxEndDocument(genxWriter w); /* + * Write XML declaration. If encoding or standalone are NULL, then those + * attributes are omitted. + */ +genxStatus genxXmlDeclaration(genxWriter w, + constUtf8 version, + constUtf8 encoding, + constUtf8 standalone); +/* * Write a comment */ genxStatus genxComment(genxWriter w, constUtf8 text); -- cgit v1.1