Good Morning...
I know that elements with the same name and in the same scope must have
the same type. I try to make a xml schema for config file. We try to
verify (validate) at specific attribute and assign a specific
restriction.
For example the section called "Common" have the next elements and
attributes:
<Common>
<add key="CountInstances" value="1.2"> Dec </add>
<add key="LogLevel" value="2"> Int</add>
<add key="OperationsPerFileList" value="1"> Int </add>
<add key="frecuenciacentinela" value="2.0"> Dec </add>
</Common>
and we want to specify for example that the attribute called
"CountInstances" is a decimal that could takes values from 1 to 3, the
attribute "LogLevel" takes integers values from 0 to 3,
key="OperationsPerFileList" takes integers values from 0 to 1, and
"frecuenciacentinela" takes decimal values from 0 to 2.
We try to use instead the fixed value....
<xs:complexType name="CommonType">
<xs:sequence>
<xs:element name="add" type="addType" maxOccurs="unbounded" />
</xs:sequence>
<xs:attributeGroup ref="myAttributeGroup" />
</xs:complexType>
<xs:attributeGroup name="myAttributeGroupCountInstances">
<xs:attribute name="key" type="xs:string" fixed="CountInstances" />
<xs:attribute name="value" type="numbyno" />
</xs:attributeGroup>
<xs:simpleType name="numbyno">
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value='3'/>
<xsd:fractionDigits value="1"/>
<xsd:minInclusive value="0" />
<xsd:maxInclusive value="5" />
<!--<xsd:pattern value="[0-5](.2)?" />-->
</xsd:restriction>
</xs:simpleType>
...but we couldnīt add another attributeGroup because we couldnīt called
an attribute name with
different type..
...so we belief use the enumeration value but we donīt know if we can
assign a specific attribute a specific restriction...we use an union
type but we donīt know how assign a specific restriccion for example
"CountInstances" to specific restriction "that could takes decimal
values for example from 1 to 3"... we did this but like a general way
for all int and so on... we have just belief that if we put in the same
order it could work but it wasnīt!, because we change the order and it
still work but taking differents types..
<xsd:complexType name="CommonType">
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="add" type="addType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="addType" mixed="true">
<xsd:attributeGroup ref="CommonAttribute"/>
</xsd:complexType>
<xsd:attributeGroup name="CommonAttribute">
<xsd:attribute name="key" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="CountInstances" />
<xsd:enumeration value="LogLevel" />
<xsd:enumeration value="frecuenciacentinela" />
....
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="value" use="required">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType> <xsd:restriction base="xsd:int">
<xsd:minInclusive value="1" /> <xsd:maxInclusive value="3" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType> <xsd:restriction base="xsd:decimal">
<xsd:totalDigits value='3'/>
<xsd:fractionDigits value="1"/> <xsd:minInclusive value="0"
/> <xsd:maxInclusive value="5" /> </xsd:restriction>
</xsd:simpleType>
....
</xsd:union>
</xsd:simpleType>
</xsd:attribute>
</xsd:attributeGroup>
we hope you could help us or recommendation something...
Thanks..
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!