-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsonml.class.php
More file actions
39 lines (34 loc) · 1.11 KB
/
Copy pathjsonml.class.php
File metadata and controls
39 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class Jsonml
{
private static $xsl = null;
private static function init()
{
self::$xsl = new XSLTProcessor();
$style = new DomDocument();
$style->load('../JsonML.xslt');
self::$xsl->importStylesheet($style);
}
static function encode($data)
{
if(self::$xsl == null)
self::init();
//todo not actually sure that this is sane
$new_data = '';
$new_data .= '<?xml version="1.0" encoding="utf8"?>';
$new_data .= '<fragment>'.str_replace('&','&',html_entity_decode($data)).'</fragment>';
$src = new DomDocument('1.0', 'utf8');
$src->preserveWhiteSpace = false;
/*
if(!$src->loadXML($new_data))
die($data.PHP_EOL.$new_data);
*/
if(constant('DEVELOPMENT'))
$src->loadXML($new_data);
else
@$src->loadXML($new_data);
//die($src->saveHTML());
return self::$xsl->transformToXml($src);
}
}
?>