xml-validation

Singling out web.xml errors in Eclipse

When Eclipse detects an invalid XML document, in my case a web.xml file, it dumps the content model of the DTD and tells me that the element is invalid. This is quite unhelpful, since it ends up telling me that: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,f...

How can I validate the XML document in a SAXParser without having to use an XMLReader?

I want to create a SAXParser which validates, but it seems the only way is either to create an XMLReader and use setErrorHandler() or let the ContentHandler in SAXParser.parse() also implement ErrorHandler. Am I missing something? All I want to do is create a validating SAXParser like this: private SAXParser createParser(final boolean ...

Using .NET to validate XML against a schema

I want to test (true or false) whether an arbitrary XML file matches a given schema. For what it's worth, the schema is the Word 2003 WordML schema, which Microsoft defines using a list of about 7 *.xsd files. One of these files also includes the W3C xml.xsd file, by including the following statement: <xsd:import id="xml" namespace="h...

How to validate an XML document?

My C#/.NET application reads XML files that are manually edited by the users. The allowed elements and tags are described in the application's documentation. I'm using LINQ to extract data from the XML file. Before extracting data from the XML file, I'd like to validate it to see if it has the expected structure. If not, it would be nic...

Which is the best methode for xml validation in java?

Hi, I want to create a validator for xml using xsd schema in java language. When I searched in the internet I found 3 meothods using javax.xml.validator, using jaxp parser, using sax parser. Can you please suggest which is the best methode in these 3? ...

Reference an XSD file from different XMLs sitting in different project modules?

I have an XSD file that is referenced in three different XML files in different project modules using: <item-groups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xml_schemas/item_groups.xml.xsd"> I have been trying to figure how to avoid manually copying the XSD into every module that needs it, s...

In Java: validate XML against multiple schema's, located @ difference server locations

In my program, I am generating a XML file, and need to validate that XML file against multiple schema's which(schema) are located on different URLs. Its required to validate that XML file against all schema in onetime only. source fragment:- // here source array contain the locations of schemas, located at diff servers. Source [] sour...

XML validation by XSLT or Schematron in Eclipse XML Editor?

How can we validate xml document by either schematron or xslt in Eclipse xml editor? The idea is to extend xml document live validation in eclipse xml editor with some rules based validation method. ...

Solve: XML Schema validation ignored when fragment-level conformance is enabled?

From my sojourn with XML and Schema validation, it seems that when fragment-level conformance is enabled for an XMLReader instance, the XML source stops being validated against any included Schemas. However I cannot verify this from the MSDN documentation as it doesn't seem to describe XSD Schema behaviour in light of conformance level...

Xsd, Validate empty or minimum length string

Currently I have an Xsd validating with this rule <xs:simpleType name='shipTo'> <xs:restriction base='xs:string'> <xs:minLength value='6'/> </xs:restriction> </xs:simpleType> I need to allow blanks as well, but if a value is entered, it's minimum length should still be 6. Can I do this without resorting to this xs:pat...

How to correct a xml file based on a xml schema?

There are a lot of files that have changed unintentionally and now they don't match their related schema. What I want to do is to find the errors and to correct them automatically (if possible). I looked at the validation mechanism available in .NET framework. The problem is I don't know how I can edit the erroneous node.The validation ...

The most performant way to validate XML against XSD

I get a string variable with XML in it and have a XSD file. I have to validate the XML in the string against XSD file and know there is more than one way (XmlDocument, XmlReader, ... ?). After the validation I just have to store the XML, so I don't need it in an XDocument oder XmlDocument. What's the way to go if I want the fastest per...

How to exclude root elements in an XSD?

I have several elements defined in my XSD file that I use as references later on in the document. I do want any of these "reference" elements to constitute a valid xml file. For example I have <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name=...

XML Namespace error in WSDL file

I have the following service definition (incomplete, but demonstrates the error. Visual Studio tells me (translated from german) "In this Schema Namespace http://schemas.xmlsoap.org/wsdl/ is not available" at the line where I define OffertXML. <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions name="TestOffertverwaltung" targetNa...

Schematron validation and uniqueness

Hi, I'm trying to write some Schematron rules and one of them is supposed to check, if elements are unique in the scope of parent element. So I have an example xml structure: <abc> <elem id="qw0"> <a>1</a> <a>2</a> <a>3</a> </elem> <elem id="qw1"> <a>1</a> <a>2</a> <a>3</a> <a>3</a> </elem> </abc> M...

Struts2 Validation

In Struts2, can we have both validation xml (ActionClass-method-validation.xml) and validate method implemented in Action class. I was asking as this validation xml don't get invoked in my situation. ...

Rss20FeedFormatter is producing RSS that is not well formed

I am using ASP.Net MVC2 and have a RSS feed for my blog. I am using out of the box functionality in System.ServiceModel.Syndication and Rss20FeedFormatter. The feed works fine and can be read by Outlook as well as every browser I have tried. However when I submitted the RSS feed to google as a sitemap I got validation errors. Out of cu...

javax.xml.parsers.DocumentBuilder support for complex types

Hi, I'm trying to put together some validation code. I am trying to validate against a schema like: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:choice="http://example.com/SimpleChoice" targetNamespace="http://example.com/Simpl...

Validate jaxws soap request against schema inside wsdl:types

I'm wanting to validate a soap request against the schema inside this wsdl. <wsdl:types > <xsd:schema targetNamespace="http://ws.thecompany.com/FormSubmissionService20100824" xmlns:request="http://xmlschema.thecompany.com/generic/FormHeader20100824" xmlns:response="http://xmlschema.thecompany.com/generic/FormRespons...

Validating different sets of required attributes in an XML schema.

My requirement is to validate an xml with two different validation strategies. In strategy 1, the xml is required to have instances of an element with certain required attributes. In strategy 2, the xml is required to have instances of the same element with different required attributes. So, the idea is that there are two different sets ...