JSP*_*r01 9 xml namespaces xml-namespaces
我想要一个这样的页面:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="mine.xsd">
<m:dialog m:title="Hello">Hi there!</m:dialog>
</html>
Run Code Online (Sandbox Code Playgroud)
我怎么写"mine.xsd"?
一个简单的例子:
XMLSchema1.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Types"
targetNamespace="http://tempuri.org/"
elementFormDefault="qualified"
xmlns="http://tempuri.org/"
xmlns:mstns="http://tempuri.org/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:simpleType name="Types">
<xs:annotation>
<xs:documentation>.NET types</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="String" />
<xs:enumeration value="Int16" />
<xs:enumeration value="Int32" />
<xs:enumeration value="Int64" />
<xs:enumeration value="DateTime" />
<xs:enumeration value="Double" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="DataSize">
<xs:annotation>
<xs:documentation>Number of bytes of the data</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:int" />
</xs:simpleType>
<!-- ... -->
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
然后在您的XML文件中,您可以使用:
<?xml version="1.0" encoding="utf-8" ?>
<ValueSet
xmlns="http://tempuri.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tempuri.org/ XMLSchema1.xsd">
<Values>
<Value Name="Stats" Type="Int32" DataSize="4" />
<Value Name="Time" Type="DateTime" DataSize="4" />
<Value Name="Some" Type="Double" DataSize="4" />
<Value Name="Other" Type="Double" DataSize="4" />
</Values>
</ValueSet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14590 次 |
| 最近记录: |