Re: [xml] Bug #21194

Date view Thread view Subject view Author view

From: Kenneth Pronovici (pronovic@skyjammer.com)
Date: Wed Aug 23 2000 - 10:06:28 EDT


> Seems you didn't originally assigned it as to gnome-xml, so I didn't
> received it, an it only show up in the database now:

Yes, I goofed and put "gnome-xml (libxml)" in the pseudo-header, not
really realizing that the pseudo-header would be machine-parsed. Sorry.

> Something strange may have happened

Yes, I was wondering why they didn't show up in the archive, too.

> but those are not public,
> I assume you would like to make similar functions public, could you send
> me the patches again ?

I'll do that. This time, I've just stuck them in the body of this email
below my signature (maybe that will work better).

> Sure if the codde is okay it may be included in the next one.
> One just need to worry about the fact that extenal subsets must follow
> the given constraints:

I doubt I have taken all of that into account properly, but I can fix it
if you let me know what needs to be done. I'll let you look at the patches
and decide whether they're appropriate or just a quick hack that doesn't
fit with the way you want to organize things. If what I've written doesn't
match what you want to see, I'll rewrite it so it does.

Thanks for the help.

KEN

--
Kenneth J. Pronovici <pronovic@ieee.org>
Alliance of Computer Professionals (http://www.acpros.com/)
Personal Homepage: http://www.skyjammer.com/~pronovic/
Home: 763.546.0140, NWA: 612.726.0842
"Hell hath no fury like the weather when I'm camping..." 

patch for tree.h

613a614,616 > void xmlDocDumpMemoryWithDOCTYPE (xmlDocPtr cur, > xmlChar**mem, > int *size); 620a624,625 > int xmlSaveFileWithDOCTYPE (const char *filename, > xmlDocPtr cur);

patch for tree.c:

5443a5444,5703 > /* This section added by KJP 08/16/00 ******************************/ > /* > I needed the <!DOCTYPE> information printed in my XML documents > so that downstream subscribers could validate this XML against > an external DTD. This was not possible with the current > functionality, so I customized the functionality. > > Changes were based on the original implementations of the four > functions which do what I need but do not write the <!DOCTYPE> > tag. > > It seemed like a good idea to make four new functions rather than > to modify the existing ones, so functions not expecting this behavior > would not be harmed. > > Questions? Please write <pronovic@ieee.org>. > */ > > /** > * xmlDocContentDumpOutputWithDOCTYPE: > * @buf: the XML buffer output > * @cur: the document > * @encoding: an optional encoding string > * > * Dump an XML document. If an extSubset (i.e. DTD) is associated with > * the document, and the name and ExternalID are filled in, will print > * the appropriate <!DOCTYPE> header after the <?xml version> line. > */ > static void > xmlDocContentDumpOutputWithDOCTYPE(xmlOutputBufferPtr buf, xmlDocPtr cur, > const char *encoding) { > xmlOutputBufferWriteString(buf, "<?xml version="); > if (cur->version != NULL) > xmlBufferWriteQuotedString(buf->buffer, cur->version); > else > xmlOutputBufferWriteString(buf, "\"1.0\""); > if (encoding == NULL) { > if (cur->encoding != NULL) > encoding = (const char *) cur->encoding; > else if (cur->charset != XML_CHAR_ENCODING_UTF8) > encoding = xmlGetCharEncodingName((xmlCharEncoding) cur->charset); > } > if (encoding != NULL) { > xmlOutputBufferWriteString(buf, " encoding="); > xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding); > } > switch (cur->standalone) { > case 0: > xmlOutputBufferWriteString(buf, " standalone=\"no\""); > break; > case 1: > xmlOutputBufferWriteString(buf, " standalone=\"yes\""); > break; > } > > /* Modified by KJP 08/16/2000 ********************************/ > /*{*/ > if(cur->extSubset != NULL) > { > > xmlOutputBufferWriteString(buf, "?>\n"); > > if(xmlStrlen(cur->extSubset->name) != 0 && xmlStrlen(cur->extSubset->ExternalID) != 0) > { > if (encoding == NULL) > { > if (cur->encoding != NULL) > encoding = (const char *) cur->encoding; > else if (cur->charset != XML_CHAR_ENCODING_UTF8) > encoding = xmlGetCharEncodingName((xmlCharEncoding) cur->charset); > } > > xmlOutputBufferWriteString(buf, "<!DOCTYPE "); > xmlOutputBufferWriteString(buf, cur->extSubset->name); > xmlOutputBufferWriteString(buf, " SYSTEM "); > xmlBufferWriteQuotedString(buf->buffer, (xmlChar *)cur->extSubset->ExternalID); > xmlOutputBufferWriteString(buf, ">"); > > xmlOutputBufferWriteString(buf, "\n"); > } > } > else > { > xmlOutputBufferWriteString(buf, "?>\n"); > } > /*}*/ > /* End modified by KJP 08/16/2000 **************************/ > > if (cur->children != NULL) { > xmlNodePtr child = cur->children; > > /* global namespace definitions, the old way */ > if (oldXMLWDcompatibility) > xmlGlobalNsListDumpOutput(buf, cur->oldNs); > else > xmlUpgradeOldNs(cur); > > while (child != NULL) { > xmlNodeDumpOutput(buf, cur, child, 0, 1, encoding); > xmlOutputBufferWriteString(buf, "\n"); > child = child->next; > } > } > } > > /** > * xmlSaveFileWithDOCTYPE: > * @filename: the filename (or URL) > * @cur: the document > * > * Dump an XML document to a file. Will use compression if > * compiled in and enabled. If @filename is "-" the stdout file is > * used. If an extSubset (i.e. DTD) is associated with the document, > * and the name and ExternalID are filled in, will print the appropriate > * <!DOCTYPE> header after the <?xml version> line. > * returns: the number of byte written or -1 in case of failure. > */ > int > xmlSaveFileWithDOCTYPE(const char *filename, xmlDocPtr cur) { > xmlOutputBufferPtr buf; > const char *encoding; > xmlCharEncodingHandlerPtr handler = NULL; > int ret; > > if (cur == NULL) > return(-1); > encoding = (const char *) cur->encoding; > > /* > * save the content to a temp buffer. > */ > #ifdef HAVE_ZLIB_H > if (cur->compression < 0) cur->compression = xmlCompressMode; > #endif > if (encoding != NULL) { > xmlCharEncoding enc; > > enc = xmlParseCharEncoding(encoding); > > if (cur->charset != XML_CHAR_ENCODING_UTF8) { > fprintf(stderr, "xmlSaveFile: document not in UTF8\n"); > return(-1); > } > if (enc != XML_CHAR_ENCODING_UTF8) { > handler = xmlFindCharEncodingHandler(encoding); > if (handler == NULL) { > xmlFree((char *) cur->encoding); > cur->encoding = NULL; > } > } > } > > buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression); > if (buf == NULL) return(0); > > xmlDocContentDumpOutputWithDOCTYPE(buf, cur, NULL); > > ret = xmlOutputBufferClose(buf); > return(ret); > } > > /** > * xmlDocContentDumpWithDOCTYPE: > * @buf: the XML buffer output > * @cur: the document > * > * Dump an XML document. > */ > static void > xmlDocContentDumpWithDOCTYPE(xmlBufferPtr buf, xmlDocPtr cur) { > xmlBufferWriteChar(buf, "<?xml version="); > if (cur->version != NULL) > xmlBufferWriteQuotedString(buf, cur->version); > else > xmlBufferWriteChar(buf, "\"1.0\""); > if (cur->encoding != NULL) { > xmlBufferWriteChar(buf, " encoding="); > xmlBufferWriteQuotedString(buf, cur->encoding); > } > switch (cur->standalone) { > case 0: > xmlBufferWriteChar(buf, " standalone=\"no\""); > break; > case 1: > xmlBufferWriteChar(buf, " standalone=\"yes\""); > break; > } > > /* Modified by KJP 08/17/2000 ********************************/ > /*{*/ > if(cur->extSubset != NULL) > { > xmlBufferWriteChar(buf, "?>\n"); > if(xmlStrlen(cur->extSubset->name) != 0 && xmlStrlen(cur->extSubset->ExternalID) != 0) > { > xmlBufferWriteChar(buf, "<!DOCTYPE "); > xmlBufferWriteChar(buf, cur->extSubset->name); > xmlBufferWriteChar(buf, " SYSTEM "); > xmlBufferWriteQuotedString(buf, (xmlChar *)cur->extSubset->ExternalID); > xmlBufferWriteChar(buf, ">"); > xmlBufferWriteChar(buf, "\n"); > } > } > else > { > xmlBufferWriteChar(buf, "?>\n"); > } > /*}*/ > /* End modified by KJP 08/17/2000 **************************/ > > if (cur->children != NULL) { > xmlNodePtr child = cur->children; > > /* global namespace definitions, the old way */ > if (oldXMLWDcompatibility) > xmlGlobalNsListDump(buf, cur->oldNs); > else > xmlUpgradeOldNs(cur); > > while (child != NULL) { > xmlNodeDump(buf, cur, child, 0, 1); > xmlBufferWriteChar(buf, "\n"); > child = child->next; > } > } > } > > /** > * xmlDocDumpMemoryWithDOCTYPE: > * @cur: the document > * @mem: OUT: the memory pointer > * @size: OUT: the memory lenght > * > * Dump an XML document in memory and return the xmlChar * and it's size. > * It's up to the caller to free the memory. > */ > void > xmlDocDumpMemoryWithDOCTYPE(xmlDocPtr cur, xmlChar**mem, int *size) { > xmlBufferPtr buf; > > if (cur == NULL) { > #ifdef DEBUG_TREE > fprintf(stderr, "xmlDocDumpMemoryWithDOCTYPE : document == NULL\n"); > #endif > *mem = NULL; > *size = 0; > return; > } > buf = xmlBufferCreate(); > if (buf == NULL) { > *mem = NULL; > *size = 0; > return; > } > xmlDocContentDumpWithDOCTYPE(buf, cur); > *mem = xmlStrndup(buf->content, buf->use); > *size = buf->use; > xmlBufferFree(buf); > } >

---- Message from the list xml@xmlsoft.org Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 23 2000 - 09:43:16 EDT