xml-schema

Restrict values of an element to be unique within the elements under the same XPath

Consider this XML - <Root> <Foo> <UniqueValue>A100</UniqueValue> </Foo> <Foo> <UniqueValue>A101</UniqueValue> </Foo> <Foo> <UniqueValue>B102</UniqueValue> </Foo> <Foo> <UniqueValue>A101</UniqueValue> <!-- This should be an error --> </Foo> <Foo> <UniqueValue> A101 </UniqueValue> <!-- This should be ...

Validate a XDocument against schema without the ValidationEventHandler (for use in a HTTP handler)

Hi everyone, (I am new to Schema validation) Regarding the following method, System.Xml.Schema.Extensions.Validate( ByVal source As System.Xml.Linq.XDocument, ByVal schemas As System.Xml.Schema.XmlSchemaSet, ByVal validationEventHandler As System.Xml.Schema.ValidationEventHandler, ByVal addSchemaInfo As Boolean) I a...

Invalid XML Schema for element with/without sub-elements

Hi I want to write an XML schema which has an element which may contain subelements and/or primitive types. So I have this fragment which does not validate correctly. <xs:complexType name="parameterType" mixed="true"> <xs:complexContent> <xs:restriction base="xsd:anyType"> <xs:any processContents="lax" minOccurs="0"...

XSD force to use a particular order for the elemnt with attribute.

Hi, I've an XML file like the one below <transaction name="TEST_EX" type="singletonComplex"> <vo class="svc.vo.UserProfile"> <field deepMapping="true"> <vo class="svc.vo.UserVO"> <field name="UserName" column="User_Name" type="String"/> <field name="Age" column="User_Age" type="Integer"/> </vo> </field> <fi...

XSD, restrictions and code generation

Hello, I'm working on some code generation for an existing project and I want to start from a xsd. So I can use tools as Xsd2Code / xsd.exe to generate the code and also the use the xsd to validate the xml. That part works without any problems. I also want to translate some of the restrictions to DataAnnotations (enrich Xsd2Code). For ...

How to present a type of an element in xml-schema?

I'm making a xml schema and I have to present database columns which have name, type and table they belong to. Like this: <xs:complexType name="tMappingItem"> <xs:sequence> <xs:element name="name" type="xs:string" /> <xs:element name="type" type="xs:string" /> <xs:element name="table" type="xs:string" /> </xs...

How to set a value for a string in a really complicated c# partial class for a web service with xml-seriaisation? (I think)

Hi I'm new to C# and I'm using MS VS2008 Express on XP32. I have this class, auto-generated from a wsdl: public partial class PartDataSetType { private object[] partDataSetField; /// [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlArrayItemAttribute("Entit...

What's the difference between xsd:include and xsd:import?

What's the difference between xsd:include and xsd:import? When would you use one instead of the other, and when might it not matter? ...

Disallow an element to be a child of itself in XML Schema

Hi! Im writing a XML schema for a project. I cannot solve following problem: A element cannot be nested by itself, ex: <document> <text> <b> <i> <a link="http://wikipedia.org"&gt; <b /> </a> </i> </b> </text> </document> This example shouldn't be allow becaus...

Loading XHTML schemas to XmlSchemaSet

Hello, I'm trying to load the XHTML schemas from the W3C site (xhtml - transitional, strict & frameset) which I'm having to put into to an XmlSchemaSet. This is then used by a third party product in our application to show intelisense and validation. However when I try and "Compile" this XmlSchema set I get the following message: Th...

XSD "one or both" choice construct leads to ambiguous content model

I am trying to make a simple XSD choice construct allowing either one or both of two referenced elements, but not none. The construct is similar to below but I keep getting an ambiguity error. What am I missing? <xs:schema xmlns:xs="..."> <xs:element name="Number" type="xs:integer"/> <xs:element name="Text" type="xs:string"/> <xs:...

XML Validation Confusion

I'll admit, I'm an XML newbie. I'm having trouble validating some xml against a schema. Here is the relevant part of my schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.me.com/orpm/kpi/automation/report" targetNamespace="http://www.me.com/orpm/kpi/automation/...

Restrict Element Values Based on Attribute

I want to restrict the type of an Element based on the value of an Attribute, like this: <Data type="decimal"> 44.00 </Data> <Data type="date"> 2008-02-01 </Data> Can a Schema be defined that does this? ...

Inheritance with JAXB.

I have an XSD file which is used to generate some objects which are then shared with other systems. I'd like to customize some of the business logic a bit in there by making some more specific implementation of these. I'm not adding new fields which need to be serialized, but more along the lines of adding setMethods which may take diffe...

How do I ensure unique element values in an XML schema?

I want to ensure that there are no duplicate book titles in the following xml: <?xml version="1.0" encoding="UTF-8"?> <books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="books3.xsd"> <book> <title>Book1</title> </book> <book> <title>Book2</title> </book> <book>...

when unmarshaling from a schema the order of a sequence matters in jaxb

I have this schema: <xs:complexType name="foo"> <xs:sequence> <xs:element name="oneBar" type="xs:string" minOccurs="0"/> <xs:element name="twoBar" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> When I try to unmarshal this <foo> <oneBar>1</oneBar> <twoBar>2</twoBar> </foo> it works but when ...

How to compile a schema that uses a DataSet (xs:schema)?

I have created the simplest web service in c#: public void AddData(DataSet ds) The generated schema (Wsdl) looks like this: <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"&gt; ... <s:element ref="s:schema" /> ... </s:schema> Note the schema does not contain any import/include elements. I am trying to load this schema to a c# ...

How to ignore the validation of Unknown tags ?

One more challenge to the XSD capability,I have been sending XML files by my clients, which will be having 0 or more undefined or [call] unexpected tags (May appear in hierarchy). Well they are redundant tags for me .. so I have got to ignore their presence, but along with them there are some set of tags which are required to be validat...

XML Schema design decision

I am designing an XML schema to hold the output of my program. However, I am hesitating concerning a design decision, and I would like the input of more experienced programmers. If I have a complex element <list> <elmt>1</elmt> <elmt>2</elmt> </list> However, the nested elements in <list> are optional. My question is how should the fi...

xml schema validation for large schema files

Hi, I'm trying to use xmllint to validate the schema, which I believe uses the libxml2 library underneath. The problem is I have a unusually large schema file in about 10MB. When I do this: xmllint --schema j9.xsd --noout jsample.xml I got the following errors: j9.xsd:65535: element annotation: Schemas parser error : Element '{http...