问题
`I have a simple type xsd element which i want to convert to a complex type because i want the final wsdl to be document type literal format. Could you guys help?
<xsd:element name="Service">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="loan.CreateLead" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
I want this to be converted to a complex type with the same name element and having an enumeration value. Please let me know on this? Thanks Buyan
回答1:
This is one way of doing it. The thing is, you can only extend/restrict one at a time, hence the two-steps approach.
I kept the original one unchanged for reference only, otherwise the first Service element could've been of "arestriction" type.
<?xml version="1.0" encoding="utf-8" ?>
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) -->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" xmlns="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Service">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="loan.CreateLead"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:simpleType name="arestriction">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="loan.CreateLead"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Service1">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="arestriction"/>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
来源:https://stackoverflow.com/questions/19549745/how-do-i-convert-this-simple-type-xsd-to-a-complex-type-xsd