Cindy

 view release on metacpan or  search on metacpan

t/Cindy.t  view on Meta::CPAN


<body>

<a href="http://www.heute-morgen.de/test/About_Cindy.html">About</a>

<ul>
<li><span class="list1"></span></li>
</ul>

<ul>
<li><span class="list2">This is replaced, 
which means a change done before is matched.</span></li>
</ul>

</body>
</html>
|;

$expected = q|<!DOCTYPE html PUBLIC "-//W3C//DTDHTML4.0Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Tests for cindy order of execution</title></head>
<body>

<a href="http://www.heute-morgen.de/test/About_Cindy.html">About</a>

<ul>
<li><span class="list1" test:before="This is done before" test:repeat="One">One</span></li>
<li><span class="list1" test:before="This is done before" test:repeat="Two">Two</span></li>
</ul>
<ul>
<li><span class="before">One</span></li>
<li><span class="before">Two</span></li>
</ul>
</body>
</html>
|;

is_up_to_ws(test($doc, $data, $cis), $expected, 'Order');

#########################
# Repeat condition

$cis = q|
/data/filter/*    repeat      /html/body/table/tr/td 
                              local-name(DATA/*)=DOC/*/@class {
  .                 content   . ;
  'red'             attribute . bgcolor 
} ;
|;

$data = q|<?xml version="1.0" encoding="UTF-8"?>
<data>
  <filter>
    <third>3</third>
    <first>1</first>
    <second>2</second>
  </filter>
</data>
|;

$doc = q|<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Tests the cindy repeat condition</title>
</head>

<body>

<table>
	<tr>
    <th>First</th>
		<td class="first">Value</td>
  </tr>
	<tr>
    <th>Second</th>
		<td class="second">Value</td>
  </tr>
	<tr>
    <th>Third</th>
		<td class="third">Value</td>
  </tr>
</table>

</body>
</html>
|;

$expected = q|<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Tests the cindy repeat condition</title></head>
<body>

<table>
<tr>
<th>First</th>
		<td class="first" bgcolor="red">1</td>
  </tr>
<tr>
<th>Second</th>
		<td class="second" bgcolor="red">2</td>
  </tr>
<tr>
<th>Third</th>
		<td class="third" bgcolor="red">3</td>
  </tr>
</table>
</body>
</html>
|;

is_up_to_ws(test($doc, $data, $cis), $expected, 'Repeat condition');

#########################
# No data found

$cis = q|

/data/does-not-exist  content /doc/content ;
/data/does-not-exist  replace /doc/replace ;
/data/does-not-exist  copy /doc/copy ;
/data/does-not-exist  omit-tag /doc/omit-tag   ;
/data/does-not-exist  attribute /doc/attribute attribute ;
/data/does-not-exist  condition /doc/condition ;
/data/does-not-exist  comment /doc/comment ;
/data/does-not-exist  repeat /doc/repeat {
  ./does-not-exist      content ./does-not-exist ;
} ;
|;

$data = q|<?xml version="1.0" encoding="UTF-8"?>
<data/>
|;

$doc = q|<?xml version="1.0" encoding="UTF-8"?>
<doc>
<content>This should be unchanged.</content>
<replace>This should be unchanged.</replace>
<copy>This should be unchanged.</copy>
<omit-tag>This should be unchanged.</omit-tag>
<attribute 
  attribute="will be removed">This should be unchanged.</attribute>
<omit-tag>This should be unchanged.</omit-tag>
<condition>This should be completely removed.</condition>
<comment>This should be unchanged.</comment>
<repeat>This should be completely removed.</repeat>
</doc>
|;



( run in 2.738 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )