试图制作正确的XML,但不断得到这个错误:
在此进行测试:
http://www.utilities-online.info/xsdvalidation
代码:.xml:
<?xml version="1.0" encoding="utf-8" ?>
<root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:Test.Namespace"
xsi:schemaLocation="urn:Test.Namespace Laptopy-ShchypylovNikita.xsd"
xmlns:me="me@me.com"
xmlns:uek="www.uek.krakow.pl"
>
<me:myself>
<me:name>Nikita</me:name>
<me:surename>Shchypylov</me:surename>
<me:sex>male</me:sex>
<me:age>19</me:age>
<me:city>Cracow</me:city>
<me:homeland>Ukraine</me:homeland>
<me:course>IT</me:course>
<me:numer>1</me:numer>
<me:group>Kr1013</me:group>
</me:myself>
<uek:copyright >
Wydzial Zarzadzania, Universytet Economiczny, Krakow
</uek:copyright>
<laptopy>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="samsung">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
bad
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="razer">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
perfect
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
<laptop type="apple">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="asus">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
excellent
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
<laptop type="toshiba">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="samsung">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
</laptopy>
</root>
<?xml version="1.0"?>
<!--Nikita Shchypylov-->
<!--Krdzis1013-->
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:Test.Namespace"
xmlns="urn:Test.Namespace"
elementFormDefault="qualified"
xmlns:me="me@me.com"
xmlns:uek="www.uek.krakow.pl"
>
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="myself" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="surename" type="xsd:string"/>
<xsd:element name="sex" type="xsd:string"/>
<xsd:element name="age" type="xsd:integer"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="homeland" type="xsd:string"/>
<xsd:element name="course" type="xsd:string"/>
<xsd:element name="numer" type="xsd:integer"/>
<xsd:element name="group" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="copyright" maxOccurs="unbounded"/>
<xsd:element name="laptopy" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="laptop"
minOccurs="10" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ekran" type="ekranType"/>
<xsd:element name="card" type="cardType"/>
<xsd:element name="gui" type="xsd:string"/>
<xsd:element name="ram" type="xsd:integer"/>
<xsd:element name="material" type="materialType">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ekranType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="producent" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="cardType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="from" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="materialType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="made" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
你把“名字”,“姓氏”,……放在你的“我自己”元素里。这意味着您将其用作ComplexType。但是,您的xsd文件并没有声明“Myself”是一个ComplexType。您必须将xsd文件中的“Myself”元素定义为ComplexType,就像您为“Laptopy”元素所做的那样。
还有,不要用“ME:Myself”或“UEK:Copyright”等,只要用“Myself”和“Copyright”就行了。
最后,您的“group”元素应该具有整数类型(正如xsd所述),但您可以将其与字符串“kr1013”一起使用。
请参阅下面的固定XML代码,它现在格式良好,对于您的XSD模式(我没有修改它)是有效的:
<?xml version="1.0" encoding="utf-8" ?>
<root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:Test.Namespace"
xsi:schemaLocation="urn:Test.Namespace Laptopy-ShchypylovNikita.xsd"
xmlns:me="me@me.com"
xmlns:uek="www.uek.krakow.pl"
>
<myself>
<name>Nikita</name>
<surename>Shchypylov</surename>
<sex>male</sex>
<age>19</age>
<city>Cracow</city>
<homeland>Ukraine</homeland>
<course>IT</course>
<numer>1</numer>
<group>1013</group>
</myself>
<copyright >
Wydzial Zarzadzania, Universytet Economiczny, Krakow
</copyright>
<laptopy>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="samsung">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
bad
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="razer">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
perfect
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
<laptop type="apple">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="asus">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
excellent
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
<laptop type="toshiba">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="dell">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
steel
</material>
</laptop>
<laptop type="samsung">
<ekran producent="samsung">
wide
</ekran>
<card from="intel">
very good
</card>
<gui>
dynamic
</gui>
<ram>
8
</ram>
<material made="in_china">
wood
</material>
</laptop>
</laptopy>
</root>
我在验证xml和xsd时遇到问题。我从xsd模式中得到这个错误。 src解决方案。4.2:解析组件“urn:id”时出错。检测到“urn:id”位于命名空间“urn:schemas microsoft com:xml-diffgram-v1”中,但此命名空间中的组件无法从架构文档中引用virtual://server/schema.xsd。如果名称空间不正确,可能需要更改“urn:id”的前缀。如
问题内容: 我需要使用给定的XSD文件验证XML文件。我只需要如果验证正常就返回true,否则返回false的方法。 问题答案: 仅返回true或false(也不需要任何外部库):
我试图在Java验证XSD1.1中的XML。正如所讨论的,如何在Java根据XSD1.1验证XML? 我有个例外说: java.lang.IllegalArgumentException:无法加载实现http://www.w3.org/xml/xmlschema/v1.1指定的架构语言的SchemaFactory 然后我尝试,错误是: 无法从类型SchemaFactory对非静态方法setProp
使用eclipse时,我消除了所有错误,但当我更改xml文档中的元素内容时,超出了中设置的限制。xsd文件没有出现验证错误。我已尝试使用联机验证http://www.freeformatter.com/xml-validator-xsd.html我得到了错误“Cvc elt.1:找不到元素“DatabaseInventory”…行“4”,列“69”的声明”,但在eclipse中它验证得很好。不知道
我正在使用Delphi10.2更新3。我按照这些说明验证生成的xml文档。 属性noNamespaceSchema位置对XML解析有什么影响? 使用Windows DOM和TXMLDocument验证XML:在某些计算机上不起作用 delphi中msxml的模式验证 但我有一个错误。“DTD/架构中未定义元素‘jegyzek\u adatok’上的属性‘noNamespaceSchemaLocat
谁能解释一下如何使用notepad++根据XSD验证xml文件。“XML Tools”插件下拉列表中没有提供指定XSD文件的选项。在plugins子目录中正确安装XML插件,并将3个DLL复制到notepad++EXE子目录。其他XML“验证”特性也可以工作,但无法针对XSD进行验证。