/usr/include/sbml/xml/XMLNode.h is in libsbml5-dev 5.12.0+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 | /**
* @file XMLNode.h
* @brief Class definition of XMLNode, a node in an XML document tree.
* @author Ben Bornstein
*
* <!--------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2013-2015 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution and
* also available online as http://sbml.org/software/libsbml/license.html
* ---------------------------------------------------------------------- -->
*
* @class XMLNode
* @sbmlbrief{core} A node in libSBML's XML document tree.
*
* LibSBML implements an XML abstraction layer. This layer presents a
* uniform XML interface to calling programs regardless of which underlying
* XML parser libSBML has actually been configured to use. The basic data
* object in the XML abstraction is a @em node, represented by XMLNode.
*
* An XMLNode can contain any number of children. Each child is another
* XMLNode, thereby forming a tree. The methods XMLNode::getNumChildren()
* and XMLNode::getChild(@if java long@endif) can be used to access the tree
* structure starting from a given node.
*
* Each XMLNode is subclassed from XMLToken, and thus has the same methods
* available as XMLToken. These methods include XMLToken::getNamespaces(),
* XMLToken::getPrefix(), XMLToken::getName(), XMLToken::getURI(), and
* XMLToken::getAttributes().
*
* @section xmlnode-str2xmlnode Conversion between an XML string and an XMLNode
*
* LibSBML provides the following utility functions for converting an XML
* string (e.g., <code><annotation>...</annotation></code>)
* to/from an XMLNode object.
*
* @li XMLNode::toXMLString() returns a string representation of the XMLNode
* object.
*
* @li XMLNode::convertXMLNodeToString(@if java XMLNode@endif) (static
* function) returns a string representation of the given XMLNode object.
*
* @li XMLNode::convertStringToXMLNode(@if java String@endif) (static
* function) returns an XMLNode object converted from the given XML string.
*
* The returned XMLNode object by XMLNode::convertStringToXMLNode(@if java
* String@endif) is a dummy root (container) XMLNode if the given XML string
* has two or more top-level elements (e.g.,
* "<code><p>...</p><p>...</p></code>"). In
* the dummy root node, each top-level element in the given XML string is
* contained as a child XMLNode. XMLToken::isEOF() can be used to identify
* if the returned XMLNode object is a dummy node or not. Here is an
* example:
@if cpp
@code{.cpp}
// Checks if the XMLNode object returned by XMLNode::convertStringToXMLNode()
// is a dummy root node:
std::string str = "...";
XMLNode* xn = XMLNode::convertStringToXMLNode(str);
if ( xn == NULL )
{
// returned value is null (error)
...
}
else if ( xn->isEOF() )
{
// Root node is a dummy node.
for ( int i = 0; i < xn->getNumChildren(); i++ )
{
// access to each child node of the dummy node.
XMLNode& xnChild = xn->getChild(i);
...
}
}
else
{
// Root node is NOT a dummy node.
...
}
@endcode
@endif
@if java
@code{.java}
// Checks if the returned XMLNode object is a dummy root node:
String str = "...";
XMLNode xn = XMLNode.convertStringToXMLNode(str);
if ( xn == null )
{
// returned value is null (error)
...
}
else if ( xn.isEOF() )
{
// Root node is a dummy node.
for ( int i = 0; i < xn.getNumChildren(); i++ )
{
// access to each child node of the dummy node.
XMLNode xnChild = xn.getChild(i);
...
}
}
else
{
// Root node is NOT a dummy node.
...
}
@endcode
@endif
@if python
@code{.py}
xn = XMLNode.convertStringToXMLNode("<p></p>")
if xn == None:
# Do something to handle exceptional situation.
elif xn.isEOF():
# Node is a dummy node.
else:
# None is not a dummy node.
@endcode
@endif
*
*/
#ifndef XMLNode_h
#define XMLNode_h
#include <sbml/xml/XMLExtern.h>
#include <sbml/xml/XMLToken.h>
#include <sbml/common/sbmlfwd.h>
#ifdef __cplusplus
#include <vector>
#include <cstdlib>
LIBSBML_CPP_NAMESPACE_BEGIN
/** @cond doxygenLibsbmlInternal */
class XMLInputStream;
class XMLOutputStream;
/** @endcond */
class LIBLAX_EXTERN XMLNode : public XMLToken
{
public:
/**
* Creates a new empty XMLNode with no children.
*/
XMLNode ();
/**
* Creates a new XMLNode by copying an XMLToken object.
*
* @param token XMLToken to be copied to XMLNode
*/
XMLNode (const XMLToken& token);
/**
* Creates a new start element XMLNode with the given set of attributes and
* namespace declarations.
*
* @param triple XMLTriple.
* @param attributes XMLAttributes, the attributes to set.
* @param namespaces XMLNamespaces, the namespaces to set.
* @param line an unsigned int, the line number (default = 0).
* @param column an unsigned int, the column number (default = 0).
*
* @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif@~
*/
XMLNode ( const XMLTriple& triple
, const XMLAttributes& attributes
, const XMLNamespaces& namespaces
, const unsigned int line = 0
, const unsigned int column = 0 );
/**
* Creates a start element XMLNode with the given set of attributes.
*
* @param triple XMLTriple.
* @param attributes XMLAttributes, the attributes to set.
* @param line an unsigned int, the line number (default = 0).
* @param column an unsigned int, the column number (default = 0).
*
* @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif@~
*/
XMLNode ( const XMLTriple& triple
, const XMLAttributes& attributes
, const unsigned int line = 0
, const unsigned int column = 0 );
/**
* Creates an end element XMLNode.
*
* @param triple XMLTriple.
* @param line an unsigned int, the line number (default = 0).
* @param column an unsigned int, the column number (default = 0).
*
* @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif@~
*/
XMLNode ( const XMLTriple& triple
, const unsigned int line = 0
, const unsigned int column = 0 );
/**
* Creates a text XMLNode.
*
* @param chars a string, the text to be added to the XMLToken
* @param line an unsigned int, the line number (default = 0).
* @param column an unsigned int, the column number (default = 0).
*
* @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif@~
*/
XMLNode ( const std::string& chars
, const unsigned int line = 0
, const unsigned int column = 0 );
/** @cond doxygenLibsbmlInternal */
/**
* Creates a new XMLNode by reading XMLTokens from stream.
*
* The stream must be positioned on a start element
* (<code>stream.peek().isStart() == true</code>) and will be read until
* the matching end element is found.
*
* @param stream XMLInputStream from which XMLNode is to be created.
*/
XMLNode (XMLInputStream& stream);
/** @endcond */
/**
* Destroys this XMLNode.
*/
virtual ~XMLNode ();
/**
* Copy constructor; creates a copy of this XMLNode.
*
* @param orig the XMLNode instance to copy.
*/
XMLNode(const XMLNode& orig);
/**
* Assignment operator for XMLNode.
*
* @param rhs The XMLNode object whose values are used as the basis
* of the assignment.
*/
XMLNode& operator=(const XMLNode& rhs);
/**
* Creates and returns a deep copy of this XMLNode object.
*
* @return the (deep) copy of this XMLNode object.
*/
XMLNode* clone () const;
/**
* Adds a copy of @p node as a child of this XMLNode.
*
* The given @p node is added at the end of the list of children.
*
* @param node the XMLNode to be added as child.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
*
* @note The given node is added at the end of the children list.
*/
int addChild (const XMLNode& node);
/**
* Inserts a copy of the given node as the <code>n</code>th child of this
* XMLNode.
*
* If the given index @p n is out of range for this XMLNode instance,
* the @p node is added at the end of the list of children. Even in
* that situation, this method does not throw an error.
*
* @param n an integer, the index at which the given node is inserted
* @param node an XMLNode to be inserted as <code>n</code>th child.
*
* @return a reference to the newly-inserted child @p node
*/
XMLNode& insertChild (unsigned int n, const XMLNode& node);
/**
* Removes the <code>n</code>th child of this XMLNode and returns the
* removed node.
*
* It is important to keep in mind that a given XMLNode may have more
* than one child. Calling this method erases all existing references to
* child nodes @em after the given position @p n. If the index @p n is
* greater than the number of child nodes in this XMLNode, this method
* takes no action (and returns @c NULL).
*
* @param n an integer, the index of the node to be removed
*
* @return the removed child, or @c NULL if @p n is greater than the number
* of children in this node
*
* @note The caller owns the returned node and is responsible for deleting it.
*/
XMLNode* removeChild(unsigned int n);
/**
* Removes all children from this node.
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
*/
int removeChildren();
/**
* Returns the <code>n</code>th child of this XMLNode.
*
* If the index @p n is greater than the number of child nodes,
* this method returns an empty node.
*
* @param n an unsigned integer, the index of the node to return
*
* @return the <code>n</code>th child of this XMLNode.
*/
XMLNode& getChild (unsigned int n);
/**
* Returns the <code>n</code>th child of this XMLNode.
*
* If the index @p n is greater than the number of child nodes,
* this method returns an empty node.
*
* @param n an unsigned integer, the index of the node to return
*
* @return the <code>n</code>th child of this XMLNode.
*/
const XMLNode& getChild (unsigned int n) const;
/**
* Returns the first child of this XMLNode with the corresponding name.
*
* If no child with corrsponding name can be found,
* this method returns an empty node.
*
* @param name the name of the node to return
*
* @return the first child of this XMLNode with given name.
*/
XMLNode& getChild (const std::string& name);
/**
* Returns the first child of this XMLNode with the corresponding name.
*
* If no child with corrsponding name can be found,
* this method returns an empty node.
*
* @param name the name of the node to return
*
* @return the first child of this XMLNode with given name.
*/
const XMLNode& getChild (const std::string& name) const;
/**
* Return the index of the first child of this XMLNode with the given name.
*
* @param name a string, the name of the child for which the
* index is required.
*
* @return the index of the first child of this XMLNode with the given
* name, or -1 if not present.
*/
int getIndex (const std::string& name) const;
/**
* Return a boolean indicating whether this XMLNode has a child with the
* given name.
*
* @param name a string, the name of the child to be checked.
*
* @return boolean indicating whether this XMLNode has a child with the
* given name.
*/
bool hasChild (const std::string& name) const;
/**
* Compare this XMLNode against another XMLNode returning true if both
* nodes represent the same XML tree, or false otherwise.
*
* @param other another XMLNode to compare against.
*
* @param ignoreURI whether to ignore the namespace URI when doing the
* comparison.
*
* @return boolean indicating whether this XMLNode represents the same XML
* tree as another.
*/
bool equals(const XMLNode& other, bool ignoreURI=false) const;
/**
* Returns the number of children for this XMLNode.
*
* @return the number of children for this XMLNode.
*/
unsigned int getNumChildren () const;
/** @cond doxygenLibsbmlInternal */
/**
* Writes this XMLNode and its children to stream.
*
* @param stream XMLOutputStream, stream to which this XMLNode
* is to be written.
*/
void write (XMLOutputStream& stream) const;
/** @endcond */
/**
* Returns a string representation of this XMLNode.
*
* @return a string derived from this XMLNode.
*/
std::string toXMLString() const;
/**
* Returns a string representation of a given XMLNode.
*
* @param node the XMLNode to be represented as a string
*
* @return a string-form representation of @p node
*/
static std::string convertXMLNodeToString(const XMLNode* node);
/**
* Returns an XMLNode which is derived from a string containing XML
* content.
*
* The XML namespace must be defined using argument @p xmlns if the
* corresponding XML namespace attribute is not part of the string of the
* first argument.
*
* @param xmlstr string to be converted to a XML node.
* @param xmlns XMLNamespaces the namespaces to set (default value is @c NULL).
*
* @note The caller owns the returned XMLNode and is reponsible for
* deleting it. The returned XMLNode object is a dummy root (container)
* XMLNode if the top-level element in the given XML string is NOT
* <code><html></code>, <code><body></code>,
* <code><annotation></code>, or <code><notes></code>. In
* the dummy root node, each top-level element in the given XML string is
* contained as a child XMLNode. XMLToken::isEOF() can be used to
* identify if the returned XMLNode object is a dummy node.
*
* @return a XMLNode which is converted from string @p xmlstr. If the
* conversion failed, this method returns @c NULL.
*
* @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif@~
*/
static XMLNode* convertStringToXMLNode(const std::string& xmlstr,
const XMLNamespaces* xmlns = NULL);
#ifndef SWIG
/** @cond doxygenLibsbmlInternal */
/**
* Inserts this XMLNode and its children into stream.
*
* @param stream XMLOutputStream, stream to which the XMLNode
* is to be written.
* @param node XMLNode, node to be written to stream.
*
* @return the stream with the node inserted.
*/
LIBLAX_EXTERN
friend
XMLOutputStream& operator<< (XMLOutputStream& stream, const XMLNode& node);
/** @endcond */
#endif /* !SWIG */
protected:
/** @cond doxygenLibsbmlInternal */
std::vector<XMLNode*> mChildren;
/** @endcond */
};
LIBSBML_CPP_NAMESPACE_END
#endif /* __cplusplus */
#ifndef SWIG
LIBSBML_CPP_NAMESPACE_BEGIN
BEGIN_C_DECLS
/**
* Creates a new empty XMLNode_t structure with no children
* and returns a pointer to it.
*
* @return pointer to the new XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_create (void);
/**
* Creates a new XMLNode_t structure by copying token and returns a pointer
* to it.
*
* @param token XMLToken_t structure to be copied to XMLNode_t structure.
*
* @return pointer to the new XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_createFromToken (const XMLToken_t *token);
/**
* Creates a new start element XMLNode_t structure with XMLTriple_t
* and XMLAttributes_t structures set and returns a pointer to it.
*
* @param triple XMLTriple_t structure to be set.
* @param attr XMLAttributes_t structure to be set.
*
* @return pointer to new XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_createStartElement (const XMLTriple_t *triple,
const XMLAttributes_t *attr);
/**
* Creates a new start element XMLNode_t structure with XMLTriple_t,
* XMLAttributes_t and XMLNamespaces_t structures set and returns a
* pointer to it.
*
* @param triple XMLTriple_t structure to be set.
* @param attr XMLAttributes_t structure to be set.
* @param ns XMLNamespaces_t structure to be set.
*
* @return pointer to new XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_createStartElementNS (const XMLTriple_t *triple,
const XMLAttributes_t *attr,
const XMLNamespaces_t *ns);
/**
* Creates a new end element XMLNode_t structure with XMLTriple_t
* structure set and returns a pointer to it.
*
* @param triple XMLTriple_t structure to be set.
*
* @return pointer to new XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_createEndElement (const XMLTriple_t *triple);
/**
* Creates a text XMLNode_t. Defaults to creating the node with a line number of 0 and a column number of 0.
*
* @param text the text to be added to the XMLToken_t
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_createTextNode (const char *text);
/**
* Creates a deep copy of the given XMLNode_t structure
*
* @param n the XMLNode_t structure to be copied
*
* @return a (deep) copy of the given XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_clone (const XMLNode_t* n);
/**
* Destroys this XMLNode_t structure.
*
* @param node XMLNode_t structure to be freed.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
void
XMLNode_free (XMLNode_t *node);
/**
* Adds a copy of child node to this XMLNode_t structure.
*
* @param node XMLNode_t structure to which child is to be added.
* @param child XMLNode_t structure to be added as child.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_addChild (XMLNode_t *node, const XMLNode_t *child);
/**
* Inserts a copy of child node to this XMLNode_t structure.
*
* @param node XMLNode_t structure to which child is to be added.
* @param n the index at which the given node is inserted
* @param child XMLNode_t structure to be inserted as nth child.
*
* @return the newly inserted child in this XMLNode_t.
* NULL will be returned if the given child is NULL.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t*
XMLNode_insertChild (XMLNode_t *node, unsigned int n, const XMLNode_t *child);
/**
* Removes the nth child of this XMLNode_t and returned the removed node.
*
* @param node XMLNode_t structure to which child is to be removed.
* @param n the index of the node to be removed
*
* @return the removed child, or NULL if the given index is out of range.
*
* @note This function invalidates all existing references to child nodes
* after the position or first.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t*
XMLNode_removeChild(XMLNode_t *node, unsigned int n);
/**
* Removes all children from this node.
*
* @param node XMLNode_t structure whose children to remove.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeChildren (XMLNode_t *node);
/**
* Returns the text of this element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the characters of this XML text.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const char *
XMLNode_getCharacters (const XMLNode_t *node);
/**
* Sets the XMLTripe_t (name, uri and prefix) of this XML element.
* Nothing will be done if this XML element is a text node.
*
* @param node XMLNode_t structure to which the triple to be added.
* @param triple an XMLTriple_t, the XML triple to be set to this XML element.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_setTriple(XMLNode_t *node, const XMLTriple_t *triple);
/**
* Returns the (unqualified) name of this XML element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the (unqualified) name of this XML element.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const char *
XMLNode_getName (const XMLNode_t *node);
/**
* Returns the namespace prefix of this XML element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the namespace prefix of this XML element.
*
* @note If no prefix
* exists, an empty string will be return.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const char *
XMLNode_getPrefix (const XMLNode_t *node);
/**
* Returns the namespace URI of this XML element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the namespace URI of this XML element.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const char *
XMLNode_getURI (const XMLNode_t *node);
/**
* Returns the nth child of this XMLNode_t structure.
*
* @param node XMLNode_t structure to be queried.
* @param n the index of the node to return
*
* @return the nth child of this XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const XMLNode_t *
XMLNode_getChild (const XMLNode_t *node, const int n);
/**
* Returns the (non-const) nth child of this XMLNode_t structure.
*
* @param node XMLNode_t structure to be queried.
* @param n the index of the node to return
*
* @return the non-const nth child of this XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_getChildNC (XMLNode_t *node, const unsigned int n);
/**
* Returns the (non-const) the first child of the XMLNode_t structure node with the given name.
*
* If no child with corrsponding name can be found,
* this method returns an empty node.
*
* @param node XMLNode_t structure to be queried.
* @param name the name of the node to return
*
* @return the first child of this XMLNode_t with given name.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_getChildForNameNC (XMLNode_t *node, const char* name);
/**
* Returns the first child of the XMLNode_t structure node with the given name.
*
* If no child with corrsponding name can be found,
* this method returns an empty node.
*
* @param node XMLNode_t structure to be queried.
* @param name the name of the node to return
*
* @return the first child of this XMLNode_t with given name.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const XMLNode_t *
XMLNode_getChildForName (const XMLNode_t *node, const char* name);
/**
* Return the index of the first child of the XMLNode_t structure node with the given name.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the name of the child for which the
* index is required.
*
* @return the index of the first child of node with the given name, or -1 if not present.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getIndex (const XMLNode_t *node, const char* name);
/**
* Return a boolean indicating whether node has a child with the given name.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the name of the child to be checked.
*
* @return true (non-zero) if this node has a child with the given name false (zero) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasChild (const XMLNode_t *node, const char* name);
/**
* Compare one XMLNode against another XMLNode returning true (non-zero) if both nodes
* represent the same XML tree, or false (zero) otherwise.
*
*
* @param node the original XMLNode_t structure
* @param other another XMLNode_t to compare against
*
* @return true (non-zero) if both nodes
* represent the same XML tree, or false (zero) otherwise
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_equals(const XMLNode_t *node, const XMLNode_t* other);
/**
* Returns the number of children for this XMLNode_t structure.
*
* @param node XMLNode_t structure to be queried.
*
* @return the number of children for this XMLNode_t structure.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
unsigned int
XMLNode_getNumChildren (const XMLNode_t *node);
/**
* Returns the attributes of this element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the XMLAttributes_t of this XML element.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const XMLAttributes_t *
XMLNode_getAttributes (const XMLNode_t *node);
/**
* Sets an XMLAttributes_t to this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to which attributes to be set.
* @param attributes XMLAttributes to be set to this XMLNode_t.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @note This function replaces the existing XMLAttributes_t with the new one.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_setAttributes (XMLNode_t *node, const XMLAttributes_t* attributes);
/**
* Adds an attribute with the given local name to the attribute set in this XMLNode_t.
* (namespace URI and prefix are empty)
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to which an attribute to be added.
* @param name a string, the local name of the attribute.
* @param value a string, the value of the attribute.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @note if the local name without namespace URI already exists in the
* attribute set, its value will be replaced.
*
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_addAttr ( XMLNode_t *node, const char* name, const char* value );
/**
* Adds an attribute with a prefix and namespace URI to the attribute set
* in this XMLNode_t optionally
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to which an attribute to be added.
* @param name a string, the local name of the attribute.
* @param value a string, the value of the attribute.
* @param namespaceURI a string, the namespace URI of the attribute.
* @param prefix a string, the prefix of the namespace
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @note if local name with the same namespace URI already exists in the
* attribute set, its value and prefix will be replaced.
*
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_addAttrWithNS ( XMLNode_t *node, const char* name
, const char* value
, const char* namespaceURI
, const char* prefix );
/**
* Adds an attribute with the given XMLTriple/value pair to the attribute set
* in this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @note if local name with the same namespace URI already exists in the
* attribute set, its value and prefix will be replaced.
*
* @param node XMLNode_t structure to which an attribute to be added.
* @param triple an XMLTriple_t, the XML triple of the attribute.
* @param value a string, the value of the attribute.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_addAttrWithTriple (XMLNode_t *node, const XMLTriple_t *triple, const char* value);
/**
* Removes an attribute with the given index from the attribute set in
* this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure from which an attribute to be removed.
* @param n an integer the index of the resource to be deleted
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeAttr (XMLNode_t *node, int n);
/**
* Removes an attribute with the given local name (without namespace URI)
* from the attribute set in this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure from which an attribute to be removed.
* @param name a string, the local name of the attribute.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeAttrByName (XMLNode_t *node, const char* name);
/**
* Removes an attribute with the given local name and namespace URI from
* the attribute set in this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure from which an attribute to be removed.
* @param name a string, the local name of the attribute.
* @param uri a string, the namespace URI of the attribute.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeAttrByNS (XMLNode_t *node, const char* name, const char* uri);
/**
* Removes an attribute with the given XMLTriple_t from the attribute set
* in this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure from which an attribute to be removed.
* @param triple an XMLTriple_t, the XML triple of the attribute.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeAttrByTriple (XMLNode_t *node, const XMLTriple_t *triple);
/**
* Clears (deletes) all attributes in this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure from which attributes to be cleared.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_clearAttributes(XMLNode_t *node);
/**
* Return the index of an attribute with the given local name and namespace URI.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the local name of the attribute.
* @param uri a string, the namespace URI of the attribute.
*
* @return the index of an attribute with the given local name and namespace URI,
* or -1 if not present.
*
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getAttrIndex (const XMLNode_t *node, const char* name, const char* uri);
/**
* Return the index of an attribute with the given XMLTriple_t.
*
* @param node XMLNode_t structure to be queried.
* @param triple an XMLTriple_t, the XML triple of the attribute for which
* the index is required.
*
* @return the index of an attribute with the given XMLTriple_t, or -1 if not present.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getAttrIndexByTriple (const XMLNode_t *node, const XMLTriple_t *triple);
/**
* Return the number of attributes in the attributes set.
*
* @param node XMLNode_t structure to be queried.
*
* @return the number of attributes in the attributes set in this XMLNode_t.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getAttributesLength (const XMLNode_t *node);
/**
* Return the local name of an attribute in the attributes set in this
* XMLNode_t (by position).
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute whose local name
* is required.
*
* @return the local name of an attribute in this list (by position).
*
* @note If index
* is out of range, an empty string will be returned. Use XMLNode_hasAttr(...)
* to test for the attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrName (const XMLNode_t *node, int index);
/**
* Return the prefix of an attribute in the attribute set in this
* XMLNode (by position).
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute whose prefix is
* required.
*
* @return the namespace prefix of an attribute in the attribute set
* (by position).
*
* @note If index is out of range, an empty string will be
* returned. Use XMLNode_hasAttr(...) to test for the attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrPrefix (const XMLNode_t *node, int index);
/**
* Return the prefixed name of an attribute in the attribute set in this
* XMLNode (by position).
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute whose prefixed
* name is required.
*
* @return the prefixed name of an attribute in the attribute set
* (by position).
*
* @note If index is out of range, an empty string will be
* returned. Use XMLNode_hasAttr(...) to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrPrefixedName (const XMLNode_t *node, int index);
/**
* Return the namespace URI of an attribute in the attribute set in this
* XMLNode (by position).
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute whose namespace
* URI is required.
*
* @return the namespace URI of an attribute in the attribute set (by position).
*
* @note If index is out of range, an empty string will be returned. Use
* XMLNode_hasAttr(index) to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrURI (const XMLNode_t *node, int index);
/**
* Return the value of an attribute in the attribute set in this XMLNode_t
* (by position).
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute whose value is
* required.
*
* @return the value of an attribute in the attribute set (by position).
*
* @note If index
* is out of range, an empty string will be returned. Use XMLNode_hasAttr(...)
* to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrValue (const XMLNode_t *node, int index);
/**
* Return a value of an attribute with the given local name (without namespace URI).
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the local name of the attribute whose value is required.
*
* @return The attribute value as a string.
*
* @note If an attribute with the given local name (without namespace URI)
* does not exist, an empty string will be returned.
* Use XMLNode_hasAttr(...) to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrValueByName (const XMLNode_t *node, const char* name);
/**
* Return a value of an attribute with the given local name and namespace URI.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the local name of the attribute whose value is required.
* @param uri a string, the namespace URI of the attribute.
*
* @return The attribute value as a string.
*
* @note If an attribute with the
* given local name and namespace URI does not exist, an empty string will be
* returned.
* Use XMLNode_hasAttr(name, uri) to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrValueByNS (const XMLNode_t *node, const char* name, const char* uri);
/**
* Return a value of an attribute with the given XMLTriple_t.
*
* @param node XMLNode_t structure to be queried.
* @param triple an XMLTriple_t, the XML triple of the attribute whose
* value is required.
*
* @return The attribute value as a string.
*
* @note If an attribute with the
* given XMLTriple_t does not exist, an empty string will be returned.
* Use XMLNode_hasAttr(...) to test for attribute existence.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getAttrValueByTriple (const XMLNode_t *node, const XMLTriple_t *triple);
/**
* Predicate returning @c true or @c false depending on whether
* an attribute with the given index exists in the attribute set in this
* XMLNode.
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, the position of the attribute.
*
* @return @c non-zero (true) if an attribute with the given index exists in
* the attribute set in this XMLNode_t, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasAttr (const XMLNode_t *node, int index);
/**
* Predicate returning @c true or @c false depending on whether
* an attribute with the given local name (without namespace URI)
* exists in the attribute set in this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the local name of the attribute.
*
* @return @c non-zero (true) if an attribute with the given local name
* (without namespace URI) exists in the attribute set in this XMLNode_t,
* @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasAttrWithName (const XMLNode_t *node, const char* name);
/**
* Predicate returning @c true or @c false depending on whether
* an attribute with the given local name and namespace URI exists
* in the attribute set in this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
* @param name a string, the local name of the attribute.
* @param uri a string, the namespace URI of the attribute.
*
* @return @c non-zero (true) if an attribute with the given local name
* and namespace URI exists in the attribute set in this XMLNode_t,
* @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasAttrWithNS (const XMLNode_t *node, const char* name, const char* uri);
/**
* Predicate returning @c true or @c false depending on whether
* an attribute with the given XML triple exists in the attribute set in
* this XMLNode_t
*
* @param node XMLNode_t structure to be queried.
* @param triple an XMLTriple_t, the XML triple of the attribute
*
* @return @c non-zero (true) if an attribute with the given XML triple exists
* in the attribute set in this XMLNode_t, @c zero (false) otherwise.
*
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasAttrWithTriple (const XMLNode_t *node, const XMLTriple_t *triple);
/**
* Predicate returning @c true or @c false depending on whether
* the attribute set in this XMLNode_t set is empty.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if the attribute set in this XMLNode_t is empty,
* @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isAttributesEmpty (const XMLNode_t *node);
/**
* Returns the XML namespace declarations for this XML element.
*
* @param node XMLNode_t structure to be queried.
*
* @return the XML namespace declarations for this XML element.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const XMLNamespaces_t *
XMLNode_getNamespaces (const XMLNode_t *node);
/**
* Sets an XMLnamespaces_t to this XML element.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to be queried.
* @param namespaces XMLNamespaces_t to be set to this XMLNode_t.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @note This function replaces the existing XMLNamespaces_t with the new one.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_setNamespaces(XMLNode_t *node, const XMLNamespaces_t* namespaces);
/**
* Appends an XML namespace prefix and URI pair to this XMLNode_t.
* If there is an XML namespace with the given prefix in this XMLNode_t,
* then the existing XML namespace will be overwritten by the new one.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to be queried.
* @param uri a string, the uri for the namespace
* @param prefix a string, the prefix for the namespace
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_addNamespace (XMLNode_t *node, const char* uri, const char* prefix);
/**
* Removes an XML Namespace stored in the given position of the XMLNamespaces_t
* of this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, position of the removed namespace.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeNamespace (XMLNode_t *node, int index);
/**
* Removes an XML Namespace with the given prefix.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to be queried.
* @param prefix a string, prefix of the required namespace.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INDEX_EXCEEDS_SIZE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_removeNamespaceByPrefix (XMLNode_t *node, const char* prefix);
/**
* Clears (deletes) all XML namespace declarations in the XMLNamespaces_t
* of this XMLNode_t.
* Nothing will be done if this XMLNode_t is not a start element.
*
* @param node XMLNode_t structure to be queried.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_XML_OPERATION, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_clearNamespaces (XMLNode_t *node);
/**
* Look up the index of an XML namespace declaration by URI.
*
* @param node XMLNode_t structure to be queried.
* @param uri a string, uri of the required namespace.
*
* @return the index of the given declaration, or -1 if not present.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getNamespaceIndex (const XMLNode_t *node, const char* uri);
/**
* Look up the index of an XML namespace declaration by prefix.
*
* @param node XMLNode_t structure to be queried.
* @param prefix a string, prefix of the required namespace.
*
* @return the index of the given declaration, or -1 if not present.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getNamespaceIndexByPrefix (const XMLNode_t *node, const char* prefix);
/**
* Returns the number of XML namespaces stored in the XMLNamespaces_t
* of this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
*
* @return the number of namespaces in this list.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_getNamespacesLength (const XMLNode_t *node);
/**
* Look up the prefix of an XML namespace declaration by position.
*
* Callers should use getNamespacesLength() to find out how many
* namespaces are stored in the XMLNamespaces.
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, position of the removed namespace.
*
* @return the prefix of an XML namespace declaration in the XMLNamespaces_t
* (by position).
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getNamespacePrefix (const XMLNode_t *node, int index);
/**
* Look up the prefix of an XML namespace declaration by its URI.
*
* @param node XMLNode_t structure to be queried.
* @param uri a string, uri of the required namespace.
*
* @return the prefix of an XML namespace declaration given its URI.
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getNamespacePrefixByURI (const XMLNode_t *node, const char* uri);
/**
* Look up the URI of an XML namespace declaration by its position.
*
* @param node XMLNode_t structure to be queried.
* @param index an integer, position of the removed namespace.
*
* @return the URI of an XML namespace declaration in the XMLNamespaces_t
* (by position).
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getNamespaceURI (const XMLNode_t *node, int index);
/**
* Look up the URI of an XML namespace declaration by its prefix.
*
* @param node XMLNode_t structure to be queried.
* @param prefix a string, prefix of the required namespace.
*
* @return the URI of an XML namespace declaration given its prefix.
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char*
XMLNode_getNamespaceURIByPrefix (const XMLNode_t *node, const char* prefix);
/**
* Predicate returning @c true or @c false depending on whether
* the XMLNamespaces_t of this XMLNode_t is empty.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if the XMLNamespaces_t of this XMLNode_t is empty,
* @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isNamespacesEmpty (const XMLNode_t *node);
/**
* Predicate returning @c true or @c false depending on whether
* an XML Namespace with the given URI is contained in the XMLNamespaces_t of
* this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
* @param uri a string, the uri for the namespace
*
* @return @c no-zero (true) if an XML Namespace with the given URI is
* contained in the XMLNamespaces_t of this XMLNode_t, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasNamespaceURI(const XMLNode_t *node, const char* uri);
/**
* Predicate returning @c true or @c false depending on whether
* an XML Namespace with the given prefix is contained in the XMLNamespaces_t of
* this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
* @param prefix a string, the prefix for the namespace
*
* @return @c no-zero (true) if an XML Namespace with the given URI is
* contained in the XMLNamespaces_t of this XMLNode_t, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasNamespacePrefix(const XMLNode_t *node, const char* prefix);
/**
* Predicate returning @c true or @c false depending on whether
* an XML Namespace with the given uri/prefix pair is contained in the
* XMLNamespaces_t of this XMLNode_t.
*
* @param node XMLNode_t structure to be queried.
* @param uri a string, the uri for the namespace
* @param prefix a string, the prefix for the namespace
*
* @return @c non-zero (true) if an XML Namespace with the given uri/prefix pair is
* contained in the XMLNamespaces_t of this XMLNode_t, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_hasNamespaceNS(const XMLNode_t *node, const char* uri, const char* prefix);
/**
* Returns a string which is converted from a given XMLNode_t.
*
* @param node XMLNode_t to be converted to a string.
*
* @return a string (char*) which is converted from a given XMLNode_t.
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
char *
XMLNode_toXMLString(const XMLNode_t *node);
/**
* Returns a string which is converted from a given XMLNode_t.
*
* @param node XMLNode_t to be converted to a string.
*
* @return a string (char*) which is converted from a given XMLNode_t.
*
* @note returned char* should be freed with safe_free() by the caller.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
const char *
XMLNode_convertXMLNodeToString(const XMLNode_t *node);
/**
* Returns an XMLNode_t pointer which is converted from a given string containing
* XML content.
*
* XMLNamespaces (the second argument) must be given if the corresponding
* xmlns attribute is not included in the string of the first argument.
*
* @param xml string to be converted to a XML node.
* @param xmlns XMLNamespaces_t structure the namespaces to set.
*
* @return pointer to XMLNode_t structure which is converted from a given string.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
XMLNode_t *
XMLNode_convertStringToXMLNode(const char * xml, const XMLNamespaces_t* xmlns);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an XML element.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if this XMLNode_t structure is an XML element, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isElement (const XMLNode_t *node);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an XML end element.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if this XMLNode_t structure is an XML end element, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isEnd (const XMLNode_t *node);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an XML end element for the given start element.
*
* @param node XMLNode_t structure to be queried.
* @param element XMLNode_t structure, element for which query is made.
*
* @return @c non-zero (true) if this XMLNode_t structure is an XML end element for the given
* XMLNode_t structure start element, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isEndFor (const XMLNode_t *node, const XMLNode_t *element);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an end of file marker.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if this XMLNode_t structure is an end of file (input) marker, @c zero (false)
* otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isEOF (const XMLNode_t *node);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an XML start element.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c true if this XMLNode_t structure is an XML start element, @c false otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isStart (const XMLNode_t *node);
/**
* Predicate returning @c true or @c false depending on whether
* this XMLNode_t structure is an XML text element.
*
* @param node XMLNode_t structure to be queried.
*
* @return @c non-zero (true) if this XMLNode_t structure is an XML text element, @c zero (false) otherwise.
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_isText (const XMLNode_t *node);
/**
* Declares this XML start element is also an end element.
*
* @param node XMLNode_t structure to be set.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_setEnd (XMLNode_t *node);
/**
* Declares this XMLNode_t structure is an end-of-file (input) marker.
*
* @param node XMLNode_t structure to be set.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_setEOF (XMLNode_t *node);
/**
* Declares this XML start/end element is no longer an end element.
*
* @param node XMLNode_t structure to be set.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
*
* @memberof XMLNode_t
*/
LIBLAX_EXTERN
int
XMLNode_unsetEnd (XMLNode_t *node);
END_C_DECLS
LIBSBML_CPP_NAMESPACE_END
#endif /* !SWIG */
#endif /* XMLNode_h */
|