From f8da775795052ad2eb879970c115d2e2a2fe8c81 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 12 Feb 2018 17:53:48 +0100 Subject: EPUB export, fixed layout: fix validation error with images The "xlink" prefix for the "xlink:href" attribute on the "image" element was not bound. Change-Id: I473a0b1612b4842cf84a264960bb28a9f19600e5 Reviewed-on: https://gerrit.libreoffice.org/49612 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- test/source/xmltesttools.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 5d476c46a5ec..45347b0c111b 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -123,6 +123,33 @@ void XmlTestTools::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath contents of child does not match").getStr(), rContent, getXPathContent(pXmlDoc, rXPath)); } +void XmlTestTools::assertXPathNSDef(xmlDocPtr pXmlDoc, const OString& rXPath, + const OUString& rNSPrefix, const OUString& rNSHref) +{ + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + CPPUNIT_ASSERT_MESSAGE( + OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' not found").getStr(), + xmlXPathNodeSetGetLength(pXmlNodes) > 0); + + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + bool bFound = false; + for (xmlNsPtr pNamespace = pXmlNode->nsDef; pNamespace; pNamespace = pNamespace->next) + { + if (!pNamespace->prefix) + continue; + + CPPUNIT_ASSERT(pNamespace->href); + if (rNSPrefix == convert(pNamespace->prefix) && rNSHref == convert(pNamespace->href)) + { + bFound = true; + break; + } + } + xmlXPathFreeObject(pXmlObj); + CPPUNIT_ASSERT(bFound); +} + void XmlTestTools::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes) { #if LIBXML_VERSION >= 20703 /* xmlChildElementCount is only available in libxml2 >= 2.7.3 */ -- cgit v1.2.3