I'm receiving an XML message with unknown variable name elements... that is, they are not predefined...
I only know there can be 0 or more of those elements, along with some other that are mandatory...
For example
<root>
<service>my service</service>
<resource>my resource</resource>
<action>update</action>
<parameters>
<field1>value1</field1>
<field2>value2</field2>
<field3>value3</field3>
</parameters>
</root>
that is, I don't know what will be passed as "parameters", I only know there will be 0 or more elements with a value, no deeper tag nesting allowed....
I was thinking about something like
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="service" type="xs:string" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="resource" type="xs:string" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="action" type="xs:string" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="parameters">
<xs:complexType>
<xs:element name="*" maxOccurs="unbounded">
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
of course, the hard part is
<xs:element name="*" maxOccurs="unbounded">
Is it possible to do such a thing?
How can I define an XSD file that validates such a message?
--
I checked the w3c reference at
http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#NCName
and it says:
The ·lexical space· of NCName is the set of all strings which ·match· the NCName production of [Namespaces in XML].
So what does it mean?
besides... could you recommend me some easy way to test compliance with an XSD definition?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…