2

I'm using XMLUnit (org.custommonkey.xmlunit.Diff) to test two HTML strings: one is produced by templating engine, other is from a static file. It works fine, but I ran to following problem:

There are conditional comments in my code, like this:

<!--[if IE6]>
    <link type="text/css" href="ie6Style.css" rel="stylesheet" />
<![endif]-->

I get an error if I test it against following code (href and type attributes are swapped in following snipped):

<!--[if IE6]>
    <link href="ie6Style.css" type="text/css" rel="stylesheet" />
<![endif]-->

I know that for XML parser, the conditional comment is just a plain text. But is there a way how to test conditional comment content a HTML/XML code?

Richard
  • 279
  • 2
  • 9

2 Answers2

1

In case you want to ignore the comments, there is XMLUnit.setIgnoreComments(false)

rajesh
  • 3,247
  • 5
  • 31
  • 56
0

Remove <!--[if IE6]> and <![endif]--> before running the test.

Oswald
  • 31,254
  • 3
  • 43
  • 68
  • That's a nice idea. But it doesn't solve my problem entirely, since I need to test various conditional definitions, too. Perhaps I might test content of conditional comments in separate test, though. – Richard Apr 01 '13 at 10:21