|
| 1 | +<?php /* |
| 2 | ++----------------------------------------------------------------------+ |
| 3 | +| Copyright (c) 1997-2025 The PHP Group | |
| 4 | ++----------------------------------------------------------------------+ |
| 5 | +| This source file is subject to version 3.01 of the PHP license, | |
| 6 | +| that is bundled with this package in the file LICENSE, and is | |
| 7 | +| available through the world-wide-web at the following url: | |
| 8 | +| https://www.php.net/license/3_01.txt. | |
| 9 | +| If you did not receive a copy of the PHP license and are unable to | |
| 10 | +| obtain it through the world-wide-web, please send a note to | |
| 11 | +| [email protected], so we can mail you a copy immediately. | |
| 12 | ++----------------------------------------------------------------------+ |
| 13 | +| Authors: André L F S Bacci <ae php.net> | |
| 14 | ++----------------------------------------------------------------------+ |
| 15 | +
|
| 16 | +# Description |
| 17 | +
|
| 18 | +Compare XML entities usage between two XML leaf/fragment files. */ |
| 19 | + |
| 20 | +require_once __DIR__ . '/libqa/all.php'; |
| 21 | + |
| 22 | +$ignore = new OutputIgnore( $argv ); // always first, may exit. |
| 23 | +$list = SyncFileList::load(); |
| 24 | + |
| 25 | +foreach ( $list as $file ) |
| 26 | +{ |
| 27 | + $source = $file->sourceDir . '/' . $file->file; |
| 28 | + $target = $file->targetDir . '/' . $file->file; |
| 29 | + $output = new OutputBuffer( "# qaxml.e" , $target , $ignore ); |
| 30 | + |
| 31 | + [ $_ , $s , $_ ] = XmlFrag::loadXmlFragmentFile( $source ); |
| 32 | + [ $_ , $t , $_ ] = XmlFrag::loadXmlFragmentFile( $target ); |
| 33 | + |
| 34 | + if ( implode( "\n" , $s ) == implode( "\n" , $t ) ) |
| 35 | + continue; |
| 36 | + |
| 37 | + $match = array(); |
| 38 | + |
| 39 | + foreach( $s as $v ) |
| 40 | + $match[$v] = [ 0 , 0 ]; |
| 41 | + foreach( $t as $v ) |
| 42 | + $match[$v] = [ 0 , 0 ]; |
| 43 | + |
| 44 | + foreach( $s as $v ) |
| 45 | + $match[$v][0] += 1; |
| 46 | + foreach( $t as $v ) |
| 47 | + $match[$v][1] += 1; |
| 48 | + |
| 49 | + foreach( $match as $k => $v ) |
| 50 | + { |
| 51 | + if ( $v[0] == $v[1] ) |
| 52 | + continue; |
| 53 | + $output->addDiff( $k , $v[0] , $v[1] ); |
| 54 | + } |
| 55 | + |
| 56 | + $output->print(); |
| 57 | +} |
0 commit comments