xml-validation

XSD requiring a specific root element exist in an XML document?

余生长醉 提交于 2021-01-28 03:35:03
问题 I want to validate a XML file and to make sure it has a root element called speak like this: <speak> <!--other node here...--> </speak> the speak element must exist in XML and must appears only once. I try to add code below in my XSD file: <xsd:element name="speak" type="speak" minOccurs="1" maxOccurs="1"/> But it does not work. 回答1: In the schema itself, you can't put a constraint on what the root element must be. (That's by design, though not everyone thinks it's a good design.) Any global

XSD define element by name or alternate attribute

自作多情 提交于 2021-01-28 00:43:42
问题 Consider two possible implementations of a "tag group": Authors are allowed to use either an element named <tag-group> or any element with attribute role="tag-group" . I'd like to write an XSD schema that will validate either case. Ideally, the schema can also validate that children are valid within a given parent. The "tag group", for example, allows children to be either an element named <tag> or any element with attribute role="tag" . So the ideal schema would validate, that given <tag

Error: It was detected that X is in namespace Y, but components from this namespace are not referenceable from schema document

泄露秘密 提交于 2021-01-27 22:02:02
问题 What's wrong in this xsd elements? <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="MessageInfoType"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="1" name="TimeStamp" type="xsd:string" /> </xsd:sequence> </xsd:complexType> <xsd:element name="GetData"> <xsd:annotation> <xsd:documentation>Send data</xsd:documentation> </xsd:annotation> <xsd

XSD Error: This element is not expected

情到浓时终转凉″ 提交于 2021-01-27 05:30:31
问题 I was writing an XSD to validate a XML, but when I was validating this error appeared: Output - error Validation of current file using XML Schema: ERROR: Element '{http://www.w3.org/2001/XMLSchema-instance}Gasto': This element is not expected. Expected is ( Gasto ) ... and I'm not understanding the error Here is a sample of my XML: <?xml version="1.0" encoding="UTF-8"?> <Armazem> <Lista_Gastos xmlns:artGasto="http://www.w3.org/2001/XMLSchema-instance" artGasto:noNamespaceSchemaLocation=

Validate XML against XSD with JavaScript on client side

╄→гoц情女王★ 提交于 2021-01-20 04:27:57
问题 I am required to show a user an XMLfile in a friendly way as a result I am creating a tree like structure such as: http://thecodeplayer.com/walkthrough/css3-family-tree instead of showing the user the raw XML. Right now when creating a new node I am validating that on the server side. If the server validates the new proposed XML(tree) then I go ahead and create a new node for example. Anyways now I will like to allow the user to drag these nodes. When dragging the nodes if I validate the

Validate XML against XSD with JavaScript on client side

谁说我不能喝 提交于 2021-01-20 04:25:43
问题 I am required to show a user an XMLfile in a friendly way as a result I am creating a tree like structure such as: http://thecodeplayer.com/walkthrough/css3-family-tree instead of showing the user the raw XML. Right now when creating a new node I am validating that on the server side. If the server validates the new proposed XML(tree) then I go ahead and create a new node for example. Anyways now I will like to allow the user to drag these nodes. When dragging the nodes if I validate the

Element cannot have character [children], because the type's content type is element-only

旧街凉风 提交于 2020-12-25 02:03:14
问题 I tried validating my XML file with a XSD file but I get the following error message: [Error]: cvc-complex-type.2.3: Element 'paragraph' cannot have character [children], because the type's content type is element-only Which (if i am understanding it correctly) means a complex type cannot have a combination of simple and complex typed elements as children. But how do I fix this? I'm still kinda new to this, so the solution could be simple? My code is shown below: XSD: <?xml version="1.0"

Element cannot have character [children], because the type's content type is element-only

人走茶凉 提交于 2020-12-25 02:02:19
问题 I tried validating my XML file with a XSD file but I get the following error message: [Error]: cvc-complex-type.2.3: Element 'paragraph' cannot have character [children], because the type's content type is element-only Which (if i am understanding it correctly) means a complex type cannot have a combination of simple and complex typed elements as children. But how do I fix this? I'm still kinda new to this, so the solution could be simple? My code is shown below: XSD: <?xml version="1.0"

Where does xsd:attribute declaration go in global xsd:complexType?

混江龙づ霸主 提交于 2020-11-29 09:55:04
问题 I want to declare an attribute of an element already defined. I would like that the element person could have 2 attributes ( name , id ) I have this: <xs:element name="person" type="perso" /> <xs:complexType name="perso"> <!-- I tried to declare the attribute here.Not working--> <xs:sequence> <!-- I tried to declare the attribute here.Not working--> <xs:element name="description" type="xs:string" /> </xs:sequence> </xs:complexType> I am looking to declare a global, not local, complex type. I

Where does xsd:attribute declaration go in global xsd:complexType?

核能气质少年 提交于 2020-11-29 09:54:08
问题 I want to declare an attribute of an element already defined. I would like that the element person could have 2 attributes ( name , id ) I have this: <xs:element name="person" type="perso" /> <xs:complexType name="perso"> <!-- I tried to declare the attribute here.Not working--> <xs:sequence> <!-- I tried to declare the attribute here.Not working--> <xs:element name="description" type="xs:string" /> </xs:sequence> </xs:complexType> I am looking to declare a global, not local, complex type. I