summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-08 15:32:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-08 15:32:48 +0200
commitbf6b63d2a72d37bee0248e5a2c39d933454d617a (patch)
treef510fa717a598ad4bbc8ddf01759101b1eedbb63
parent217eb5fe08d902a87c313cbd3ee7f99b5f6fbf93 (diff)
Add support for writing XML declaration
-rw-r--r--genx.c37
-rw-r--r--genx.h8
2 files changed, 45 insertions, 0 deletions
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, "<?xml version=\"");
+ SendCheck (w, ver);
+
+ if (enc != NULL)
+ {
+ SendCheck (w, "\" encoding=\"");
+ SendCheck (w, enc);
+ }
+
+ if (stl != NULL)
+ {
+ SendCheck (w, "\" standalone=\"");
+ SendCheck (w, stl);
+ }
+
+ 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);