How to modify XSD element from string to xml?
I have the following part in my XSD:
<xs:element name="Parameter">
<xs:complexType mixed="true">
<xs:attribute name="Name" use="required" type="xs:stri开发者_运维知识库ng"/>
</xs:complexType>
</xs:element>
which means that value for a Parameter can be any string
. Can I somehow specify that value for Parameter can be any valid xml
like <aaa></aaa>
? Something like type="xs:xml"
Use <xs:any>
to allow any XML elements in your content model.
<xs:element name="Parameter">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
You can restrict elements allowed by <xs:any>
to certain namespaces with namespace
attribute and control their validation with processContents
attribute. To allow any attribute, use <xs:anyAttribute>
More info in the XML Schema recommendation: 3.10.2 XML Representation of Wildcard Schema Components
You will have to use
<xs:element name="Parameter" type="myType>
where
<complexType name="myType>
<choice>
<element "myXml" type="xml">
<element "myStr" type="xs:sting">
</choice>
</complexType>
and you will have to define xml like a pattern of xml you want to be your value.
精彩评论