我的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<workbook xmlns="http://www.dei.isep.ipp.pt/lapr4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dei.isep.ipp.pt/lapr4 validate.xsd">
<lastSave>2013/06/05 20:33:23</lastSave>
<numSpreadsheets>3</numSpreadsheets>
<spreadsheet title="Sheet 1">
<cell horizAlign="2" vertiAlign="0" fontStyle="0" fontSize="12" fontName="Dialog" fgColor="-13421773" bgColor="-1" left="1" right="1" top="1" bottom="1" content="a" address="C7" row="6" column="2"/>
<cell horizAlign="2" vertiAlign="0" fontStyle="0" fontSize="12" fontName="Dialog" fgColor="-13421773" bgColor="-1" left="1" right="1" top="1" bottom="1" content="asd" address="A7" row="6" column="0"/>
<cell horizAlign="2" vertiAlign="0" fontStyle="0" fontSize="12" fontName="Dialog" fgColor="-13421773" bgColor="-1" left="1" right="1" top="1" bottom="1" content="ad" address="B5" row="4" column="1"/>
<cell horizAlign="2" vertiAlign="0" fontStyle="0" fontSize="12" fontName="Dialog" fgColor="-13421773" bgColor="-1" left="1" right="1" top="1" bottom="1" content="sad" address="B7" row="6" column="1"/>
</spreadsheet>
<spreadsheet title="Sheet 2"/>
<spreadsheet title="Sheet 3"/>
</workbook>
我的xsd文件:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.dei.isep.ipp.pt/lapr4"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.dei.isep.ipp.pt/lapr4"
elementFormDefault="qualified">
<xs:element name="workbook" type="TWorkbook"/>
</xs:schema>
<xs:complexType name="TWorkbook">
<xs:sequence>
<xs:element name="lastSave" type="xs:string"/>
<xs:element name="numSpreadsheets" type="TnumSpreadsheets" minOccurs="1"/>
<xs:element name="spreadsheet" type="TSpreadSheet" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="TnumSpreadsheets">
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="TSpreadSheet">
<xs:sequence>
<xs:element name="cell" type="TCell" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="title" type="xs:string" />
</xs:complexType>
<xs:complexType name="TCell">
<xs:attribute name="row" type="xs:int" />
<xs:attribute name="column" type="xs:int" />
<xs:attribute name="horizAlign" type="xs:int" />
<xs:attribute name="vertiAlign" type="xs:int" />
<xs:attribute name="fontStyle" type="xs:int" />
<xs:attribute name="fontSize" type="xs:int" />
<xs:attribute name="font" type="xs:string" />
<xs:attribute name="address" type="xs:string" />
<xs:attribute name="fontName" type="xs:string" />
<xs:attribute name="fgColor" type="xs:int" />
<xs:attribute name="bgColor" type="xs:int" />
<xs:attribute name="left" type="xs:int" />
<xs:attribute name="right" type="xs:int" />
<xs:attribute name="top" type="xs:int" />
<xs:attribute name="bottom" type="xs:int" />
<xs:attribute name="content" type="xs:string" />
</xs:complexType>
</xs:schema>
我一个接一个地验证了文件,并在web和netbeans上相互验证,但当我运行应用程序时,总是出现以下错误:
org.xml.sax.saxparseexception:cvc复杂类型.2.4.a:发现以元素“lastsave”开头的无效内容。“{”之一http://www.dei.isep.ipp.pt/lapr4应为“:numspreadsheets}”。
我一直在寻找答案,但似乎没有任何工作,有人能给我一些关于这个问题的灯?
提前谢谢。
2条答案
按热度按时间ykejflvf1#
@mifet这是我用来创建xml文件的java文件:
我是葡萄牙人,所以这里写的一些东西是葡萄牙语的
l7mqbcuq2#
你有两倍的时间
</xs:schema>
xsd文件中的结束标记。尝试删除第一个出现的问题,它会使xsd处理器混淆。而且,你还错过了一个
<cell />
中的元素<spreadsheet />
标签添加底部。这验证了所有权利:
xml格式:
xsd码: