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;
67class 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)
156class TXMLEntity :
public TNamed {
161 Bool_t IsSystem()
const {
return fSystem; }
164class 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)
276 fInp->get(buf, maxsize, 0);
277 resultsize = strlen(buf);
279 resultsize = strlcpy(buf, fInpStr, maxsize);
280 if (resultsize >= maxsize)
281 resultsize = maxsize - 1;
282 fInpStr += resultsize;
283 fInpStrLen -= resultsize;
291 Bool_t ExpandStream(
char *&curr)
296 int curlength = fMaxAddr - fBuf;
297 char *newbuf = (
char *)
realloc(fBuf, fBufSize);
301 fMaxAddr = newbuf + (fMaxAddr - fBuf);
302 fCurrent = newbuf + (fCurrent - fBuf);
303 fLimitAddr = newbuf + (fLimitAddr - fBuf);
304 curr = newbuf + (curr - fBuf);
307 int len = DoRead(fMaxAddr, fBufSize - curlength);
311 fLimitAddr += int(len * 0.75);
320 if (fCurrent < fLimitAddr)
324 int rest_len = fMaxAddr - fCurrent;
325 memmove(fBuf, fCurrent, rest_len);
326 int read_len = DoRead(fBuf + rest_len, fBufSize - rest_len);
329 fMaxAddr = fBuf + rest_len + read_len;
330 fLimitAddr = fBuf + int((rest_len + read_len) * 0.75);
337 Int_t TotalPos() {
return fTotalPos; }
342 Int_t CurrentLine() {
return fCurrentLine; }
349 for (
int n = 0;
n < sz;
n++) {
352 if (fCurrent >= fLimitAddr) {
354 if (fCurrent >= fMaxAddr)
368 while (fCurrent < fMaxAddr) {
369 char symb = *fCurrent;
370 if ((symb > 26) && (symb !=
' '))
376 if (tillendl && (symb == 10))
385 Bool_t CheckFor(
const char *str)
387 int len = strlen(str);
388 char *curr = fCurrent;
389 while (curr + len > fMaxAddr) {
390 if (!ExpandStream(curr))
394 if (*str++ != *curr++)
396 return ShiftCurrent(len);
403 Int_t SearchFor(
const char *str)
405 int len = strlen(str);
407 char *curr = fCurrent;
411 while (curr + len > fMaxAddr)
412 if (!ExpandStream(curr))
415 const char *chk = str;
418 if (*chk++ != *chk0++) {
424 return curr - fCurrent;
425 }
while (curr < fMaxAddr);
432 inline Bool_t GoodStartSymbol(
unsigned char symb)
434 return (((symb >=
'a') && (symb <=
'z')) || ((symb >=
'A') && (symb <=
'Z')) || (symb ==
'_') ||
435 ((symb >= 0xc0) && (symb <= 0xd6)) || ((symb >= 0xd8) && (symb <= 0xf6)) || (symb > 0xf8));
441 Int_t LocateIdentifier()
443 unsigned char symb = (
unsigned char)*fCurrent;
445 Bool_t ok = GoodStartSymbol(symb);
449 char *curr = fCurrent;
453 if (curr >= fMaxAddr)
454 if (!ExpandStream(curr))
456 symb = (
unsigned char)*curr;
457 ok = GoodStartSymbol(symb) || ((symb >=
'0') && (symb <=
'9')) || (symb ==
':') || (symb ==
'-') ||
458 (symb ==
'.') || (symb == 0xb7);
460 return curr - fCurrent;
461 }
while (curr < fMaxAddr);
468 Int_t LocateContent()
470 char *curr = fCurrent;
471 while (curr < fMaxAddr) {
474 return curr - fCurrent;
476 if (curr >= fMaxAddr)
477 if (!ExpandStream(curr))
486 Int_t LocateValue(
unsigned curr_offset,
bool withequalsign =
true)
488 char *curr = fCurrent + curr_offset;
489 if (curr >= fMaxAddr)
490 if (!ExpandStream(curr))
496 if (curr >= fMaxAddr)
497 if (!ExpandStream(curr))
500 if ((*curr !=
'\"') && (*curr !=
'\''))
505 if (curr >= fMaxAddr)
506 if (!ExpandStream(curr))
509 return curr - (fCurrent + curr_offset) + 1;
510 }
while (curr < fMaxAddr);
535 if ((xmlnode == 0) || (
name == 0))
537 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
553 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
572 sscanf(attr,
"%d", &res);
585 int namelen(
name != 0 ? strlen(
name) : 0);
586 int valuelen(value != 0 ? strlen(value) : 0);
587 SXmlAttr_t *attr = (SXmlAttr_t *)
AllocateAttr(namelen, valuelen, xmlnode);
591 strncpy(attrname,
name, namelen + 1);
594 attrname += (namelen + 1);
596 strncpy(attrname, value, valuelen + 1);
609 sprintf(sbuf,
"%d", value);
620 SXmlAttr_t *attr = ((SXmlNode_t *)xmlnode)->fAttr;
621 SXmlAttr_t *prev = 0;
625 prev->fNext = attr->fNext;
627 ((SXmlNode_t *)xmlnode)->fAttr = attr->fNext;
646 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
647 SXmlAttr_t *attr = node->fAttr;
649 SXmlAttr_t *next = attr->fNext;
663 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
665 SXmlAttr_t *attr = node->fAttr;
666 if ((attr != 0) && (node->fNs == attr))
703 return attrname + strlen(attrname) + 1;
711 int namelen(
name != 0 ? strlen(
name) : 0);
713 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(namelen, parent);
720 node->fNs = (SXmlAttr_t *)
ns;
721 int contlen = (content != 0) ? strlen(content) : 0;
723 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(contlen, node);
737 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
740 int namelen = strlen(
name);
741 char *nsname =
new char[namelen + 7];
744 SXmlAttr_t *
first = node->fAttr;
747 SXmlAttr_t *nsattr = (SXmlAttr_t *)
NewAttr(xmlnode, 0, nsname, reference);
749 node->fAttr = nsattr;
750 nsattr->fNext =
first;
764 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
776 if ((nsname != 0) && (strncmp(nsname,
"xmlns:", 6) == 0))
795 if ((parent == 0) || (child == 0))
797 SXmlNode_t *pnode = (SXmlNode_t *)parent;
798 SXmlNode_t *cnode = (SXmlNode_t *)child;
803 cnode->fParent = pnode;
804 if (pnode->fLastChild == 0) {
805 pnode->fChild = cnode;
806 pnode->fLastChild = cnode;
810 pnode->fLastChild->fNext = cnode;
811 pnode->fLastChild = cnode;
820 if ((parent == 0) || (child == 0))
822 SXmlNode_t *pnode = (SXmlNode_t *)parent;
823 SXmlNode_t *cnode = (SXmlNode_t *)child;
828 cnode->fParent = pnode;
830 cnode->fNext = pnode->fChild;
831 pnode->fChild = cnode;
833 if (pnode->fLastChild == 0)
834 pnode->fLastChild = cnode;
842 if (afternode == 0) {
847 SXmlNode_t *pnode = (SXmlNode_t *)parent;
848 SXmlNode_t *cnode = (SXmlNode_t *)child;
849 SXmlNode_t *anode = (SXmlNode_t *)afternode;
851 if (anode->fParent != pnode) {
852 Error(
"InsertChildAfter",
"Specified afternode is not in childs list of parent node");
860 cnode->fParent = pnode;
862 cnode->fNext = anode->fNext;
863 anode->fNext = cnode;
865 if (pnode->fLastChild == anode)
866 pnode->fLastChild = cnode;
874 if ((xmlnode == 0) || (comment == 0))
877 int commentlen = strlen(comment);
879 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(commentlen, xmlnode);
911 if ((xmlnode == 0) || (
line == 0))
914 int linelen = strlen(
line);
915 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(linelen, xmlnode);
948 int alternate,
const char *media,
const char *charset)
950 if ((xmlnode == 0) || (href == 0) || (
type == 0))
953 const char *nodename =
"xml-stylesheet";
954 int nodenamelen = strlen(nodename);
956 SXmlNode_t *node = (SXmlNode_t *)
AllocateNode(nodenamelen, xmlnode);
961 NewAttr(node, 0,
"alternate", (alternate > 0) ?
"yes" :
"no");
964 NewAttr(node, 0,
"title", title);
966 NewAttr(node, 0,
"href", href);
970 NewAttr(node, 0,
"media", media);
972 NewAttr(node, 0,
"charset", charset);
981 int alternate,
const char *media,
const char *charset)
1004 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1005 SXmlNode_t *parent = node->fParent;
1010 if (parent->fChild == node) {
1011 parent->fChild = node->fNext;
1012 if (parent->fLastChild == node)
1013 parent->fLastChild = node->fNext;
1015 SXmlNode_t *ch = parent->fChild;
1016 while (ch->fNext != node)
1018 ch->fNext = node->fNext;
1019 if (parent->fLastChild == node)
1020 parent->fLastChild = ch;
1035 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1037 SXmlNode_t *child = node->fChild;
1038 while (child != 0) {
1039 SXmlNode_t *next = child->fNext;
1044 SXmlAttr_t *attr = node->fAttr;
1046 SXmlAttr_t *next = attr->fNext;
1081 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1082 if (node->fChild == 0)
1099 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1100 if ((node->fChild != 0) && (node->fChild->fType ==
kXML_CONTENT))
1106 len = strlen(content);
1108 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(len, 0);
1111 strncpy(nameptr, content, len);
1124 if ((xmlnode == 0) || (content == 0))
1127 len = strlen(content);
1129 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(len, xmlnode);
1132 strncpy(nameptr, content, len);
1144 if (realnode && (res != 0) && (((SXmlNode_t *)res)->fType !=
kXML_NODE))
1154 return xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fParent;
1164 xmlnode = xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fNext;
1165 if ((xmlnode == 0) || !realnode)
1167 }
while (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1179 xmlnode = xmlnode == 0 ? 0 : (
XMLNodePointer_t)((SXmlNode_t *)xmlnode)->fNext;
1180 if ((xmlnode == 0) || !realnode)
1182 }
while (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1190 return xmlnode == 0 ?
kFALSE : (((SXmlNode_t *)xmlnode)->fType ==
kXML_NODE);
1198 return xmlnode == 0 ?
kTRUE : (((SXmlNode_t *)xmlnode)->fType !=
kXML_NODE);
1233 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1235 SXmlNode_t *child = node->fChild;
1236 while (child != 0) {
1237 SXmlNode_t *next = child->fNext;
1243 node->fLastChild = 0;
1251 SXmlDoc_t *doc =
new SXmlDoc_t;
1252 doc->fRootNode = (SXmlNode_t *)
NewChild(0, 0,
"??DummyTopNode??", 0);
1257 NewAttr(vernode, 0,
"version", version);
1272 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1273 delete[] doc->fDtdName;
1274 doc->fDtdName =
Makestr(dtdname);
1275 delete[] doc->fDtdRoot;
1276 doc->fDtdRoot =
Makestr(rootname);
1286 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1288 delete[] doc->fDtdName;
1289 delete[] doc->fDtdRoot;
1305 SXmlDoc_t *doc = (SXmlDoc_t *)xmldoc;
1307 TXMLOutputStream out(filename, 100000);
1314 }
while (child != 0);
1352 if ((filename == 0) || (strlen(filename) == 0))
1354 if (maxbuf < 100000)
1356 TXMLInputStream inp(
true, filename, maxbuf);
1365 if ((xmlstring == 0) || (strlen(xmlstring) == 0))
1367 TXMLInputStream inp(
false, xmlstring, 100000);
1386 ReadNode(((SXmlDoc_t *)xmldoc)->fRootNode, inp, resvalue);
1393 if (!inp->EndOfStream())
1396 if (inp->EndOfStream()) {
1428 const char *value =
GetAttr(vernode,
"version");
1434 return strcmp(version, value) == 0;
1446 if ((res == 0) || (xmlnode == 0))
1449 TXMLOutputStream out(res, 10000);
1451 SaveNode(xmlnode, &out, layout, 0);
1462 TXMLInputStream inp(
false, src, 10000);
1468 if (resvalue <= 0) {
1484 int len = strlen(str);
1487 char *res =
new char[len + 1];
1488 strncpy(res, str, len + 1);
1497 if ((str == 0) || (len == 0))
1499 char *res =
new char[len + 1];
1500 strncpy(res, str, len);
1512 SXmlNode_t *node = (SXmlNode_t *)
malloc(
sizeof(SXmlNode_t) + namelen + 1);
1519 node->fLastChild = 0;
1535 SXmlAttr_t *attr = (SXmlAttr_t *)
malloc(
sizeof(SXmlAttr_t) + namelen + 1 + valuelen + 1);
1537 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1541 if (node->fAttr == 0)
1544 SXmlAttr_t *
d = node->fAttr;
1545 while (
d->fNext != 0)
1558 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1560 if (node->fNs != 0) {
1562 if (strcmp(nsname,
name) == 0)
1565 node = node->fParent;
1575 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1585 *(copyname++) = *(++colon);
1594 while (srclen > 0) {
1595 if (*source ==
'&') {
1596 if ((srclen > 3) && (*(source + 1) ==
'l') && (*(source + 2) ==
't') && (*(source + 3) ==
';')) {
1600 }
else if ((srclen > 3) && (*(source + 1) ==
'g') && (*(source + 2) ==
't') && (*(source + 3) ==
';')) {
1604 }
else if ((srclen > 4) && (*(source + 1) ==
'a') && (*(source + 2) ==
'm') && (*(source + 3) ==
'p') &&
1605 (*(source + 4) ==
';')) {
1609 }
else if ((srclen > 5) && (*(source + 1) ==
'q') && (*(source + 2) ==
'u') && (*(source + 3) ==
'o') &&
1610 (*(source + 4) ==
't') && (*(source + 5) ==
';')) {
1614 }
else if ((srclen > 5) && (*(source + 1) ==
'a') && (*(source + 2) ==
'p') && (*(source + 3) ==
'o') &&
1615 (*(source + 4) ==
's') && (*(source + 5) ==
';')) {
1620 *target++ = *source++;
1624 *target++ = *source++;
1643 while ((find = strpbrk(last,
"<&>\"")) != 0) {
1651 else if (symb ==
'>')
1653 else if (symb ==
'&')
1654 out->Write(
"&");
1655 else if (symb ==
'\'')
1656 out->Write(
"'");
1658 out->Write(
""");
1671 SXmlNode_t *node = (SXmlNode_t *)xmlnode;
1673 Bool_t issingleline = (node->fChild == 0);
1676 out->Put(
' ', level);
1702 if ((node->fNs != 0) && (node->fNs != node->fAttr)) {
1708 SXmlAttr_t *attr = node->fAttr;
1712 out->Write(attrname);
1714 attrname += strlen(attrname) + 1;
1733 SXmlNode_t *child = node->fChild;
1735 if ((child != 0) && (child->fType ==
kXML_CONTENT) && (child->fNext == 0)) {
1741 while (child != 0) {
1743 child = child->fNext;
1747 out->Put(
' ', level);
1752 if ((node->fNs != 0) && (node->fNs != node->fAttr)) {
1775 if (!inp->SkipSpaces()) {
1779 SXmlNode_t *parent = (SXmlNode_t *)xmlparent;
1781 SXmlNode_t *node = 0;
1784 while (inp->CheckFor(
"<!--")) {
1785 Int_t commentlen = inp->SearchFor(
"-->");
1786 if (commentlen <= 0) {
1792 node = (SXmlNode_t *)
AllocateNode(commentlen, xmlparent);
1795 strncpy(nameptr, inp->fCurrent, commentlen);
1796 nameptr += commentlen;
1800 if (!inp->ShiftCurrent(commentlen + 3)) {
1804 if (!inp->SkipSpaces() && !inp->EndOfStream()) {
1813 if (*inp->fCurrent !=
'<') {
1820 int contlen = inp->LocateContent();
1824 SXmlNode_t *contnode = (SXmlNode_t *)
AllocateNode(contlen, xmlparent);
1828 if (!inp->ShiftCurrent(contlen))
1831 if (inp->NumEntities() <= 0) {
1838 const char *beg(0), *lastentity(0), *curr(contptr);
1840 while (*curr != 0) {
1841 if ((beg == 0) && (*curr ==
'&'))
1843 if ((beg == 0) || (*curr !=
';')) {
1848 TXMLEntity *entity = inp->FindEntity(beg + 1, curr - beg - 1);
1852 if (lastentity == 0) {
1853 lastentity = contptr;
1857 if (lastentity != beg)
1860 if (entity->IsSystem()) {
1862 if (entitydoc == 0) {
1869 while (topnode != 0) {
1886 if (lastentity != 0) {
1888 if (strlen(lastentity) > 0)
1899 if (!inp->ShiftCurrent())
1903 if (*inp->fCurrent ==
'/') {
1905 if (!inp->ShiftCurrent())
1907 if (!inp->SkipSpaces())
1909 Int_t len = inp->LocateIdentifier();
1925 if (!inp->ShiftCurrent(len))
1928 if (!inp->SkipSpaces())
1930 if (*inp->fCurrent !=
'>')
1932 if (!inp->ShiftCurrent())
1935 if (parent->fNs != 0)
1938 inp->SkipSpaces(
kTRUE);
1943 if (*inp->fCurrent ==
'!') {
1945 if (!inp->ShiftCurrent())
1947 if (!inp->CheckFor(
"DOCTYPE")) {
1951 if (!inp->SkipSpaces()) {
1957 Int_t len = inp->LocateIdentifier();
1962 if (!inp->ShiftCurrent(len)) {
1966 if (!inp->SkipSpaces()) {
1972 if (inp->CheckFor(
"[")) {
1973 if (!inp->SkipSpaces())
1976 if (inp->CheckFor(
"<!ENTITY")) {
1978 if (!inp->SkipSpaces()) {
1982 Int_t namelen = inp->LocateIdentifier();
1987 TString entity_name(inp->fCurrent, namelen);
1988 if (!inp->ShiftCurrent(namelen)) {
1992 if (!inp->SkipSpaces()) {
1997 if (inp->CheckFor(
"SYSTEM")) {
1998 if (!inp->SkipSpaces()) {
2005 Int_t valuelen = inp->LocateValue(0,
false);
2011 TString entity_value(inp->fCurrent + 1, valuelen - 2);
2013 if (!inp->ShiftCurrent(valuelen)) {
2018 if (*inp->fCurrent !=
'>') {
2022 if (!inp->ShiftCurrent()) {
2028 inp->AddEntity(
new TXMLEntity(entity_name, entity_value, is_system));
2032 if (inp->CheckFor(
"<!ELEMENT")) {
2034 if (!inp->SkipSpaces()) {
2038 Int_t namelen = inp->LocateIdentifier();
2044 if (!inp->ShiftCurrent(namelen)) {
2048 if (!inp->SkipSpaces()) {
2053 if (!inp->CheckFor(
"(")) {
2057 if (inp->SearchFor(
")") <= 0) {
2063 if (*inp->fCurrent !=
'>') {
2067 if (!inp->ShiftCurrent()) {
2079 if (!inp->CheckFor(
"]")) {
2085 if (!inp->CheckFor(
">")) {
2095 Bool_t canhaschildren =
true;
2096 char endsymbol =
'/';
2099 if (*inp->fCurrent ==
'?') {
2100 if (!inp->ShiftCurrent())
2103 canhaschildren =
false;
2107 if (!inp->SkipSpaces())
2109 Int_t len = inp->LocateIdentifier();
2114 node->fType = nodetype;
2116 strncpy(nameptr, inp->fCurrent, len);
2121 if ((colon != 0) && (parent != 0)) {
2127 if (!inp->ShiftCurrent(len))
2131 if (!inp->SkipSpaces())
2134 char nextsymb = *inp->fCurrent;
2136 if (nextsymb == endsymbol) {
2137 if (!inp->ShiftCurrent())
2139 if (*inp->fCurrent ==
'>') {
2140 if (!inp->ShiftCurrent())
2146 inp->SkipSpaces(
kTRUE);
2151 }
else if (nextsymb ==
'>') {
2152 if (!canhaschildren) {
2157 if (!inp->ShiftCurrent())
2162 }
while (resvalue == 2);
2164 if (resvalue == 1) {
2170 Int_t attrlen = inp->LocateIdentifier();
2176 int valuelen = inp->LocateValue(attrlen,
true);
2185 strncpy(attrname, inp->fCurrent, attrlen);
2186 attrname += attrlen;
2191 if (!inp->ShiftCurrent(attrlen + valuelen))
2196 if ((strlen(attrname) > 6) && (strstr(attrname,
"xmlns:") == attrname)) {
2201 if (node->fNs != 0) {
2219 case -14:
Error(
"ParseFile",
"Error include external XML file at line %d", linenumber);
break;
2220 case -13:
Error(
"ParseFile",
"Error processing DTD part of XML file at line %d", linenumber);
break;
2221 case -12:
Error(
"ParseFile",
"DOCTYPE missing after <! at line %d", linenumber);
break;
2223 Error(
"ParseFile",
"Node cannot be closed with > symbol at line %d, for instance <?xml ... ?> node", linenumber);
2226 Error(
"ParseFile",
"Error in xml comments definition at line %d, must be <!-- comments -->", linenumber);
2228 case -9:
Error(
"ParseFile",
"Multiple namespace definitions not allowed, line %d", linenumber);
break;
2229 case -8:
Error(
"ParseFile",
"Invalid namespace specification, line %d", linenumber);
break;
2230 case -7:
Error(
"ParseFile",
"Invalid attribute value, line %d", linenumber);
break;
2231 case -6:
Error(
"ParseFile",
"Invalid identifier for node attribute, line %d", linenumber);
break;
2232 case -5:
Error(
"ParseFile",
"Mismatch between open and close nodes, line %d", linenumber);
break;
2233 case -4:
Error(
"ParseFile",
"Unexpected close node, line %d", linenumber);
break;
2234 case -3:
Error(
"ParseFile",
"Valid identifier for close node is missing, line %d", linenumber);
break;
2235 case -2:
Error(
"ParseFile",
"No multiple content entries allowed, line %d", linenumber);
break;
2236 case -1:
Error(
"ParseFile",
"Unexpected end of xml file");
break;
2237 default:
Error(
"ParseFile",
"XML syntax error at line %d", linenumber);
break;
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
The TNamed class is the base class for all named ROOT classes.
Int_t GetLast() const
Return index of last object in array.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TString & Append(const char *cs)
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...
XMLNodePointer_t AllocateNode(int namelen, XMLNodePointer_t parent)
Allocates new xml node with specified name length.
const char * GetNSName(XMLNsPointer_t ns)
return name id of namespace
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
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
XMLNsPointer_t NewNS(XMLNodePointer_t xmlnode, const char *reference, const char *name=0)
create namespace 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...
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 DisplayError(Int_t error, Int_t linenumber)
Displays xml parsing error.
Bool_t AddComment(XMLNodePointer_t parent, const char *comment)
Adds comment line to the node.
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
void CleanNode(XMLNodePointer_t xmlnode)
remove all children node from xmlnode
void UnlinkNode(XMLNodePointer_t node)
unlink (detach) xmlnode from parent
void AssignDtd(XMLDocPointer_t xmldoc, const char *dtdname, const char *rootname)
assigns dtd filename to document
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
void AddChild(XMLNodePointer_t parent, XMLNodePointer_t child)
add child element to xmlnode
XMLAttrPointer_t NewIntAttr(XMLNodePointer_t xmlnode, const char *name, Int_t value)
create node attribute with integer value
Bool_t AddDocComment(XMLDocPointer_t xmldoc, const char *comment)
add comment line to the top of the document
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
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char *name)
checks if node has attribute of specified name
char * Makestr(const char *str)
creates char* variable with copy of provided string
Bool_t IsXmlNode(XMLNodePointer_t xmlnode)
return kTRUE is this is normal xmlnode
void SaveNode(XMLNodePointer_t xmlnode, TXMLOutputStream *out, Int_t layout, Int_t level)
stream data of xmlnode to output
Bool_t IsContentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
return next attribute in the list
XMLDocPointer_t ParseStream(TXMLInputStream *input)
parses content of the stream and tries to produce xml structures
XMLNodePointer_t ReadSingleNode(const char *src)
read single xmlnode from provided string
const char * GetNSReference(XMLNsPointer_t ns)
return reference id of namespace
char * Makenstr(const char *start, int len)
creates char* variable with copy of len symbols from provided string
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
const char * GetNodeContent(XMLNodePointer_t xmlnode)
get contents (if any) of xmlnode
XMLNsPointer_t GetNS(XMLNodePointer_t xmlnode)
return namespace attribute (if exists)
Bool_t IsEmptyNode(XMLNodePointer_t xmlnode)
return kTRUE is this is node with special data like comments to data processing instructions
Bool_t IsCommentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
const char * GetAttrName(XMLAttrPointer_t xmlattr)
return name of the attribute
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
return first attribute in the list, namespace (if exists) will be skipped
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
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...
XMLNodePointer_t ReadNode(XMLNodePointer_t xmlparent, TXMLInputStream *inp, Int_t &resvalue)
Tries to construct xml node from input stream.
void FreeAttr(XMLNodePointer_t xmlnode, const char *name)
remove attribute from xmlnode
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...
void OutputValue(char *value, TXMLOutputStream *out)
output value to output stream if symbols '<' '&' '>' '"' ''' appears in the string,...
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
Bool_t ValidateVersion(XMLDocPointer_t doc, const char *version=0)
check that first node is xml processing instruction with correct xml version number
void AddChildAfter(XMLNodePointer_t parent, XMLNodePointer_t child, XMLNodePointer_t afternode)
Insert new child node after already existing node.
Int_t GetIntAttr(XMLNodePointer_t node, const char *name)
returns value of attribute as integer
XMLDocPointer_t NewDoc(const char *version="1.0")
creates new xml document with provided version
XMLNsPointer_t FindNs(XMLNodePointer_t xmlnode, const char *nsname)
define if namespace of that name exists for xmlnode
void UnlinkFreeNode(XMLNodePointer_t xmlnode)
combined operation. Unlink node and free used memory
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
TXMLEngine()
if true, do not create comments nodes in document during parsing
XMLAttrPointer_t AllocateAttr(int namelen, int valuelen, XMLNodePointer_t xmlnode)
Allocate new attribute with specified name length and value length.
void TruncateNsExtension(XMLNodePointer_t xmlnode)
removes namespace extension of nodename
void UnpackSpecialCharacters(char *target, const char *source, int srclen)
unpack special symbols, used in xml syntax to code characters these symbols: '<' - <,...
void FreeAllAttr(XMLNodePointer_t xmlnode)
Free all attributes of the node.
virtual ~TXMLEngine()
destructor for TXMLEngine object
XMLDocPointer_t ParseString(const char *xmlstring)
parses content of string and tries to produce xml structures
void FreeNode(XMLNodePointer_t xmlnode)
release all memory, allocated from this node and destroys node itself
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.
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
return value of attribute
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
void SkipEmpty(XMLNodePointer_t &xmlnode)
Skip all current empty nodes and locate on first "true" node.
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
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
set main (root) node for document
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
returns parent of xmlnode
void AddChildFirst(XMLNodePointer_t parent, XMLNodePointer_t child)
add node as first child
void Init(TClassEdit::TInterpreterLookupHelper *helper)
static constexpr double ns