[PATCH] Correct transformNode
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Thu Apr 24 07:22:14 CDT 2008
---
dlls/msxml3/node.c | 46 ++++++++++++++++++++++++++++++----------
dlls/msxml3/tests/domdoc.c | 49 ++++++++++++++++++++++++++++++++++++++-----
2 files changed, 77 insertions(+), 18 deletions(-)
diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c
index 246598d..039bb04 100644
--- a/dlls/msxml3/node.c
+++ b/dlls/msxml3/node.c
@@ -44,6 +44,10 @@
# include <libxslt/xsltInternals.h>
#endif
+#ifdef HAVE_LIBXML2
+# include <libxml/HTMLtree.h>
+#endif
+
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
@@ -1065,21 +1069,39 @@ static HRESULT WINAPI xmlnode_transformNode(
result = xsltApplyStylesheet(xsltSS, This->node->doc, NULL);
if(result)
{
- xmlBufferPtr pXmlBuf;
- int nSize;
-
- pXmlBuf = xmlBufferCreate();
- if(pXmlBuf)
+ const xmlChar *pContent;
+
+ if(result->type == XML_HTML_DOCUMENT_NODE)
{
- nSize = xmlNodeDump(pXmlBuf, NULL, (xmlNodePtr)result, 0, 0);
- if(nSize > 0)
+ xmlOutputBufferPtr pOutput = xmlAllocOutputBuffer(NULL);
+ if(pOutput)
{
- const xmlChar *pContent;
-
- pContent = xmlBufferContent(pXmlBuf);
- *xmlString = bstr_from_xmlChar(pContent);
+ htmlDocContentDumpOutput(pOutput, result->doc, NULL);
+ if(pOutput)
+ {
+ pContent = xmlBufferContent(pOutput->buffer);
+ *xmlString = bstr_from_xmlChar(pContent);
+ }
+
+ xmlOutputBufferClose(pOutput);
+ }
+ }
+ else
+ {
+ xmlBufferPtr pXmlBuf;
+ int nSize;
- xmlBufferFree(pXmlBuf);
+ pXmlBuf = xmlBufferCreate();
+ if(pXmlBuf)
+ {
+ nSize = xmlNodeDump(pXmlBuf, NULL, (xmlNodePtr)result, 0, 0);
+ if(nSize > 0)
+ {
+ pContent = xmlBufferContent(pXmlBuf);
+ *xmlString = bstr_from_xmlChar(pContent);
+
+ xmlBufferFree(pXmlBuf);
+ }
}
}
}
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 9d84435..2c91433 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -143,10 +143,9 @@ static const CHAR szTransformSSXML[] =
"</xsl:stylesheet>";
static const CHAR szTransformOutput[] =
-"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
-"<html><body><h1>\n"
-"Hello World\n"
-"</h1></body></html>\n";
+"<html><body><h1>"
+"Hello World"
+"</h1></body></html>";
static const WCHAR szNonExistentFile[] = {
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
@@ -242,6 +241,44 @@ static VARIANT _variantbstr_(const char *str)
return v;
}
+static BOOL comapreIgnoreReturns(BSTR sLeft, BSTR sRight)
+{
+ int nLeft=0;
+ int nRight=0;
+
+ while(sLeft[nLeft] != 0)
+ {
+ if(sLeft[nLeft] == '\r')
+ nLeft++;
+
+ if(sLeft[nLeft] == '\n')
+ nLeft++;
+
+ if(sRight[nRight] == '\r')
+ nRight++;
+
+ if(sRight[nRight] == '\n')
+ nRight++;
+
+ if(sLeft[nLeft] == 0 && sRight[nRight] == 0)
+ return TRUE;
+
+ if(sLeft[nLeft] == 0 && sRight[nRight] != 0)
+ return FALSE;
+
+ if(sLeft[nLeft] != 0 && sRight[nRight] == 0)
+ return FALSE;
+
+ if(sLeft[nLeft] != sRight[nRight])
+ return FALSE;
+
+ nLeft++;
+ nRight++;
+ }
+
+ return TRUE;
+}
+
static void get_str_for_type(DOMNodeType type, char *buf)
{
switch (type)
@@ -3192,8 +3229,8 @@ static void test_testTransforms(void)
BSTR bOut;
hr = IXMLDOMDocument_transformNode(doc, pNode, &bOut);
- ok(hr == S_OK, "ret %08x\n", hr );
- ok( !lstrcmpW( bOut, _bstr_(szTransformOutput) ), "Stylesheet output not correct\n");
+ ok(hr == S_OK, "ret %08x\n", hr );
+ ok( comapreIgnoreReturns( bOut, _bstr_(szTransformOutput)) == TRUE, "Stylesheet output not correct\n");
IXMLDOMNode_Release(pNode);
}
--
1.5.4.1
--------------040808010706070708040705--
More information about the wine-patches
mailing list