我有一个要求,我需要使用XSD限制属性值及其元素的值。我已经能够将属性值限制为
之一JSON
SWAGGER
到目前为止,我还需要将元素值限制为
之一letter.c
di.js
。
XML:
<response src="XML">
<resp name="JSON">letter.c</resp>
<resp name="SWAGGER">di.js</resp>
</response>
XSD:
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="response">
<xs:complexType>
<xs:sequence>
<xs:element name="resp" maxOccurs="14" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="respFilter">
<xs:attribute name="name" use="required"
type="Enum" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="src" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="XML"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="Enum">
<xs:restriction base="xs:string">
<xs:enumeration value="JSON">
</xs:enumeration>
<xs:enumeration value="SWAGGER">
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="respFilter">
<xs:restriction base="xs:string">
<xs:minLength value="0"></xs:minLength>
<xs:maxLength value="1064"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
</xs:schema>
有没有办法可以使用XSD限制它们?
答案 0 :(得分:1)
当然,只需使用xs:enum
为resp/@name
属性完成。
替换
<xs:simpleType name="respFilter">
<xs:restriction base="xs:string">
<xs:minLength value="0"></xs:minLength>
<xs:maxLength value="1064"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
与
<xs:restriction base="xs:string">
<xs:maxLength value="1064"/>
<xs:enumeration value="letter.c"/>
<xs:enumeration value="di.js"/>
</xs:restriction>
附注:
xs:minLength value="0"
xs:string
基地<?php
$result = mysqli_query($link,"SELECT * FROM account_db");
$row = mysqli_fetch_row($result);
echo"<html>";
echo"<center>";
echo "<form method='POST'>";
echo "<table style='border:1px solid black' name='pleasework'>";
echo"<th>FILES</th>";
echo"<th>AMOUNT</th>";
echo"<th>NO. OF COPIES</th>";
echo"<th>TOTAL AMOUNT</th>";
$answer = $row[2] * noofcopies;
while($row)
{
echo"<tr>";
echo "<td id='transfile'>$row[1] </td>";
echo "<td align=center>$row[2] </td>";
echo "<td align=center><input type='number' name='noofcopies' onkeyup> </td>";
echo "<td align=center value=''>$answer</td>";
echo"</tr>";
}
echo "</table>";
echo " <input type='submit' value='Transact' name='transaction'>";
echo"</center>";
echo"</html>";
?>
多余的。