Questions tagged [xml-validation]

the procedure of checking an XML document against some kind of schema that describes rules that this type of document must conform to. This can often be done programmatically in eg. Java or C# and the schemas are often of the type XSD.

xml-validation
Filter by
Sorted by
Tagged with
1 vote
3 answers
194 views

XML Schema- how to match any integer?

I need to write a XML file which should conform to a schema. The schema enforces datatype of the element (happens to be process id on Linux) to be an integer. This fragment of the code passed the ...
user837208's user avatar
  • 2,537
1 vote
2 answers
851 views

minOccurs/maxOccurs on xsd:sequence vs xsd:element?

Let say we have the following schema (from a Microsoft sample): <xs:element name="zooAnimals"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="...
Jean-Philippe's user avatar
1 vote
2 answers
865 views

xsd:sequence: A problem was found starting at: simpleType

So I am facing this error while I was validating XML against XSD Error - Line 38, 44: org.xml.sax.SAXParseException; lineNumber: 38; columnNumber: 44; s4s-elt-must-match.1: The content of 'sequence' ...
Piyush Bajaj's user avatar
1 vote
1 answer
6k views

cvc-complex-type.2.3 : Element 'Project' cannot have character children

I am trying to create a spring boot application, but I get some issue in my project. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Mohamed Ali Lassoued's user avatar
1 vote
2 answers
2k views

Why is my XSD allowing a prohibited attribute in my XML?

I've inserted an attribute called Classroom into an element called Lecture. Here's the XML schema : <xsd:attribute name="Classroom" use="required"> <xsd:simpleType> <xsd:...
Dimitris Delis's user avatar
1 vote
1 answer
4k views

unable to validate SAML 2.0 assertion against schema

