xml-validation

XML XSD Schema - Enforce Unique Attribute Values in Schema

我怕爱的太早我们不能终老 提交于 2019-11-26 22:42:46
问题 Lets say I have a schema that defines the following XML: <Values> <Add Key="Key1">Value 1</Add> <Add Key="Key2">Value 2</Add> <Add Key="Key3">Value 3</Add> <Add Key="Key4">Value 4</Add> </Values> I would like, at a schema level, to be able to enforce that the values for the Key attribute are unique, i.e. the example above is valid, but the following example would be invalid: <Values> <Add Key="Key1">Value 1</Add> <Add Key="Key2">Value 2</Add> <Add Key="Key2">Value 3</Add> <Add Key="Key3"

Require XML element in XSD when another element has certain value?

血红的双手。 提交于 2019-11-26 20:57:28
I need a required attribute or element only if a specific value of an enumeration is chosen. Example below: <xs:element name="TYPE" type="TestEnum" /> <!-- // This Element should only required when TYPE = INTERNATIONAL --> <xs:element name="IBAN"/> </xs:complexType> <xs:simpleType name="TestEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="NATIONAL"/> <xs:enumeration value="INTERNATIONAL"/> </xs:restriction> </xs:simpleType> XSD 1.1 Here's how use xs:assert to make IBAN be mandatory when TYPE = 'INTERNATIONAL' : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http:/

External referenced DTD in XML

江枫思渺然 提交于 2019-11-26 19:05:54
test.xml: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email SYSTEM "test.dtd"> <email> <von>test@test.com</von> <zu>xxx@example.com</zu> <titel>Hello</titel> <text>Dear John....;-).</text> <prior type="schnell"/> </email> test.dtd: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email [ <!ELEMENT email (von,zu,titel,text,prior)> <!ELEMENT von (#PCDATA)> <!ELEMENT zu (#PCDATA)> <!ELEMENT titel (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ATTLIST prior type CDATA #REQUIRED > ]> Error Code in test.dtd The markup declarations contained or pointed to by the document type declaration must be well

cvc-elt.1: Cannot find the declaration of element 'MyElement'

人走茶凉 提交于 2019-11-26 18:11:19
问题 I'm trying to validate a really simple xml using xsd, but for some reason I get this error. I'll really appreciate if someone can explain me why. XML File <?xml version="1.0" encoding="utf-8"?> <MyElement>A</MyElement> XSD File <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/Test" xmlns:tns="http://www.example.org/Test" elementFormDefault="qualified"> <simpleType name="MyType"> <restriction base="string"><

What does elementFormDefault do in XSD?

会有一股神秘感。 提交于 2019-11-26 15:11:24
What does elementFormDefault do, and when should it be used? So I found some definitions for elementFormDefault values: qualified - elements and attributes are in the targetNamespace of the schema unqualified - elements and attributes do not have a namespace So from that definition I would think that if a schema is set to qualified then why must you prefix the type with the namespace? And what are the scenarios that you would even have one set to unqualified for that matter? I tried Googling, but all I got were a couple W3C pages that were extremely hard to understand. This is the file I am

External referenced DTD in XML

霸气de小男生 提交于 2019-11-26 05:39:14
问题 test.xml: <?xml version=\'1.0\' encoding=\'UTF-8\'?> <!DOCTYPE email SYSTEM \"test.dtd\"> <email> <von>test@test.com</von> <zu>xxx@example.com</zu> <titel>Hello</titel> <text>Dear John....;-).</text> <prior type=\"schnell\"/> </email> test.dtd: <?xml version=\'1.0\' encoding=\'UTF-8\'?> <!DOCTYPE email [ <!ELEMENT email (von,zu,titel,text,prior)> <!ELEMENT von (#PCDATA)> <!ELEMENT zu (#PCDATA)> <!ELEMENT titel (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ATTLIST prior type CDATA #REQUIRED > ]>

Require XML element in XSD when another element has certain value?

我只是一个虾纸丫 提交于 2019-11-26 04:27:42
问题 I need a required attribute or element only if a specific value of an enumeration is chosen. Example below: <xs:element name=\"TYPE\" type=\"TestEnum\" /> <!-- // This Element should only required when TYPE = INTERNATIONAL --> <xs:element name=\"IBAN\"/> </xs:complexType> <xs:simpleType name=\"TestEnum\"> <xs:restriction base=\"xs:string\"> <xs:enumeration value=\"NATIONAL\"/> <xs:enumeration value=\"INTERNATIONAL\"/> </xs:restriction> </xs:simpleType> 回答1: XSD 1.1 Here's how use xs:assert to

How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?

帅比萌擦擦* 提交于 2019-11-26 02:20:09
I found some tips for this problem, but still didn't help me. Here is my XML <?xml version="1.0" encoding="UTF-8"?> <work xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2001/XMLSchema-instance" tns:schemaLocation="myXSDSchema.xsd"> <tns:Objects> <tns:Object Name=":" Location=":"> </tns:Object> </tns:Objects> </work> Here is my XSD file: <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns = "http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> (some checks) </schema> My XSD file is located in the same folder as the XML. How to link these 2 files? How

How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?

自作多情 提交于 2019-11-26 01:08:52
问题 I found some tips for this problem, but still didn\'t help me. Here is my XML <?xml version=\"1.0\" encoding=\"UTF-8\"?> <work xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://www.w3.org/2001/XMLSchema-instance\" tns:schemaLocation=\"myXSDSchema.xsd\"> <tns:Objects> <tns:Object Name=\":\" Location=\":\"> </tns:Object> </tns:Objects> </work> Here is my XSD file: <schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns = \"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\

How to fix error: The markup in the document following the root element must be well-formed

本小妞迷上赌 提交于 2019-11-26 00:18:31
问题 I put my code in the XML validation website and it gives me this error: Line 8: 4 The markup in the document following the root element must be well-formed. The line that is having an issue is the <xsl:output method = \"html\" doctype-system = \"about:legacy-compat\"/> , line. XML <?xml version=\"1.0\"?> <!-- Fig. 15.21: sorting.xsl --> <xsl:stylesheet version = \"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"/> <!-- write XML declaration and DOCTYPE DTD information --> *<xsl:output