mirror of
https://github.com/jezhiggins/arabica
synced 2025-02-05 20:45:56 +01:00
Fix for incorrect hasAttributeURI
from Mark D Anderson, mda@discerning.net with input of: <stuff:Blah name="test" xmlns:stuff="http://stuff.org/"/> the Attr object for name returns true for hasNamespaceURI(), yet the value of getNamespaceURI() is the empty string. This is inconsistent; an empty namespace is illegal. For now I'm working around this by putting (!n.hasNamespaceURI() || n.getNamespaceURI().empty()) into my code.
This commit is contained in:
parent
09c7a6376f
commit
8875207274
2 changed files with 50 additions and 5 deletions
|
@ -69,7 +69,7 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
||||||
|
|
||||||
void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value)
|
void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value)
|
||||||
{
|
{
|
||||||
AttrNSImpl<stringT, string_adaptorT>* a = new AttrNSImpl<stringT, string_adaptorT>(ownerDoc_, namespaceURI, true, qualifiedName);
|
AttrNSImpl<stringT, string_adaptorT>* a = new AttrNSImpl<stringT, string_adaptorT>(ownerDoc_, namespaceURI, !namespaceURI.empty(), qualifiedName);
|
||||||
a->setValue(value);
|
a->setValue(value);
|
||||||
a->setOwnerElement(ownerElement_);
|
a->setOwnerElement(ownerElement_);
|
||||||
setNamedItemNS(a);
|
setNamedItemNS(a);
|
||||||
|
|
|
@ -64,6 +64,40 @@ class SAXTest : public TestCase
|
||||||
assertEquals("poop", elem.getAttribute("attr"));
|
assertEquals("poop", elem.getAttribute("attr"));
|
||||||
} // test4
|
} // test4
|
||||||
|
|
||||||
|
void test5()
|
||||||
|
{
|
||||||
|
DOM::Document<std::string> d = parse("<stuff:elem attr='something' xmlns:stuff='http://example.com/stuff'/>");
|
||||||
|
DOM::Element<std::string> elem = d.getDocumentElement();
|
||||||
|
assertEquals(true, elem.hasNamespaceURI());
|
||||||
|
assertEquals("http://example.com/stuff", elem.getNamespaceURI());
|
||||||
|
|
||||||
|
DOM::Attr<std::string> attr = elem.getAttributeNode("attr");
|
||||||
|
assertEquals(false, attr.hasNamespaceURI());
|
||||||
|
} // test5
|
||||||
|
|
||||||
|
void test6()
|
||||||
|
{
|
||||||
|
DOM::Document<std::string> d = parse("<stuff:elem stuff:attr='something' xmlns:stuff='http://example.com/stuff'/>");
|
||||||
|
DOM::Element<std::string> elem = d.getDocumentElement();
|
||||||
|
assertEquals(true, elem.hasNamespaceURI());
|
||||||
|
assertEquals("http://example.com/stuff", elem.getNamespaceURI());
|
||||||
|
|
||||||
|
DOM::Attr<std::string> attr = elem.getAttributeNodeNS("http://example.com/stuff", "attr");
|
||||||
|
assertEquals(true, attr.hasNamespaceURI());
|
||||||
|
assertEquals("http://example.com/stuff", attr.getNamespaceURI());
|
||||||
|
} // test6
|
||||||
|
|
||||||
|
void test7()
|
||||||
|
{
|
||||||
|
DOM::Document<std::string> d = parse("<elem stuff:attr='something' xmlns:stuff='http://example.com/stuff'/>");
|
||||||
|
DOM::Element<std::string> elem = d.getDocumentElement();
|
||||||
|
assertEquals(false, elem.hasNamespaceURI());
|
||||||
|
|
||||||
|
DOM::Attr<std::string> attr = elem.getAttributeNodeNS("http://example.com/stuff", "attr");
|
||||||
|
assertEquals(true, attr.hasNamespaceURI());
|
||||||
|
assertEquals("http://example.com/stuff", attr.getNamespaceURI());
|
||||||
|
} // test7
|
||||||
|
|
||||||
void test8()
|
void test8()
|
||||||
{
|
{
|
||||||
DOM::Document<std::string> d = parse("<root attr=\"poop\"><child/></root>");
|
DOM::Document<std::string> d = parse("<root attr=\"poop\"><child/></root>");
|
||||||
|
@ -75,7 +109,17 @@ class SAXTest : public TestCase
|
||||||
assert(e2.hasAttributes() == true);
|
assert(e2.hasAttributes() == true);
|
||||||
assert(e2.getAttribute("attr") == "poop");
|
assert(e2.getAttribute("attr") == "poop");
|
||||||
assert(e2.getFirstChild().getNodeName() == "child");
|
assert(e2.getFirstChild().getNodeName() == "child");
|
||||||
} // test7
|
} // test8
|
||||||
|
|
||||||
|
void test9()
|
||||||
|
{
|
||||||
|
DOM::Document<std::string> d = parse("<elem attr='something' xmlns:stuff='http://example.com/stuff'/>");
|
||||||
|
DOM::Element<std::string> elem = d.getDocumentElement();
|
||||||
|
assertEquals(false, elem.hasNamespaceURI());
|
||||||
|
|
||||||
|
DOM::Attr<std::string> attr = elem.getAttributeNode("attr");
|
||||||
|
assertEquals(false, attr.hasNamespaceURI());
|
||||||
|
} // test9
|
||||||
};
|
};
|
||||||
|
|
||||||
TestSuite* SAXTest_suite()
|
TestSuite* SAXTest_suite()
|
||||||
|
@ -85,10 +129,11 @@ TestSuite* SAXTest_suite()
|
||||||
suiteOfTests->addTest(new TestCaller<SAXTest>("test2", &SAXTest::test2));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test2", &SAXTest::test2));
|
||||||
suiteOfTests->addTest(new TestCaller<SAXTest>("test3", &SAXTest::test3));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test3", &SAXTest::test3));
|
||||||
suiteOfTests->addTest(new TestCaller<SAXTest>("test4", &SAXTest::test4));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test4", &SAXTest::test4));
|
||||||
// suiteOfTests->addTest(new TestCaller<SAXTest>("test5", &SAXTest::test5));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test5", &SAXTest::test5));
|
||||||
// suiteOfTests->addTest(new TestCaller<SAXTest>("test6", &SAXTest::test6));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test6", &SAXTest::test6));
|
||||||
// suiteOfTests->addTest(new TestCaller<SAXTest>("test7", &SAXTest::test7));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test7", &SAXTest::test7));
|
||||||
suiteOfTests->addTest(new TestCaller<SAXTest>("test8", &SAXTest::test8));
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test8", &SAXTest::test8));
|
||||||
|
suiteOfTests->addTest(new TestCaller<SAXTest>("test9", &SAXTest::test9));
|
||||||
return suiteOfTests;
|
return suiteOfTests;
|
||||||
} // MathTest_suite
|
} // MathTest_suite
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue