Json模式需要patternProperty

时间:2016-10-21 11:00:43

标签: jsonschema

有没有办法要求patternProperty?

<?php 
$con = @mysql_connect($mysql_db_hostname, $mysql_db_user, $mysql_db_password);
mysql_select_db( $mysql_db_database);


$res = mysql_query("select
a.assembly,
a.election_year,
COUNT(b.male_observers_trained) as male,
COUNT(b.female_observers_trained) as female
FROM elect a
LEFT JOIN tbl_observer_stats b ON (a.id=b.election_id)
GROUP BY a.assembly, a.election_year") or die(mysql_error());

$ar = array();
$years = array();
while($result = mysql_fetch_assoc($res)){
  /* fetch into multi array */
  $ar[$result['assembly']][$result['election_year']] = array('male'=>$result['male'], 'female'=>$result['female']);
  /* make array of distinct years */
  $years[$result['election_year']] = $result['election_year'];
}
mysql_free_result($res);
sort($years);

?>

<table width="812" class="listing resultList resultList--tbl_election" border="1">
        <tr class="table-headings">
        <th class="row-actions-header" width="157" rowspan="3"><div align="left"><strong>Assembly</strong></div></th>
        <th height="43" colspan="<?php echo count($years)*2 ?>" class="row-actions-header"><div align="center"><strong>Number of Observers Trained</strong></div></th>
              </tr>
              <tr class="table-headings">
              <?php
              foreach($years as $year){
                echo '<th colspan="2" class="row-actions-header"><div align="center"><strong>' . $year . '</strong></div></th>';
              }
              ?>

                <th width="141" colspan="2" class="row-actions-header"><div align="center"><strong>Total</strong></div></th>
              </tr>
              <tr class="table-headings">
              <?php
              foreach($years as $year){
                echo ' <th width="30" height="43" class="row-actions-header">Male Observer</th>
                <th width="16" class="row-actions-header">Female Observer</th>';
              }
                ?>

       <th width="30" height="43" class="row-actions-header">Male Observer</th>
       <th width="16" class="row-actions-header">Female Observer</th>
       </tr> 

      <?php

      $colSum = array();

      foreach($ar as $assembly => $data){
        $total_male = 0;
        $total_female = 0;
        echo '<tr class="table-headings"><td class="field-content resultListCell">' . $assembly . '</td>';
        foreach($years as $year){
          echo '
          <td class="field-content resultListCell">' . $data[$year]['male'] . '</td>
          <td class="field-content resultListCell">' . $data[$year]['female'] . '</td>';
        $total_male += $data[$year]['male'];
        $total_female += $data[$year]['female'];

        $colSum[$year]['male'][] = $data[$year]['male'];
        $colSum[$year]['female'][] = $data[$year]['female'];

        }
        echo '
      <td class="field-content resultListCell">' . $total_male . '</td> 
      <td class="field-content resultListCell">' . $total_female . '</td>
      </tr>';

       }

       echo '<tr class="table-headings"><td class="field-content resultListCell">TOTAL</td>';

       $totalSum = array();
        foreach($years as $year){
          echo '
          <td class="field-content resultListCell">' . array_sum($colSum[$year]['male']) . '</td>
          <td class="field-content resultListCell">' . array_sum($colSum[$year]['female']) . '</td>';
          $totalSum['male'][] = array_sum($colSum[$year]['male']);
          $totalSum['female'][] = array_sum($colSum[$year]['female']);

        }
        echo '
      <td class="field-content resultListCell">' . array_sum($totalSum['male']) . '</td> 
      <td class="field-content resultListCell">' . array_sum($totalSum['female']) . '</td>
      </tr>';
       ?>

        </table>

我是否可以通过任何其他方式使“^ _ _ + _ $ $”成为必需或需要任意密钥?

1 个答案:

答案 0 :(得分:2)

不,它无法完成。但是,当我键入此内容以开发下一版本的JSON Schema时,正在进行讨论。我鼓励你去https://github.com/json-schema-org/json-schema-spec并提出一个问题,要求在下一次迭代中包含一些东西来处理这种情况。