I am working with Spring SAML and I have problem consuming SAML assertion (sample assertion from Wikipedia article <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:...
Bartosz Bilicki's user avatar
1 vote
1 answer
2k views

How to prevent empty element in XSD while requiring an attribute

I am validating an XML document with the below XSD, and I want to ensure that the value of reportPath is not empty. Here is my current XSD.. <xs:element name="reportPath"> <xs:...
vishwas 115's user avatar
1 vote
1 answer
2k views

Can't find "schemaLocation" attribute

I'm creating a schema to validate some XML, but when it comes down to actually reading in the document, I'm getting the error: The 'http://www.w3.org/2001/XMLSchema:schemaLocation' attribute is not ...
elucid8's user avatar
  • 1,412
1 vote
3 answers
3k views

Is there a light-weight, free XML/XML Schema editor available, with support for XML Schema catalogs and XML Validation? [closed]

I have recently switched from working on Android in Eclipse to working on iOS apps in Xcode. I really liked the Eclipse XML editor interface (which has features like auto-complete, CDATA documentation ...
Phil's user avatar
  • 36.2k
1 vote
1 answer
265 views

XSD validation says my <any> is not defined

I'm trying to build a schema using an <xs:any /> node. When I validate it says the inserted child nodes aren't defined. I thought any allowed me to have undefined child nodes. My schema: <xs:...
Jay's user avatar
  • 14.2k
1 vote
2 answers
475 views

Why is XML validation in a Blazor application giving different messages on localhost and as an Azure Static Web App?

edit I made a simplified repo at https://github.com/GilShalit/XMLValidation I am building an XML editor in Blazor WebAssembly (TargetFramework=net5.0). Part of the functionality involves validating ...
GilShalit's user avatar
  • 6,291
1 vote
1 answer
425 views

XSD String pattern which inlcude email with Latin characters

<xsd:element name="MigrCustContactEmail" type="StringX50Email" minOccurs="0" maxOccurs="1"/> <xsd:simpleType name="StringX50Email"> ...
murari99732's user avatar
1 vote
2 answers
117 views

Can I validate polymorphic XML elements based on a child Type element value?

I want to validate polymorphic Shape elements, differentiated by the Type child element (not attribute) value. Below are sibling Circle and Rectangle Shape elements. Circles have a Radius and only 1 ...
jbobbins's user avatar
  • 1,271
1 vote
1 answer
398 views

In WSO2 ESB is validate XML before coming to the api

Is there a way to validate XML coming to the WSO2 ESB API since in order to validate. I'm getting an error when the wrong XML comes to my API. This is the error I'm getting when it comes to the API I ...
Malinda Peiris's user avatar
1 vote
1 answer
434 views

XML Schema: Difference between using <xs:all> and not when minOccurs="0"

What is the difference between this (taken from w3schools.com reference for <xs:all>): <xs:element name="person"> <xs:complexType> <xs:all> <xs:element name="...
Alex's user avatar
  • 109
1 vote
1 answer
4k views

Validating xml against an xsd that has include and import in c#

I would like to cache the xsd then perform validation against it rather than loading xsd every time for any xml in order to increase performance. However, I could not manage to do it. My guess is that ...
aeb-dev's user avatar
  • 313
1 vote
2 answers
3k views

Element http://www.w3.org/2001/XMLSchema:complexType is invalid in this context

I'm trying to validate this XML file <session> <mic id="1" posname="T1" x="0.0" y="0.0" z="0.0" /> </session> using this XSD file <?xml version="1.0" encoding="utf-8"?> &...
Godzby's user avatar
  • 33
1 vote
1 answer
1k views

Unique Particle Attribution error

Aim: I am having an existing standard XSD called Schema1.xsd. I want to extend the complexType("tElementWithIDAndName") of Schema1.xsd in complexType("TVDSection") of Schema2.xsd. When i try to ...
VinayCH's user avatar
  • 27
1 vote
1 answer
460 views

Dependent naming of XML element in Xml Schema

Assuming that I have this XML: <parameters> <parameter type="string" isVisible="True" optional="False" id="DealerCode"> <DealerCode>ABCDEF001</DealerCode> </...
rbr94's user avatar
  • 2,247
1 vote
1 answer
1k views

Using xs:extension and xs:restriction in a XSD

I wanted to use both xs:extensions and xs:restriction together in my XSD for the below mentioned XML <?xml version="1.0" encoding="utf-8"?> <records> <row id="1"> <record&...
hakuna's user avatar
  • 6,481
1 vote
1 answer
540 views

Why is my XSD not validating some elements?

I am trying to define an XML Schema for a recursive data structure. Basically an element should be able to have children and properties, which is a list of elements that may in turn have children and ...
Taus's user avatar
  • 344
1 vote
2 answers
2k views

Disable XSD validation for a single element?

I have one XSD file, which contains some element <xs:element name="BasicData"> <xs:complexType> <xs:sequence> <xs:element ref="TTTeacherList" ...
Gabu's user avatar
  • 83
1 vote
1 answer
463 views

XSD restrict tag content depending upon attribute value

I would like define an XSD that allows an element to have specific children regarding one of its attribute value. This attribute values are defined using multiple xsd:enumeration. Here is how my XML ...
PlikPlok's user avatar
  • 110
1 vote
1 answer
3k views

XSD restriction either number or fixed string

Right now I am trying to write an XSD for my XML. What I need to do is to write a simpleType definition which will allow to input into XML either number (non-decimal) or string with one possible ...
Michael Iris's user avatar
1 vote
2 answers
1k views

Enforce further constraints on xsd:any?

I have an XSD 1.0 sequence that defines a set of elements, some of which may be optional but none of which can occur more than once, and which also ends with an <xsd:any minOccurs="0" maxOccurs="...
ivanatpr's user avatar
  • 1,870
1 vote
1 answer
1k views

XSD: define complex element with attribute and other child elements

I want to define an element like this: <A id='1'> <name>jack</name> </A> With this below I could define attribute id of element A: <xs:complexType name="A"> <...
JACK M's user avatar
  • 2,771
1 vote
1 answer
988 views

XML Schema for sequence order/restriction based on attribute value

Is it possible to define in XML Schema a sequence order/restriction based on attribute value? In XML, there is container node which keeps only item nodes. First item node is always delimiter, other ...
user2931279's user avatar
1 vote
1 answer
2k views

How to validate XML with generated c# class from XSD

I want to send a http request from client to local server and on the server I made a query with Linq that returns data in xml I also have .xsd file and a .cs file enerated from my xsd file that I want ...
user3122648's user avatar
1 vote
1 answer
612 views

Validating against XSD with global attributes and namespaces

I am trying to reference a few attributes in the XSD file (XML Schema), and getting the following errors: Attribute 'code' is not allowed to appear in element 'project'. Attribute 'type' is ...
Liran H's user avatar
  • 9,831
1 vote
1 answer
150 views

xsd: attribute points to element id

I have an xml describing vertices on a directed graph: <graph> <vertex id="a"> <edge target="b"/> </vertex> <vertex id="b"/> </graph> Given the schema: ...
eladidan's user avatar
  • 2,642
1 vote
1 answer
1k views

Printing traceback with lxml xml schema validation

I am using lxml package (etree) to take in a xml schema and parse it against xml file using the code. from lxml import etree import traceback schema_file = 'C:/Users/Romi/Desktop/XML Testing/schema....
Scooby's user avatar
  • 3,471
1 vote
2 answers
7k views

Unique Particle Attribution Error with <any>, <element>, and <choice>

Goal: Element octave can have either subnode query or any subnode in namespace http://www.website.com/main. I don't know where/how this is violating unique particle attribution...there's no other ...
Jefftopia's user avatar
  • 2,125
1 vote
1 answer
62 views

Checking XML file for specified rules

Let's say I have the following xml file: <report> <income> <amount type="type1">50</amount> <amount type="type2">100</amount> </income> <...
torayeff's user avatar
  • 9,516
1 vote
2 answers
5k views

Validate an XML file against an XSD schema using JDOM 2.0

I've been looking for an example on how to validate an XML file against an XSD schema using JDOM 2.0 before parsing it. I've been searching for about an hour but wasn't able to find a solution which ...
Dušan Rychnovský's user avatar
1 vote
2 answers
426 views

How to break the loop in the case of some error has been caught

Q: I want to break the loop if some exception has been caught in the event. The code : XmlDocument x = new XmlDocument(); x.Load(targetFileName); XmlReaderSettings settings = new XmlReaderSettings(...
Anyname Donotcare's user avatar
1 vote
1 answer
3k views

XSD - attribute restriction ignored when validating

I am having issues trying to test the below xsd against the below xml files. Are my tools bad, or is my xsd not functioning in a predictable way? Software tested: xmllint (using libxml version ...
Ryan Gooler's user avatar
  • 2,055
1 vote
1 answer
612 views

XPathNavigator.CheckValidity validates invalid XML document

I'm trying to use XPathNavigator.CheckValidity to validate an XML document. Somehow, I was able to write tests that passed using this method, but now (mysteriously) aren't passing anymore. The only ...
bdukes's user avatar
  • 154k
1 vote
2 answers
3k views

How to validate REST request?

Given this service: POST /hotel HTTP/1.1 <hotel> <a>aaa</a> <b>bbb</b> <c>ccc</c> </hotel> HTTP/1.1 201 CREATED Location: /hotel/123 When we ...
Marcus Leon's user avatar
  • 55.8k
1 vote
1 answer
165 views

Restricting values in XML Schema

I have an XSD with two elements, name and color. Would like to restrict length of names to 5. Getting an error: simpleType element not supported in this context. As I understand these are custom ...
teknik's user avatar
  • 155
1 vote
2 answers
541 views

How can you define an element by position in XML Schema?

How can you define an element by position in XML Schema? We're getting various XML data feeds with the data as a series of <row> elements, with the actual values as <value>. The XML files ...
SteveC's user avatar
  • 16.3k
1 vote
1 answer
827 views

How to link XML file with XSD schema?

I am new to XML. Can somebody help me connect the XSD to XML file ? Here is my XML: <WorldWideHappiness xmlns="https://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/...
GEORGI DIMITROV's user avatar
1 vote
1 answer
41 views

The xs:extension causes my element to stop enforcing its type

I have a simple element in an XSD file "strict" that only acepts boolean, however when I use xs:extension, the type is no longer enforced. Here it is declared without attributes: <xs:...
E.S.'s user avatar
  • 2,793
1 vote
1 answer
614 views

SaxonEE-9.9: Escape Character '@' not allowed in regular expression

I use Saxon EE APIs to validate XML payload with XSDs. My environment is OSGi. One of my user is trying to escape @ character in regex definition. I've shared the snippet of the line which is causing ...
Subash's user avatar
  • 431
1 vote
1 answer
181 views

Compare two xml element from different parents using xs:assert XSD 1.1

Can i compare two xml element from different parents using xs:assert for example I want to compare <xs:assert test="pa:MsgId eq pa:EndToEndId"/> or may be checking NbOfTxs = number of ...
ravi's user avatar
  • 23
1 vote
2 answers
177 views

Difference between empty simple element and empty complex element - XML

Is there any difference between an empty simple element and an empty complex element in a xml file? How can I distinguish them? On w3schools I found: empty simple element <element></element&...
Gennaro Arguzzi's user avatar
1 vote
1 answer
4k views

s4s-elt-schema-ns: The namespace of element 'schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'

I have a more or less simple task to build a XSD schema of but I'm not sure if my idea here is right. Especially for the element comment. Customers can make purchase orders. A purchase order includes ...
CptDayDreamer's user avatar
1 vote
1 answer
229 views

Require either both attributes or none to be present by XML schema

I have an element that could look like this: <MyElement start="12.5. 2020" end="6.6 2020" info="Hello world!"/> But also this: <!-- This element still can contain useful info, but is not ...
Tomáš Zato's user avatar
  • 51.5k
1 vote
1 answer
139 views

Using XPath to retrieve information from a XML File based upon a XML Schema created by me

I'm developing a markup language and I started with defining a DTD. As I was finishing my DTD, I noticed I needed a stronger type of document for my language so I went for an XML Schema based upon my ...
Gallo Arrosto's user avatar
1 vote
1 answer
1k views

s4s-elt-must-match.1: The content of X must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*))

<?xml version="1.0" encoding="utf-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="City"> <xsd:complextype> <xsd:...
user avatar
1 vote
1 answer
189 views

XSD to validate a list of 1 to 4 specific characters

I would like to validate that an attribute value in my XML contains at least one character and up to 4 characters in a set. The values I'm looking for are "T", "C", "S" and "R". They can be in any ...
J. Jordan's user avatar

1
6 7
8
9 10
21