How to generate Objective C class files from XML schema?

I have an XML schema that defines my data model. I would now like to have Objective C source files generated from the XML schema. Does anyone know how to accomplish this?


Take a look at this Stack Overflow question on XML serialization, which mentions a project along these lines.

Without knowing the details my immediate thought would be to probably use xslt for this. e.g. if you had something like (I appreciate

<element name="SomeEntity">
  <attribute name="someAttr" type="integer" />
      <element name="someOtherAttr" type="string" />

Create a bunch of templates to translate this,e.g.

<xsl:template match="element">
  <xsl:apply-template select="." mode="header"/>
  <xsl:apply-template select="." mode="impl"/>

<xsl:template match="element" mode="header">
class <xsl:value-of select="@name"/> {
  <xsl:apply-template select="attribute" mode="header"/>

  <xsl:apply-template select="complexType/element" mode="header"/>


Though if the logic on the generation is more complex I would probably go down the road of importing the xml into an object model and programmatically process that, possibly using a template engine such as Velocity, as while it is possible complex logic in xslt is a pain.

Need Your Help

partial specialization of function in template class

c++ templates operator-overloading specialization

I have a template class representing an array of numerical values.

Can I get away with adding a whitespace to a class definition?

html css class syntax

I'm working on some legacy PHP code that, depending on conditions, produces either the following output: