[Libreoffice-commits] core.git: include/tools tools/qa tools/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jan 17 00:08:18 UTC 2021
include/tools/XmlWalker.hxx | 2 ++
tools/qa/cppunit/test_xmlwalker.cxx | 5 +++++
tools/qa/data/test.xml | 2 ++
tools/source/xml/XmlWalker.cxx | 10 ++++++++++
4 files changed, 19 insertions(+)
New commits:
commit cd65d6c06760caf0109664d2a320cfb29d634ab2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jan 17 00:08:08 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Jan 17 01:07:29 2021 +0100
tools: support reading xml namespace with XmlWalker
Adds methods namespaceHref and namespacePrefix for reading the
current element's namespace prefix and the href.
Change-Id: I1c16857c6fc0bdfde2d983d8f42f153111119029
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109442
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/tools/XmlWalker.hxx b/include/tools/XmlWalker.hxx
index 204d71b5f48c..65beb4531003 100644
--- a/include/tools/XmlWalker.hxx
+++ b/include/tools/XmlWalker.hxx
@@ -41,6 +41,8 @@ public:
bool open(SvStream* pStream);
OString name();
+ OString namespaceHref();
+ OString namespacePrefix();
OString content();
void children();
diff --git a/tools/qa/cppunit/test_xmlwalker.cxx b/tools/qa/cppunit/test_xmlwalker.cxx
index 9f442c73c347..ec0a695b62d1 100644
--- a/tools/qa/cppunit/test_xmlwalker.cxx
+++ b/tools/qa/cppunit/test_xmlwalker.cxx
@@ -74,6 +74,11 @@ void XmlWalkerTest::testReadXML()
}
aWalker.parent();
}
+ else if (aWalker.name() == "with-namespace")
+ {
+ CPPUNIT_ASSERT_EQUAL(OString("adobe:ns:meta/"), aWalker.namespaceHref());
+ CPPUNIT_ASSERT_EQUAL(OString("xx"), aWalker.namespacePrefix());
+ }
aWalker.next();
}
aWalker.parent();
diff --git a/tools/qa/data/test.xml b/tools/qa/data/test.xml
index 7a0473d7f8f9..c2736e8bb6ac 100644
--- a/tools/qa/data/test.xml
+++ b/tools/qa/data/test.xml
@@ -8,4 +8,6 @@
</child>
<child number="3">
</child>
+ <xx:with-namespace xmlns:xx="adobe:ns:meta/">
+ </xx:with-namespace>
</root>
diff --git a/tools/source/xml/XmlWalker.cxx b/tools/source/xml/XmlWalker.cxx
index 219bf10c8bb5..34a3d8746f6b 100644
--- a/tools/source/xml/XmlWalker.cxx
+++ b/tools/source/xml/XmlWalker.cxx
@@ -61,6 +61,16 @@ bool XmlWalker::open(SvStream* pStream)
OString XmlWalker::name() { return reinterpret_cast<const char*>(mpImpl->mpCurrent->name); }
+OString XmlWalker::namespaceHref()
+{
+ return reinterpret_cast<const char*>(mpImpl->mpCurrent->ns->href);
+}
+
+OString XmlWalker::namespacePrefix()
+{
+ return reinterpret_cast<const char*>(mpImpl->mpCurrent->ns->prefix);
+}
+
OString XmlWalker::content()
{
OString aContent;
More information about the Libreoffice-commits
mailing list