void XmlWriter::write(const NodePtr nodeArg) { NodePtr node = nodeArg; indent+=2; NamedNodeMap attributes = node->getAttributes(); int nrAttrs = attributes.getLength(); //### Start open tag spaces(); po("<"); pos(node->getNodeName()); if (nrAttrs>0) po("\n"); //### Attributes for (int i=0 ; i<nrAttrs ; i++) { NodePtr attr = attributes.item(i); spaces(); pos(attr->getNodeName()); po("=\""); pos(attr->getNodeValue()); po("\"\n"); } //### Finish open tag if (nrAttrs>0) spaces(); po(">\n"); //### Contents spaces(); pos(node->getNodeValue()); //### Children for (NodePtr child = node->getFirstChild() ; child.get() ; child=child->getNextSibling()) { write(child); } //### Close tag spaces(); po("</"); pos(node->getNodeName()); po(">\n"); indent-=2; }
void dumpattrs(Node *node) { NamedNodeMap *attrs; Attr *a; uword i; size_t na; oratext *qname; oratext *namespce; oratext *local; oratext *prefix; oratext *value; if (attrs = node->getAttributes()) { cout << "\n ATTRIBUTES: \n"; for (na = attrs->getLength(), i = 0; i < na; i++) { /* get attr qualified name, local name, namespace, and prefix */ a = (Attr *)attrs->item(i); qname = namespce = local = prefix = value = (oratext*)" "; if (a->getQualifiedName() != (oratext*)NULL) qname = a->getQualifiedName(); if (a->getNamespace() != (oratext*)NULL) namespce = a->getNamespace(); if (a->getLocal() != (oratext*)NULL) local = a->getLocal(); if (a->getPrefix() != (oratext*)NULL) prefix = a->getPrefix(); if (a->getValue() != (oratext*)NULL) value = a->getValue(); cout << " " << (char*)qname << " = " << (char*)value << "\n"; cout << " Namespace : " << (char*)namespce << "\n"; cout << " Local Name: " << (char*)local << "\n"; cout << " Prefix : " << (char*)prefix << "\n\n"; } } cout << "\n"; }
/* * Runs the test case. */ void runTest() { Document doc; DocumentType docType; NamedNodeMap notationList; Node notation; int notationType; doc = (Document) baseT::load("staff", false); docType = doc.getDoctype(); baseT::assertNotNull(docType, __LINE__, __FILE__); notationList = docType.getNotations(); baseT::assertNotNull(notationList, __LINE__, __FILE__); for (unsigned int indexN65609 = 0; indexN65609 != notationList.getLength(); indexN65609++) { notation = (Node) notationList.item(indexN65609); notationType = (int) notation.getNodeType(); baseT::assertEquals(12, notationType, __LINE__, __FILE__); } }