17 void dtd_cb(XBit bit,
void *arg);
26 int main(
int argc,
char **argv)
35 for(i = 1; i < argc; i++)
39 for(s = &argv[i][1]; *s; s++)
76 "usage: rxp [-abemnstvx] [-c encoding] [url]\n");
151 fprintf(stderr,
"unknown encoding %s\n",
enc_name);
163 fprintf(stderr,
"Input encoding %s, output encoding %s\n",
171 if(
source->entity->version_decl)
172 Printf(
" version=\"%s\"",
source->entity->version_decl);
177 Printf(
" encoding=\"%s\"",
181 Printf(
" encoding=\"%s\"",
185 Printf(
" standalone=\"%s\"",
234 for(i=0; i<bit->nchildren; i++)
244 const char *sys, *pub;
251 Printf(
"At %d: ", bit->byte_offset);
261 sys = pub =
"<none>";
262 if(p->dtd->external_part)
264 if(p->dtd->external_part->publicid)
265 pub = p->dtd->external_part->publicid;
266 if(p->dtd->external_part->systemid)
267 sys = p->dtd->external_part->systemid;
269 Printf(
"doctype: %S pubid %s sysid %s\n", p->dtd->name, pub, sys);
272 Printf(
"start: %S ", bit->element_definition->name);
277 Printf(
"empty: %S ", bit->element_definition->name);
282 Printf(
"end: %S\n", bit->element_definition->name);
285 Printf(
"pi: %S: ", bit->pi_name);
323 Printf(
"<!DOCTYPE %S", p->dtd->name);
324 if(p->dtd->external_part)
326 if(p->dtd->external_part->publicid)
327 Printf(
" PUBLIC \"%s\"", p->dtd->external_part->publicid);
328 else if(p->dtd->external_part->systemid)
330 if(p->dtd->external_part->systemid)
331 Printf(
" \"%s\"", p->dtd->external_part->systemid);
333 if(p->dtd->internal_part)
334 Printf(
" [%S]", p->dtd->internal_part->text);
339 Printf(
"<%S", bit->element_definition->name);
340 print_attrs(bit->element_definition, bit->attributes);
344 Printf(
"></%S>", bit->element_definition->name);
349 Printf(
"</%S>", bit->element_definition->name);
353 bit->pi_name, bit->pi_chars,
nsgml ?
">" :
"?>");
362 Printf(
"<![CDATA[%S]]>", bit->cdsect_chars);
371 Printf(
"<!--%S-->", bit->comment_chars);
385 return Strcmp((*(Attribute *)a)->definition->name,
386 (*(Attribute *)b)->definition->name);
395 for(b=a; b; b=b->next)
401 aa = malloc(n *
sizeof(*aa));
403 for(i=0, b=a; b; i++, b=b->next)
411 Printf(
" %S=\"", aa[i]->definition->name);
423 for(i=0; i<50 && text[i]; i++)
424 if(text[i] ==
'\n' || text[i] ==
'\r')
445 for(pc = last = text; *pc; pc++)
447 if(*pc ==
'&' || *pc ==
'<' || *pc ==
'>' || *pc ==
'"' ||
448 (
strict_xml && (*pc == 9 || *pc == 10 || *pc == 13)))
451 Printf(
"%.*S", pc - last, last);
481 Printf(
"%.*S", pc - last, last);
487 strcmp(ent->publicid,
"-//RMT//DTD just a test//EN") == 0)
492 if((f = fopen(
"/tmp/mydtd",
"r")))
STD_API void SetFileEncoding(FILE16 *file, CharacterEncoding encoding)
int attr_compare(const void *a, const void *b)
void print_bit(Parser p, XBit bit)
XML_API void FreeDtd(Dtd dtd)
void qsort(EST_TList< T > &a)
XML_API void FreeEntity(Entity e)
STD_API const char8 * CharacterEncodingName[CE_enum_count]
STD_API const char8 * CharacterEncodingNameAndByteOrder[CE_enum_count]
InputSource entity_open(Entity ent, void *arg)
STD_API FILE16 * MakeFILE16FromFILE(FILE *f, const char *type)
STD_API void SetCloseUnderlying(FILE16 *file, int cu)
XML_API void ParserSetDtdCallback(Parser p, CallbackProc cb)
void print_text_bit(Char *text)
void print_tree(Parser p, XBit bit)
XML_API void ParserPerror(Parser p, XBit bit)
void dtd_cb(XBit bit, void *arg)
void FreeXTree(XBit tree)
#define NewExternalEntity(name, pub, sys, nnot, parent)
void print_attrs(ElementDefinition e, Attribute a)
const char8 * StandaloneDeclarationName[SDD_enum_count]
XML_API int ParserPush(Parser p, InputSource source)
int main(int argc, char **argv)
XML_API Parser NewParser(void)
CharacterEncoding encoding
XML_API void ParserSetFlag(Parser p, ParserFlag flag, int value)
XML_API void FreeParser(Parser p)
STD_API int Printf(const char *format,...)
ElementDefinition element_definition
enum character_encoding CharacterEncoding
XML_API void ParserSetCallbackArg(Parser p, void *arg)
XML_API const char8 * XBitTypeName[XBIT_enum_count]
STD_API char8 * strdup8(const char8 *s)
void print_text(Char *text)
STD_API CharacterEncoding FindEncoding(char8 *name)
XML_API XBit ReadXBit(Parser p)
XML_API void ParserSetEntityOpener(Parser p, EntityOpenerProc opener)
XML_API void FreeXBit(XBit xbit)