--- /dev/null
+<?php
+
+
+class GenerateBordereauSEDA {
+
+ public function generate($bordereau_with_annotation_xml, AnnotationWrapper $annotationWrapper){
+ $dom = new DOMDocument();
+ $dom->loadXML($bordereau_with_annotation_xml);
+
+ $xpath = new DOMXPath($dom);
+ $xpath->registerNamespace("pastell", RelaxNgImportAgapeAnnotation::PASTELL_ANNOTATION_NS);
+ $annotation_list = $xpath->query("//pastell:annotation");
+
+ /** @var DOMElement $annotation */
+ foreach($annotation_list as $annotation){
+ $content = $annotationWrapper->wrap((string) $annotation->nodeValue);
+ $annotation->parentNode->nodeValue = $content;
+ }
+ return $dom->saveXML();
+
+ }
+
+}
\ No newline at end of file
protected $domDocument;
private $domResultNamespace;
+
public function generateFromRelaxNG($relax_ng_path) {
+ return $this->generateFromRelaxNGString(file_get_contents($relax_ng_path));
+ }
- $relax_ng = simplexml_load_file($relax_ng_path);
+ public function generateFromRelaxNGString($relax_ng_string){
+ $relax_ng = simplexml_load_string($relax_ng_string);
$relax_ng->registerXPathNamespace("rng",self::RELAX_NG_NS);
require_once __DIR__."/../connecteur/seda-ng/lib/SedaValidation.class.php";
require_once __DIR__."/../connecteur/seda-ng/lib/AnnotationWrapper.class.php";
require_once __DIR__."/../connecteur/seda-ng/lib/RelaxNgImportAgapeAnnotation.class.php";
+require_once __DIR__."/../connecteur/seda-ng/lib/GenerateBordereauSEDA.class.php";
--- /dev/null
+<?php
+
+
+class GenerateBordereauSEDATest extends PHPUnit_Framework_TestCase {
+
+ public function testGenerate() {
+
+ $relaxNGImportAgapeAnnotation = new RelaxNgImportAgapeAnnotation();
+ $relaxNG_with_annotation = $relaxNGImportAgapeAnnotation->importAnnotation(
+ __DIR__ . "/../../../fixtures/EMEG_PROFIL_PES_0002_v1_schema.rng",
+ __DIR__ . "/../../../fixtures/EMEG_PROFIL_PES_0002_v1.5.xml"
+ );
+
+ $generateXMLFromAnnotedRelaxNG = new GenerateXMLFromAnnotedRelaxNG();
+ $bordereau_seda_with_annotation = $generateXMLFromAnnotedRelaxNG->generateFromRelaxNGString($relaxNG_with_annotation);
+
+
+ $annotationWrapper = new AnnotationWrapper();
+
+ $generateBordereauSEDA = new GenerateBordereauSEDA();
+ $xml = $generateBordereauSEDA->generate($bordereau_seda_with_annotation, $annotationWrapper);
+
+
+ print_r($xml);
+
+
+ }
+
+}
\ No newline at end of file