fnogatz / xsd2json

Translate XML Schema into equivalent JSON Schema
MIT License
149 stars 28 forks source link

Why are simpleTypes prefixed with '@' ? #19

Open redaktor opened 9 years ago

redaktor commented 9 years ago

E.g.

<xs:attribute name="countryCode" type="xs:string"/>

becomes

"@countryCode": {
    "type": "string"
}
fnogatz commented 9 years ago

At the end it should not:

<xs:complexType>
  <xs:attribute name="countryCode" type="xs:string" />
</xs:complexType>

becomes

{
    "properties": {
        "countryCode": {
            "type": "string"
        }
    },
    "type": "object"
}

as you would expect. There's a test specified for this scenario too.

FYI: While processing the XSD all attributes are prefixed with an @ for being able to handle the following situation:

<xs:complexType>
  <xs:all>
    <xs:element name="countryCode" type="xs:string" />
  </xs:all>
  <xs:attribute name="countryCode" type="xs:string" />
</xs:complexType>

Though the Prolog predicate remove_at_from_property_names/2 will remove any unnecessary @-prefix.

redaktor commented 9 years ago

I tested with the Schemas in PRISM - it is a namespace absolutely not following 5-star-data or linked data. But it is used in popular OWL ontologies. They have got XML Schemas which you can download in a .zip here ;) : http://www.idealliance.org/specifications/prism-metadata-initiative/prism

fnogatz commented 9 years ago

I already read your other issue and posts on the json-schema mailing list. I will have a look at the PRISM schemas this weekend :)