Enumeration with types

This should cover W3C XML Schema, Relax NG and DTD related problems.
Jindra2001
Posts: 1

Enumeration with types

Wed Mar 21, 2012 3:01 pm

Hi all,

I am facing a situation which I do not know how to solve. My customer wants to receive XML in the format below. The values in element <name> are known and can be placed into enumeration. But according to value in <name> the value of <type> changes. How this can be done? Is there any way for such a logic? Thanks a lot for any answer or hints.

Best regards,

Jindra (Czech Republic)

Wanted result
<content>
<params>
<param>
<name>Statement period</name>
<type>VARCHAR2(20)</type>
<value>monthly</value>
</param>
<param>
<name>Percentage rate</name>
<type>Decimal</type>
<value>22.34</value>
</param>
</params>
</content>



What I have now

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>Odchozi zprava z C4M. C4M tuto zpravu o zmene stavu hodnoceni posila jen na hodnoceni, ktera jsou svazana s kreditnim navrhem.</xs:documentation>
</xs:annotation>
<xs:element name="CONTENT">
<xs:complexType>
<xs:sequence>
<xs:element ref="PARAMS"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PARAMS">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="PARAM"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PARAM" type="CT_PARAM_TYPE"/>
<xs:element name="NAME">
<xs:simpleType>
<xs:restriction base="ST_string128">
<xs:enumeration value="CLIENT_EVAL_ID"/>
<xs:enumeration value="OLD_STATE_CODE"/>
<xs:enumeration value="NEW_STATE_CODE"/>
<xs:enumeration value="LAST_MOD_NAME"/>
<xs:enumeration value="MODIFICATION"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element default="VARCHAR2(128)" name="TYPE" type="ST_string128"/>
<xs:element name="VALUE" type="ST_string128"/>
<xs:complexType block="" name="CT_PARAM_TYPE">
<xs:all>
<xs:element ref="NAME"/>
<xs:element ref="TYPE"/>
<xs:element ref="VALUE"/>
</xs:all>
</xs:complexType>
<xs:simpleType name="ST_string128">
<xs:restriction base="xs:string">
<xs:maxLength value="128"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests