1 2 3 4 5 6 7 8 9 10 11 12 | <?php // include class file include 'XML/RDDL.php'; // create RDDL parser // parse RDDL file $rddl = new XML_RDDL(); $rddl->parseRDDL('example.html'); // print array of resources print_r($rddl->getAllResources()); ?> |
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 | Array ( [0] => Array ( [lang] => en [type] => simple [href] => http://app.example.domain/example.xsd [role] => http://www.w3.org/2000/10/XMLSchema [title] => Example XML Schema [arcrole] => http://www.rddl.org/purposes#schema-validation ) [1] => Array ( [lang] => en [type] => simple [id] => dtd [href] => http://app.example.domain/example.dtd [role] => http://www.isi.edu/in-notes/iana/assignments/media-types/ application/xml-dtd [title] => Example DTD [arcrole] => http://www.rddl.org/purposes#validation ) ... ) |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <style type="text/css"> table { width:100%; border-collapse:collapse; } td { border: solid 1px black; padding: 5px; } </style> </head> <body> <h2>Resources</h2> <?php // include class file include 'XML/RDDL.php'; // create RDDL parser // parse RDDL file $rddl = new XML_RDDL(); $rddl->parseRDDL('example.html'); // get all resources as array // format as table $resources = $rddl->getAllResources(); if (is_array($resources) && count($resources) > 0) { ?> <table> <tr> <td>Resource</td> <td>Description</td> <td>Purpose</td> <td>Role</td> </tr> <?php foreach ($resources as $r) { $purpose = explode('#', $r['arcrole']); ?> <tr> <td><a href="<?php echo $r['href']; ?>"><?php echo $r['href']; ?></a></td> <td><?php echo $r['title']; ?></td> <td><?php echo $purpose[1]; ?></td> <td><a href="<?php echo $r['role']; ?>"><?php echo $r['role']; ?></a></td> </tr> <?php } ?> </table> <?php } ?> </body> </html> |
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 40 41 42 43 44 45 | <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rddl="http://www.rddl.org/" xml:lang="en"> <head> <title>An Example RDDL Document</title> </head> <body> <pre> <?php // include class file include 'XML/RDDL.php'; // create RDDL parser // parse RDDL file $rddl = new XML_RDDL(); $rddl->parseRDDL('example.html'); // get resources by nature // get all DTDs echo "Resources by nature:\n"; foreach ($rddl->getResourcesByNature('http://www.isi.edu/in-notes/iana/assignments/ media-types/application/xml-dtd') as $r) { echo $r['href'] . " \n"; } echo "\n"; // get resources by purpose // get all software packages echo "Resources by purpose:\n"; foreach ($rddl->getResourcesByPurpose('http://www.rddl.org/ purposes#software-package') as $r) { echo $r['href'] . " \n"; } echo "\n"; // get a specific resource using its id $dtd = $rddl->getResourceById('dtd'); if (is_array($dtd)) { echo "Resource with id 'dtd':\n"; echo $dtd['href']; } ?> </pre> </body> </html> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |