Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD transformation into XML

Tags:

php

xml

xsd

How can I create a (empty) XML file trough a existing XSD schema? Which PHP (5.3) functions are necessary?

like image 843
powtac Avatar asked Dec 04 '09 18:12

powtac


2 Answers

I was also searching on how to "initialize" directly a DOM XML object that corresponds to an existing XSD in PHP. This allows for easily "feeding" this empty XML file with my own data. Found only ONE method that does it, the SDO DAS XML extension of PHP

http://www.php.net/manual/en/sdo-das-xml.examples.php

see example #2. Unfortunately the extension is not by default in PHP 5.3, you have to add it through PECL, which does't work on my Windows PC, so I could not test it.

like image 54
spiritoo Avatar answered Oct 01 '22 10:10

spiritoo


You would need to write a PHP parser that takes the XSD file and builds, tag by tag, an XML file.

Depending on the complexity of your XSD schema, this could either take a short/medium amount of time - or it could be entirely unfeasible, in terms of "you should probably just make an XML file by hand".

like image 27
derrylwc Avatar answered Oct 01 '22 12:10

derrylwc