GithubHelp home page GithubHelp logo

florian25686 / xsd2php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidgillen/xsd2php

2.0 1.0 1.0 18 KB

A script to parse an XML schema and generate a list of PHP classes representing the nodes in the XML tree. The constructors for the classes have valildation set up based on the schema specifications.

License: GNU General Public License v3.0

PHP 100.00%

xsd2php's Introduction

An XML schema to PHP class generator
Released under the GPL, see COPYING
I offer no guarentees, either express or implied, that this software
and the classes it generates are fit for use. Use at own risk.

Usage: php xsd2php.php <schema.xml>

Will result in a number of classes being created in the current directory.
Each class has the following features
- list of properties representing xml children
- constructor which validate the children based upon type, and number
  of occurances.
- Doc comments for the constructor
- validates against the PHPCodeSniffer PEAR coding standard check.

TODO: Change to use the DOM instead of simpleXML

xsd2php's People

Contributors

davidgillen avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

leo2505

xsd2php's Issues

Empty Values

If there is an element without a value it will return empty instead of 0. The default for empty values is not given or set to null.
Should fix the bug

Attributes needed

In my case I need a way to add attributes to the XML.
Example:

  <xs:annotation>
    <xs:documentation>With attribut "languagecode" a language is indicated.</xs:documentation>
  </xs:annotation>
  <xs:complexType>
    <xs:sequence>
      <xs:element name="version">
        <xs:annotation>
          <xs:documentation>With the version there can be a Releasemanagement to ensure backwards compatibility</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="10"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="languagecode" type="languagecode" use="required"/>
  </xs:complexType>
</xs:element>

Should generate an XML like this

<format languagecode="DE">
    <version>1.0</version>
</format>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.