37 static inline char *
Name(
void *arg) {
return (
char *)arg +
sizeof(SXmlAttr_t); }
54 SXmlNode_t *fLastChild;
58 static inline char *
Name(
void *arg) {
return (
char *)arg +
sizeof(SXmlNode_t); }
62 SXmlNode_t *fRootNode;
67 class TXMLOutputStream {
77 TXMLOutputStream(
const char *filename,
Int_t bufsize = 20000)
79 fOut =
new std::ofstream(filename);
93 fBuf = (
char *)
malloc(bufsize);
95 fMaxAddr = fBuf + bufsize;
96 fLimitAddr = fBuf + int(bufsize * 0.75);
99 virtual ~TXMLOutputStream()
101 if (fCurrent != fBuf)
109 if (fCurrent != fBuf) {
111 fOut->write(fBuf, fCurrent - fBuf);
112 else if (fOutStr != 0)
113 fOutStr->
Append(fBuf, fCurrent - fBuf);
118 void OutputChar(
char symb)
122 else if (fOutStr != 0)
126 void Write(
const char *str)
128 int len = strlen(str);
129 if (fCurrent + len >= fMaxAddr) {
131 fOut->write(str, len);
134 *fCurrent++ = *str++;
135 if (fCurrent > fLimitAddr)
142 if (fCurrent +
cnt >= fMaxAddr)
144 if (fCurrent +
cnt >= fMaxAddr)
145 for (
int n = 0;
n <
cnt;
n++)
148 for (
int n = 0;
n <
cnt;
n++)
150 if (fCurrent > fLimitAddr)
156 class TXMLEntity :
public TNamed {
161 Bool_t IsSystem()
const {
return fSystem; }
164 class TXMLInputStream {
187 TXMLInputStream(
Bool_t isfilename,
const char *filename,
Int_t ibufsize)
188 : fInp(0), fInpStr(0), fInpStrLen(0), fBuf(0), fBufSize(0), fMaxAddr(0), fLimitAddr(0), fTotalPos(0),
189 fCurrentLine(0), fEntities(), fCurrent(0)
192 fInp =
new std::ifstream(filename);
198 fInpStrLen = filename == 0 ? 0 : strlen(filename);
202 fBuf = (
char *)
malloc(fBufSize);
207 int len = DoRead(fBuf, fBufSize);
209 fMaxAddr = fBuf + len;
210 fLimitAddr = fBuf + int(len * 0.75);
221 virtual ~TXMLInputStream()
232 inline Bool_t EndOfFile() {
return (fInp != 0) ? fInp->eof() : (fInpStrLen <= 0); }
237 inline Bool_t EndOfStream() {
return EndOfFile() && (fCurrent >= fMaxAddr); }
242 void AddEntity(TXMLEntity *ent) { fEntities.
Add(ent); }
247 Int_t NumEntities()
const {
return fEntities.
GetLast() + 1; }
252 TXMLEntity *FindEntity(
const char *beg,
Int_t len)
257 TXMLEntity *entity = (TXMLEntity *)fEntities[
n];
258 if ((
Int_t)strlen(entity->GetName()) != len)
260 if (strncmp(beg, entity->GetName(), len) == 0)
269 int DoRead(
char *buf,
int maxsize)
274 fInp->get(buf, maxsize, 0);
275 maxsize = strlen(buf);
277 if (maxsize > fInpStrLen)
278 maxsize = fInpStrLen;
279 strncpy(buf, fInpStr, maxsize);
281 fInpStrLen -= maxsize;
294 int curlength = fMaxAddr - fBuf;
295 char *newbuf = (
char *)
realloc(fBuf, fBufSize);
299 fMaxAddr = newbuf + (fMaxAddr - fBuf);
300 fCurrent = newbuf + (fCurrent - fBuf);
301 fLimitAddr = newbuf + (fLimitAddr - fBuf);
304 int len = DoRead(fMaxAddr, fBufSize - curlength);
308 fLimitAddr += int(len * 0.75);
317 if (fCurrent < fLimitAddr)
321 int rest_len = fMaxAddr - fCurrent;
322 memmove(fBuf, fCurrent, rest_len);
323 int read_len = DoRead(fBuf + rest_len, fBufSize - rest_len);
326 fMaxAddr = fBuf + rest_len + read_len;
327 fLimitAddr = fBuf + int((rest_len + read_len) * 0.75);
334 Int_t TotalPos() {
return fTotalPos; }
339 Int_t CurrentLine() {
return fCurrentLine; }
346 for (
int n = 0;
n < sz;
n++) {
349 if (fCurrent >= fLimitAddr) {
351 if (fCurrent >= fMaxAddr)
365 while (fCurrent < fMaxAddr) {
366 char symb = *fCurrent;
367 if ((symb > 26) && (symb !=
' '))
373 if (tillendl && (symb == 10))
382 Bool_t CheckFor(
const char *str)
384 int len = strlen(str);
385 while (fCurrent + len > fMaxAddr)
388 char *curr = fCurrent;
390 if (*str++ != *curr++)
392 return ShiftCurrent(len);
399 Int_t SearchFor(
const char *str)
401 int len = strlen(str);
403 char *curr = fCurrent;
407 while (curr + len > fMaxAddr)
411 const char *chk = str;
414 if (*chk++ != *chk0++) {
420 return curr - fCurrent;
421 }
while (curr < fMaxAddr);
428 inline Bool_t GoodStartSymbol(
unsigned char symb)
430 return (((symb >=
'a') && (symb <=
'z')) || ((symb >=
'A') && (symb <=
'Z')) || (symb ==
'_') ||
431 ((symb >= 0xc0) && (symb <= 0xd6)) || ((symb >= 0xd8) && (symb <= 0xf6)) || (symb > 0xf8));
437 Int_t LocateIdentifier()
439 unsigned char symb = (
unsigned char)*fCurrent;
441 Bool_t ok = GoodStartSymbol(symb);
445 char *curr = fCurrent;
449 if (curr >= fMaxAddr)
452 symb = (
unsigned char)*curr;
453 ok = GoodStartSymbol(symb) || ((symb >=
'0') && (symb <=
'9')) || (symb ==
':') || (symb ==
'-') ||
454 (symb ==
'.') || (symb == 0xb7);
456 return curr - fCurrent;
457 }
while (curr < fMaxAddr);
464 Int_t LocateContent()
466 char *curr = fCurrent;
467 while (curr < fMaxAddr) {
470 return curr - fCurrent;
472 if (curr >= fMaxAddr)
482 Int_t LocateValue(
char *start,
bool withequalsign =
true)
485 if (curr >= fMaxAddr)
492 if (curr >= fMaxAddr)
496 if ((*curr !=
'\"') && (*curr !=
'\''))
501 if (curr >= fMaxAddr)
505 return curr - start + 1;
506 }
while (curr < fMaxAddr);
531 if ((xmlnode == 0) || (
name == 0))
533 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
549 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
568 sscanf(attr,
"%d", &res);
581 int namelen(
name != 0 ? strlen(
name) : 0);
582 int valuelen(value != 0 ? strlen(value) : 0);
583 SXmlAttr_t *attr = (SXmlAttr_t *)
AllocateAttr(namelen, valuelen, xmlnode);
587 strncpy(attrname,
name, namelen + 1);
590 attrname += (namelen + 1);
592 strncpy(attrname, value, valuelen + 1);
605 sprintf(sbuf,
"%d", value);
616 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
617 SXmlAttr_t *prev = 0;
621 prev->fNext = attr->fNext;
623 ((SXmlNode_t *)xmlnode)->fAttr = attr->fNext;
642 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
643 SXmlAttr_t *attr = node->fAttr;
645 SXmlAttr_t *next = attr->fNext;
659 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
661 SXmlAttr_t *attr = node->fAttr;
662 if ((attr != 0) && (node->fNs == attr))
699 return attrname + strlen(attrname) + 1;
707 int namelen(
name != 0 ? strlen(
name) : 0);
709 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(namelen, parent);
716 node->fNs = (SXmlAttr_t *)
ns;
717 int contlen = (content != 0) ? strlen(content) : 0;
719 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(contlen, node);
733 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
736 int namelen = strlen(
name);
737 char *nsname =
new char[namelen + 7];
740 SXmlAttr_t *
first = node->fAttr;
743 SXmlAttr_t *nsattr = (SXmlAttr_t *)
NewAttr(xmlnode, 0, nsname, reference);
745 node->fAttr = nsattr;
746 nsattr->fNext =
first;
760 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
772 if ((nsname != 0) && (strncmp(nsname,
"xmlns:", 6) == 0))
791 if ((parent == 0) || (child == 0))
793 SXmlNode_t *pnode = (SXmlNode_t *)parent;
794 SXmlNode_t *cnode = (SXmlNode_t *)child;
795 cnode->fParent = pnode;
796 if (pnode->fLastChild == 0) {
797 pnode->fChild = cnode;
798 pnode->fLastChild = cnode;
802 pnode->fLastChild->fNext = cnode;
803 pnode->fLastChild = cnode;
812 if ((parent == 0) || (child == 0))
814 SXmlNode_t *pnode = (SXmlNode_t *)parent;
815 SXmlNode_t *cnode = (SXmlNode_t *)child;
816 cnode->fParent = pnode;
818 cnode->fNext = pnode->fChild;
819 pnode->fChild = cnode;
821 if (pnode->fLastChild == 0)
822 pnode->fLastChild = cnode;
830 if ((xmlnode == 0) || (comment == 0))
833 int commentlen = strlen(comment);
835 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(commentlen, xmlnode);
867 if ((xmlnode == 0) || (
line == 0))
870 int linelen = strlen(
line);
871 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(linelen, xmlnode);
904 int alternate,
const char *media,
const char *charset)
906 if ((xmlnode == 0) || (href == 0) || (type == 0))
909 const char *nodename =
"xml-stylesheet";
910 int nodenamelen = strlen(nodename);
912 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(nodenamelen, xmlnode);
917 NewAttr(node, 0,
"alternate", (alternate > 0) ?
"yes" :
"no");
920 NewAttr(node, 0,
"title", title);
922 NewAttr(node, 0,
"href", href);
923 NewAttr(node, 0,
"type", type);
926 NewAttr(node, 0,
"media", media);
928 NewAttr(node, 0,
"charset", charset);
937 int alternate,
const char *media,
const char *charset)
945 Bool_t res =
AddStyleSheet(((SXmlDoc_t *)xmldoc)->fRootNode, href, type, title, alternate, media, charset);
959 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
961 SXmlNode_t *parent = node->fParent;
966 if (parent->fChild == node) {
967 parent->fChild = node->fNext;
968 if (parent->fLastChild == node)
969 parent->fLastChild = node->fNext;
971 SXmlNode_t *ch = parent->fChild;
972 while (ch->fNext != node)
974 ch->fNext = node->fNext;
975 if (parent->fLastChild == node)
976 parent->fLastChild = ch;
988 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
990 SXmlNode_t *child = node->fChild;
992 SXmlNode_t *next = child->fNext;
997 SXmlAttr_t *attr = node->fAttr;
999 SXmlAttr_t *next = attr->fNext;
1034 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1035 if (node->fChild == 0)
1052 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1053 if ((node->fChild != 0) && (node->fChild->fType ==
kXML_CONTENT))
1059 len = strlen(content);
1061 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(len, 0);
1064 strncpy(nameptr, content, len);
1077 if ((xmlnode == 0) || (content == 0))
1080 len = strlen(content);
1082 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(len, xmlnode);
1085 strncpy(nameptr, content, len);
1097 if (realnode && (res != 0) && (((SXmlNode_t *)res)->fType !=
kXML_NODE))
1107 return xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fParent;
1117 xmlnode = xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fNext;
1118 if ((xmlnode == 0) || !realnode)
1120 }
while (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1132 xmlnode = xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fNext;
1133 if ((xmlnode == 0) || !realnode)
1135 }
while (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1143 return xmlnode == 0 ?
kFALSE : (((SXmlNode_t *)xmlnode)->fType ==
kXML_NODE);
1151 return xmlnode == 0 ?
kTRUE : (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1186 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1188 SXmlNode_t *child = node->fChild;
1189 while (child != 0) {
1190 SXmlNode_t *next = child->fNext;
1196 node->fLastChild = 0;
1204 SXmlDoc_t *doc =
new SXmlDoc_t;
1205 doc->fRootNode = (SXmlNode_t *)
NewChild(0, 0,
"??DummyTopNode??", 0);
1210 NewAttr(vernode, 0,
"version", version);
1225 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1226 delete[] doc->fDtdName;
1227 doc->fDtdName =
Makestr(dtdname);
1228 delete[] doc->fDtdRoot;
1229 doc->fDtdRoot =
Makestr(rootname);
1239 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1241 delete[] doc->fDtdName;
1242 delete[] doc->fDtdRoot;
1258 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1260 TXMLOutputStream out(filename, 100000);
1267 }
while (child != 0);
1305 if ((filename == 0) || (strlen(filename) == 0))
1307 if (maxbuf < 100000)
1309 TXMLInputStream inp(
true, filename, maxbuf);
1318 if ((xmlstring == 0) || (strlen(xmlstring) == 0))
1320 TXMLInputStream inp(
false, xmlstring, 2 * strlen(xmlstring));
1339 ReadNode(((SXmlDoc_t *)xmldoc)->fRootNode, inp, resvalue);
1346 if (!inp->EndOfStream())
1349 if (inp->EndOfStream()) {
1381 const char *value =
GetAttr(vernode,
"version");
1387 return strcmp(version, value) == 0;
1399 if ((res == 0) || (xmlnode == 0))
1402 TXMLOutputStream out(res, 10000);
1404 SaveNode(xmlnode, &out, layout, 0);
1415 TXMLInputStream inp(
false, src, 10000);
1421 if (resvalue <= 0) {
1437 int len = strlen(str);
1440 char *res =
new char[len + 1];
1441 strncpy(res, str, len + 1);
1450 if ((str == 0) || (len == 0))
1452 char *res =
new char[len + 1];
1453 strncpy(res, str, len);
1465 SXmlNode_t *node = (SXmlNode_t *)
malloc(
sizeof(SXmlNode_t) + namelen + 1);
1472 node->fLastChild = 0;
1488 SXmlAttr_t *attr = (SXmlAttr_t *)
malloc(
sizeof(SXmlAttr_t) + namelen + 1 + valuelen + 1);
1490 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1494 if (node->fAttr == 0)
1497 SXmlAttr_t *d = node->fAttr;
1498 while (d->fNext != 0)
1511 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1513 if (node->fNs != 0) {
1515 if (strcmp(nsname,
name) == 0)
1518 node = node->fParent;
1528 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1538 *(copyname++) = *(++colon);
1547 while (srclen > 0) {
1548 if (*source ==
'&') {
1549 if ((srclen > 3) && (*(source + 1) ==
'l') && (*(source + 2) ==
't') && (*(source + 3) ==
';')) {
1553 }
else if ((srclen > 3) && (*(source + 1) ==
'g') && (*(source + 2) ==
't') && (*(source + 3) ==
';')) {
1557 }
else if ((srclen > 4) && (*(source + 1) ==
'a') && (*(source + 2) ==
'm') && (*(source + 3) ==
'p') &&
1558 (*(source + 4) ==
';')) {
1562 }
else if ((srclen > 5) && (*(source + 1) ==
'q') && (*(source + 2) ==
'u') && (*(source + 3) ==
'o') &&
1563 (*(source + 4) ==
't') && (*(source + 5) ==
';')) {
1567 }
else if ((srclen > 5) && (*(source + 1) ==
'a') && (*(source + 2) ==
'p') && (*(source + 3) ==
'o') &&
1568 (*(source + 4) ==
's') && (*(source + 5) ==
';')) {
1573 *target++ = *source++;
1577 *target++ = *source++;
1596 while ((find = strpbrk(last,
"<&>\"")) != 0) {
1604 else if (symb ==
'>')
1606 else if (symb ==
'&')
1607 out->Write(
"&");
1608 else if (symb ==
'\'')
1609 out->Write(
"'");
1611 out->Write(
""");
1624 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1626 Bool_t issingleline = (node->fChild == 0);
1629 out->Put(
' ', level);
1655 if ((node->fNs != 0) && (node->fNs != node->fAttr)) {
1661 SXmlAttr_t *attr = node->fAttr;
1665 out->Write(attrname);
1667 attrname += strlen(attrname) + 1;
1686 SXmlNode_t *child = node->fChild;
1688 if ((child != 0) && (child->fType ==
kXML_CONTENT) && (child->fNext == 0)) {
1694 while (child != 0) {
1696 child = child->fNext;
1700 out->Put(
' ', level);
1705 if ((node->fNs != 0) && (node->fNs != node->fAttr)) {
1728 if (!inp->SkipSpaces()) {
1732 SXmlNode_t *parent = (SXmlNode_t *)xmlparent;
1734 SXmlNode_t *node = 0;
1737 while (inp->CheckFor(
"<!--")) {
1738 Int_t commentlen = inp->SearchFor(
"-->");
1739 if (commentlen <= 0) {
1745 node = (SXmlNode_t *)
AllocateNode(commentlen, xmlparent);
1748 strncpy(nameptr, inp->fCurrent, commentlen);
1749 nameptr += commentlen;
1753 if (!inp->ShiftCurrent(commentlen + 3)) {
1757 if (!inp->SkipSpaces() && !inp->EndOfStream()) {
1766 if (*inp->fCurrent !=
'<') {
1773 int contlen = inp->LocateContent();
1777 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(contlen, xmlparent);
1781 if (!inp->ShiftCurrent(contlen))
1784 if (inp->NumEntities() <= 0) {
1791 const char *beg(0), *lastentity(0), *curr(contptr);
1793 while (*curr != 0) {
1794 if ((beg == 0) && (*curr ==
'&'))
1796 if ((beg == 0) || (*curr !=
';')) {
1801 TXMLEntity *entity = inp->FindEntity(beg + 1, curr - beg - 1);
1805 if (lastentity == 0) {
1806 lastentity = contptr;
1810 if (lastentity != beg)
1814 if (entity->IsSystem()) {
1816 if (entitydoc == 0) {
1823 while (topnode != 0) {
1840 if (lastentity != 0) {
1842 if (strlen(lastentity) > 0)
1853 if (!inp->ShiftCurrent())
1857 if (*inp->fCurrent ==
'/') {
1859 if (!inp->ShiftCurrent())
1861 if (!inp->SkipSpaces())
1863 Int_t len = inp->LocateIdentifier();
1879 if (!inp->ShiftCurrent(len))
1882 if (!inp->SkipSpaces())
1884 if (*inp->fCurrent !=
'>')
1886 if (!inp->ShiftCurrent())
1889 if (parent->fNs != 0)
1892 inp->SkipSpaces(
kTRUE);
1897 if (*inp->fCurrent ==
'!') {
1899 if (!inp->ShiftCurrent())
1901 if (!inp->CheckFor(
"DOCTYPE")) {
1905 if (!inp->SkipSpaces()) {
1911 Int_t len = inp->LocateIdentifier();
1916 if (!inp->ShiftCurrent(len)) {
1920 if (!inp->SkipSpaces()) {
1926 if (inp->CheckFor(
"[")) {
1927 if (!inp->SkipSpaces())
1930 if (inp->CheckFor(
"<!ENTITY")) {
1932 if (!inp->SkipSpaces()) {
1936 Int_t namelen = inp->LocateIdentifier();
1941 TString entity_name(inp->fCurrent, namelen);
1942 if (!inp->ShiftCurrent(namelen)) {
1946 if (!inp->SkipSpaces()) {
1951 if (inp->CheckFor(
"SYSTEM")) {
1952 if (!inp->SkipSpaces()) {
1959 char *valuestart = inp->fCurrent;
1960 Int_t valuelen = inp->LocateValue(valuestart,
false);
1966 TString entity_value(valuestart + 1, valuelen - 2);
1968 if (!inp->ShiftCurrent(valuelen)) {
1973 if (*inp->fCurrent !=
'>') {
1977 if (!inp->ShiftCurrent()) {
1983 inp->AddEntity(
new TXMLEntity(entity_name, entity_value, is_system));
1990 if (inp->CheckFor(
"<!ELEMENT")) {
1992 if (!inp->SkipSpaces()) {
1996 Int_t namelen = inp->LocateIdentifier();
2002 if (!inp->ShiftCurrent(namelen)) {
2006 if (!inp->SkipSpaces()) {
2011 if (!inp->CheckFor(
"(")) {
2015 if (inp->SearchFor(
")") <= 0) {
2021 if (*inp->fCurrent !=
'>') {
2025 if (!inp->ShiftCurrent()) {
2037 if (!inp->CheckFor(
"]")) {
2043 if (!inp->CheckFor(
">")) {
2053 Bool_t canhaschildren =
true;
2054 char endsymbol =
'/';
2057 if (*inp->fCurrent ==
'?') {
2058 if (!inp->ShiftCurrent())
2061 canhaschildren =
false;
2065 if (!inp->SkipSpaces())
2067 Int_t len = inp->LocateIdentifier();
2072 node->fType = nodetype;
2074 strncpy(nameptr, inp->fCurrent, len);
2079 if ((colon != 0) && (parent != 0)) {
2085 if (!inp->ShiftCurrent(len))
2089 if (!inp->SkipSpaces())
2092 char nextsymb = *inp->fCurrent;
2094 if (nextsymb == endsymbol) {
2095 if (!inp->ShiftCurrent())
2097 if (*inp->fCurrent ==
'>') {
2098 if (!inp->ShiftCurrent())
2104 inp->SkipSpaces(
kTRUE);
2109 }
else if (nextsymb ==
'>') {
2110 if (!canhaschildren) {
2115 if (!inp->ShiftCurrent())
2120 }
while (resvalue == 2);
2122 if (resvalue == 1) {
2128 Int_t attrlen = inp->LocateIdentifier();
2134 char *valuestart = inp->fCurrent + attrlen;
2136 int valuelen = inp->LocateValue(valuestart,
true);
2145 strncpy(attrname, inp->fCurrent, attrlen);
2146 attrname += attrlen;
2151 if (!inp->ShiftCurrent(attrlen + valuelen))
2156 if ((strlen(attrname) > 6) && (strstr(attrname,
"xmlns:") == attrname)) {
2161 if (node->fNs != 0) {
2179 case -14:
Error(
"ParseFile",
"Error include external XML file at line %d", linenumber);
break;
2180 case -13:
Error(
"ParseFile",
"Error processing DTD part of XML file at line %d", linenumber);
break;
2181 case -12:
Error(
"ParseFile",
"DOCTYPE missing after <! at line %d", linenumber);
break;
2183 Error(
"ParseFile",
"Node cannot be closed with > symbol at line %d, for instance <?xml ... ?> node", linenumber);
2186 Error(
"ParseFile",
"Error in xml comments definition at line %d, must be <!-- comments -->", linenumber);
2188 case -9:
Error(
"ParseFile",
"Multiple namespace definitions not allowed, line %d", linenumber);
break;
2189 case -8:
Error(
"ParseFile",
"Invalid namespace specification, line %d", linenumber);
break;
2190 case -7:
Error(
"ParseFile",
"Invalid attribute value, line %d", linenumber);
break;
2191 case -6:
Error(
"ParseFile",
"Invalid identifier for node attribute, line %d", linenumber);
break;
2192 case -5:
Error(
"ParseFile",
"Mismatch between open and close nodes, line %d", linenumber);
break;
2193 case -4:
Error(
"ParseFile",
"Unexpected close node, line %d", linenumber);
break;
2194 case -3:
Error(
"ParseFile",
"Valid identifier for close node is missing, line %d", linenumber);
break;
2195 case -2:
Error(
"ParseFile",
"No multiple content entries allowed, line %d", linenumber);
break;
2196 case -1:
Error(
"ParseFile",
"Unexpected end of xml file");
break;
2197 default:
Error(
"ParseFile",
"XML syntax error at line %d", linenumber);
break;
char * Makestr(const char *str)
creates char* variable with copy of provided string
XMLDocPointer_t ParseStream(TXMLInputStream *input)
parses content of the stream and tries to produce xml structures
void FreeAttr(XMLNodePointer_t xmlnode, const char *name)
remove attribute from xmlnode
XMLNsPointer_t GetNS(XMLNodePointer_t xmlnode)
return namespace attribute (if exists)
void SaveNode(XMLNodePointer_t xmlnode, TXMLOutputStream *out, Int_t layout, Int_t level)
stream data of xmlnode to output
Bool_t AddStyleSheet(XMLNodePointer_t parent, const char *href, const char *type="text/css", const char *title=0, int alternate=-1, const char *media=0, const char *charset=0)
Adds style sheet definition to the specified node Creates <?xml-stylesheet alternate="yes" title="com...
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
XMLDocPointer_t NewDoc(const char *version="1.0")
creates new xml document with provided version
TXMLEngine()
if true, do not create comments nodes in document during parsing
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped ...
Bool_t AddComment(XMLNodePointer_t parent, const char *comment)
Adds comment line to the node.
XMLNsPointer_t FindNs(XMLNodePointer_t xmlnode, const char *nsname)
define if namespace of that name exists for xmlnode
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
return next attribute in the list
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
void UnlinkFreeNode(XMLNodePointer_t xmlnode)
combined operation. Unlink node and free used memory
XMLAttrPointer_t NewIntAttr(XMLNodePointer_t xmlnode, const char *name, Int_t value)
create node attribute with integer value
const char * GetNodeContent(XMLNodePointer_t xmlnode)
get contents (if any) of xmlnode
void DisplayError(Int_t error, Int_t linenumber)
Displays xml parsing error.
void FreeAllAttr(XMLNodePointer_t xmlnode)
Free all attributes of the node.
The TNamed class is the base class for all named ROOT classes.
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
set main (root) node for document
void Init(TClassEdit::TInterpreterLookupHelper *helper)
XMLNsPointer_t NewNS(XMLNodePointer_t xmlnode, const char *reference, const char *name=0)
create namespace attribute for xmlnode.
TString & Append(const char *cs)
XMLDocPointer_t ParseString(const char *xmlstring)
parses content of string and tries to produce xml structures
Bool_t IsEmptyNode(XMLNodePointer_t xmlnode)
return kTRUE is this is node with special data like comments to data processing instructions ...
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
XMLAttrPointer_t AllocateAttr(int namelen, int valuelen, XMLNodePointer_t xmlnode)
Allocate new attribute with specified name length and value length.
Int_t GetLast() const
Return index of last object in array.
void SaveDoc(XMLDocPointer_t xmldoc, const char *filename, Int_t layout=1)
store document content to file if layout<=0, no any spaces or newlines will be placed between xmlnode...
void AddChild(XMLNodePointer_t parent, XMLNodePointer_t child)
add child element to xmlnode
void ShiftToNext(XMLNodePointer_t &xmlnode, Bool_t realnode=kTRUE)
shifts specified node to next if realnode==kTRUE, any special nodes in between will be skipped ...
Bool_t AddRawLine(XMLNodePointer_t parent, const char *line)
Add just line into xml file Line should has correct xml syntax that later it can be decoded by xml pa...
void SetNodeContent(XMLNodePointer_t xmlnode, const char *content, Int_t len=0)
set content of the xmlnode if old node content was exists, it will be replaced
char * Makenstr(const char *start, int len)
creates char* variable with copy of len symbols from provided string
Bool_t IsCommentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
return value of attribute
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
return first attribute in the list, namespace (if exists) will be skipped
Bool_t AddDocStyleSheet(XMLDocPointer_t xmldoc, const char *href, const char *type="text/css", const char *title=0, int alternate=-1, const char *media=0, const char *charset=0)
Add style sheet definition on the top of document.
void SkipEmpty(XMLNodePointer_t &xmlnode)
Skip all current empty nodes and locate on first "true" node.
Bool_t IsXmlNode(XMLNodePointer_t xmlnode)
return kTRUE is this is normal xmlnode
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char *name)
checks if node has attribute of specified name
Bool_t AddDocRawLine(XMLDocPointer_t xmldoc, const char *line)
Add just line on the top of xml document Line should has correct xml syntax that later it can be deco...
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
void AddChildFirst(XMLNodePointer_t parent, XMLNodePointer_t child)
add node as first child
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
void CleanNode(XMLNodePointer_t xmlnode)
remove all children node from xmlnode
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
void SaveSingleNode(XMLNodePointer_t xmlnode, TString *res, Int_t layout=1)
convert single xmlnode (and its child node) to string if layout<=0, no any spaces or newlines will be...
Bool_t AddDocComment(XMLDocPointer_t xmldoc, const char *comment)
add comment line to the top of the document
void TruncateNsExtension(XMLNodePointer_t xmlnode)
removes namespace extension of nodename
void FreeNode(XMLNodePointer_t xmlnode)
release all memory, allocated from this node and destroys node itself
XMLNodePointer_t ReadNode(XMLNodePointer_t xmlparent, TXMLInputStream *inp, Int_t &resvalue)
Tries to construct xml node from input stream.
Bool_t ValidateVersion(XMLDocPointer_t doc, const char *version=0)
check that first node is xml processing instruction with correct xml version number ...
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
returns parent of xmlnode
void UnpackSpecialCharacters(char *target, const char *source, int srclen)
unpack special symbols, used in xml syntax to code characters these symbols: '<' - <, '>' - >, '&' - &, '"...
const char * GetNSName(XMLNsPointer_t ns)
return name id of namespace
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
void UnlinkNode(XMLNodePointer_t node)
unlink (detach) xmlnode from parent
Int_t GetIntAttr(XMLNodePointer_t node, const char *name)
returns value of attribute as integer
Bool_t IsContentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
void AddNodeContent(XMLNodePointer_t xmlnode, const char *content, Int_t len=0)
add new content of the xmlnode old content will be preserved, one could mix content with child nodes ...
XMLNodePointer_t ReadSingleNode(const char *src)
read single xmlnode from provided string
virtual ~TXMLEngine()
destructor for TXMLEngine object
void OutputValue(char *value, TXMLOutputStream *out)
output value to output stream if symbols '<' '&' '>' '"' ''' appears in the string, they will be encoded to appropriate xml symbols: <, &, >, ", &apos
const char * GetAttrName(XMLAttrPointer_t xmlattr)
return name of the attribute
static constexpr double ns
XMLNodePointer_t AllocateNode(int namelen, XMLNodePointer_t parent)
Allocates new xml node with specified name length.
const char * GetNSReference(XMLNsPointer_t ns)
return reference id of namespace
void AssignDtd(XMLDocPointer_t xmldoc, const char *dtdname, const char *rootname)
assigns dtd filename to document