xml-schema

¿What is the best way to Create a Xml Document conforming to a XSD Schema?

Well, I have a XSD and I have to generate a XML document for send to the customers of the company I work with. The Documents I send will be validated against this XSD schema. What is the best way to Create a Xml Document conforming to a XSD Schema? I mean, i'm searching for best practices and the like. I'm new to this and "googling" aro...

How do I specify in an XML schema where I don't care about the name of an element?

I'm trying to parse XML files and I would like to provide a schema to validate against however, since I don't care about some of the tag names, I would like to allow users to specify anything for certain tags. Example XML: <root> <record> <data1>foo</data1><data2>bar</data2> </record> <record> <data2>foo2</d...

XSD: Can I make an element inherit an ancestor's rules?

Consider the following: <xs:complexType name="A"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:group ref="subAGroup"/> <xs:group ref="xGroup"/> </xs:choice> </xs:complexType> <xs:complexType name="B"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:group ref="subBGroup"/> <xs:group ...

Mono validation of NHibernate's cfg.xml file

I'm trying to set up NHibernate in Mono, to store objects in SQLite. I've copied/pasted the example configuration file. I only have the following two lines of code: var config = new Configuration(); config.Configure(); Which result in the following ungrammatical validation exception: System.InvalidOperationException : Unexpecte...

Sub-elements and namespaces in XSD

I've been trying to figure out how to use an XML Schema to validate XML files as I load them into an application. I've got that part working, but I can't seem to get the schema to recognise anything other than the root element as valid. For instance, I have the following XML file: <fun xmlns="http://ttdi.us/I/am/having/fun" xmlns...

what means "The matching wildcard is strict"

Validating the XML against the Controlling Documents ERROR: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'adlcp:datafromlms'. line: 21, col: 24 here is error line in my xml file: < adlcp:datafromlms>course=e7.txt;lesson=1< /adlcp:datafromlms> this is from XSD: ...

ct-props-correct error when parsing schema

Hi, I'm using the JAXB xjc tool to generate some Java interface files from xsds. I'm running into a problem where I'm getting a tonne of errors of the form: org.xml.sax.SAXParseException: ct-props-correct.4: Error for type 'COCT_MT110200CA.PayeeRole'. Duplicate attribute uses with the same name and target namespace are specified. N...

Restricting an element to having text, or subelements.

We have a situation where we want to restrict an element to having: Either text(). or Subelements. E.g. <a>mytext</a> or <a><b>xxx</b></a> But not: <a>mytext<b>xxx</b></a> Given the xs:simpleContent mechanism I can restrict it to having only text, and of course I can define the element(s) it can be allowed, but does anyone k...

XSD relation/attribute question

I would like to set up an XSD such that it enforces something like a foreign key relationship. Here's an example: <MappingElement Reference="MySourceElementName"/> <SourceElement Name="MySourceElementName"/> I would like to specify in the XSD that for any value assigned to the attribute "Reference" must also be a value of a Name ...

XSD date format overriding

I am defining an XSD. I need to define an element which takes date in format yyyymmdd. How can I define a restriction in XSD to only accept this format? ...

Complex rules in XSD for elements sequence

In my XML I have 6 elements X1, X2, X3, X4, X5 and X6. The rules are as follows - X1 must be followed by X2 X2 must be followed by X3 X3 must be followed by X4 X4 must be followed by X2, X3, X4 or X5 X5 must be followed by X6 X6 can be followed by X2, X3, X4, X5 or X6 I am trying to define an XSD for this. Is it possible? I tried...

How can I require at least 1 occurrence of an element in the XSD?

How can I require the "Address" element? If I perform an XSD validation on a document with no "Address" it passes, but I would like it to fail. Is this possible? http://en.wikipedia.org/wiki/XSD see the example xsd. it hiding my xsd sample <?xml version="1.0" encoding="utf-8"?> <xs:schema elementFormDefault="qualified" xmlns:xs="http...

XML Schema: Setting a default value for a complexType?

Let's say I want to set up a generic complexType like so: <xs:complexType name="button"> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="href" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="label" type="xs:string" minOccurs="0" maxOccurs="...

Why does XSD validation always work for this file?

The following xml file always seems to validate. Not sure why, but when I remove the following ' xmlns="urn:schemas-microsoft-com:office:spreadsheet" ', it seems to throw a validation error as expected. Somehow MS is preventing validation with the added XSD office schema. So anytime that XSD Schema is included you can't validate XML usi...

Linq To XSD at runtime.

Hi, I'm trying to get the .NET object representation of a certain XSD(element) at runtime. How can I use Linq to XSD to do that in runtime as opposed to design time? Thanks, --Ran. ...

XMLDocument.Validate Error: System.InvalidOperationException : The XmlSchemaSet on the document is either null or has no schemas in it

I got this weird error when I wanted to validate my in-memory xml Schema, anything I did wrong? [Test] public void ValidationXML() { int errorCount = 0; var xmlString = "<?xml version='1.0'?><response><error code='1'> Success</error></response>"; XmlDocument xmlDocument = new XmlDocument(); xm...

Validate an XML File Against Multiple Schema Definitions

I'm trying to validate an XML file against a number of different schemas (apologies for the contrived example): a.xsd b.xsd c.xsd c.xsd in particular imports b.xsd and b.xsd imports a.xsd, using: <xs:include schemaLocation="b.xsd"/> I'm trying to do this via Xerces in the following manner: XMLSchemaFactory xmlSchemaFactory = new...

XInclude Schema/Namespace Problem?

I'm trying to use XML Includes to help manage a large XML structure that needs to be usable by both humans and machines. But am experiencing a myriad of problems when trying to construct XML files that can be validated against an existing schema. Here's a simplified example of what I'm trying to do. My "main.xml" file does not validat...

Can Keys and Keyrefs be spread across multiple XSD files?

I'm trying to mimic a relational database structure using XML. (Just in case anyone is wondering why, my reasons for using XML are: (1) The total amount of data is expected to be small, (2) I need non-programmers to be able to edit some of the input tables, and (3) I want the installation process to be as simple as possible (i.e., no da...

Survey: how are you using ID/IDREF? (or key/keyref)

I'm interested in how people use this feature: what domain, what relationships (apologies if survey questions aren't appropriate). XML represents trees naturally using containment; but it can also represent graphs, using IDREFs that refer to IDs: many elements can refer to the same element (multi-ref); and a nested element can refer to ...