ServiceSchemaWriter.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class ServiceSchemaWriter
  3. {
  4. /**
  5. * @throws Exception
  6. */
  7. public static function writeSchemaXmlString(array $attributesArr)
  8. {
  9. $dom = new DOMDocument('1.0', 'utf-8');
  10. $root = $dom->createElement("serviceSchema");
  11. foreach ($attributesArr as $attribute) {
  12. if ($attribute instanceof XMLAttribute) {
  13. $attribute->toValueElement($dom, $root);
  14. }
  15. }
  16. $dom->appendChild($root);
  17. return $dom->saveXML($dom->documentElement);
  18. }
  19. /**
  20. * @throws Exception
  21. */
  22. public static function writeFullchemaXmlString(array $attributesArr)
  23. {
  24. $dom = new DOMDocument('1.0', 'utf-8');
  25. $root = $dom->createElement("serviceSchema");
  26. foreach ($attributesArr as $attribute) {
  27. if ($attribute instanceof XMLAttribute) {
  28. $attribute->toElement($dom, $root);
  29. }
  30. }
  31. $dom->appendChild($root);
  32. return $dom->saveXML($dom->documentElement);
  33. }
  34. }