summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-09 15:03:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-09 15:03:00 +0200
commit39f7ac4cb5e436820a2023761aaf4ef8a43a5054 (patch)
tree148a970257341cde82b377cff51421e0148a361f
parente01831ddeb7194118b50737fd5a7a6c68d1c2a47 (diff)
Add support for DOCTYPE declaration
-rw-r--r--genx.c52
-rw-r--r--genx.h13
2 files changed, 65 insertions, 0 deletions
diff --git a/genx.c b/genx.c
index 3b2f905..9848a63 100644
--- a/genx.c
+++ b/genx.c
@@ -2143,6 +2143,58 @@ genxStatus genxXmlDeclaration(genxWriter w,
return GENX_SUCCESS;
}
+genxStatus genxDoctypeDeclaration(genxWriter w,
+ constUtf8 re,
+ constUtf8 pi,
+ constUtf8 si,
+ constUtf8 is)
+{
+ if (w->sequence != SEQUENCE_PRE_DOC)
+ return w->status = GENX_SEQUENCE_ERROR;
+
+ if ((w->status = genxCheckText(w, re)) != GENX_SUCCESS)
+ return w->status;
+
+ if (pi != NULL && (w->status = genxCheckText(w, pi)) != GENX_SUCCESS)
+ return w->status;
+
+ if (si != NULL && (w->status = genxCheckText(w, si)) != GENX_SUCCESS)
+ return w->status;
+
+ if (is != NULL && (w->status = genxCheckText(w, is)) != GENX_SUCCESS)
+ return w->status;
+
+ SendCheck (w, "<!DOCTYPE ");
+ SendCheck (w, re);
+
+ if (pi != NULL)
+ {
+ SendCheck (w, " PUBLIC\n \"");
+ SendCheck (w, pi);
+ SendCheck (w, "\"");
+ }
+
+ if (si != NULL)
+ {
+ if (pi == NULL)
+ SendCheck (w, " SYSTEM");
+
+ SendCheck (w, "\n \"");
+ SendCheck (w, si);
+ SendCheck (w, "\"");
+ }
+
+ if (is != NULL)
+ {
+ SendCheck (w, " [\n");
+ SendCheck (w, is);
+ SendCheck (w, "\n]");
+ }
+
+ SendCheck (w, ">\n");
+ return GENX_SUCCESS;
+}
+
genxStatus genxComment(genxWriter w, constUtf8 text)
{
size_t i;
diff --git a/genx.h b/genx.h
index bdaeee1..e55b467 100644
--- a/genx.h
+++ b/genx.h
@@ -205,6 +205,19 @@ genxStatus genxXmlDeclaration(genxWriter w,
constUtf8 encoding,
constUtf8 standalone);
/*
+ * Write DOCTYPE declaration. If public_id is not NULL, then this is
+ * a PUBLIC DOCTYPE declaration, otherwise, if system_id is not NULL,
+ * then this is a SYSTEM DOCTYPE. If both are NULL, then a DOCTYPE
+ * that only contains the root element and, if not NULL, internal
+ * subset is written.
+ */
+genxStatus genxDoctypeDeclaration(genxWriter w,
+ constUtf8 root_element,
+ constUtf8 public_id,
+ constUtf8 system_id,
+ constUtf8 internal_subset);
+
+/*
* Write a comment
*/
genxStatus genxComment(genxWriter w, constUtf8 text);