xml-schema

XML: Enforce child structure for two elements through XML Schema

Is it possible (and if so, how) to enforce with XML Schema that two elements in a document must contain an identical substructure? For instance, I'd like to express that any foo has two children, bar1 and bar2, and bar1 has to have the same child structure as bar2: <foo> <bar1> <baz>hello, world</baz> </bar1> <bar2> <baz>h...

XML: How to reprepresent objects with multiple occurences?

hi, i need to save objects that can occur multiple times. each object is marked with unique identifier. when it is serialized first time all its properties are written. after that only references are used. <actionHistory> <add> <figure id="1" xsi:type="point"> <position x="1" y="2" /> </figure> </add> <change> ...

Why qualify global elements in instance document?

When validating an xml document using xml-Schema and namespaces, the instance document has to have its global element prefixed with a namespace to qualify it, besides declaring the namespace itself. One would think that a default namespace would suffice in this case to qualify the element, but xml-Schema apparently has another opinion. ...

Help me clean some ugly XML

I'm getting this XML from a service that I need to deal with. I'm not much on XML Schema or Namespace fu, but to me it looks a mess. Can someone take a look at it and tell me how to make it nicer? http://gist.github.com/325952 I know that the namespace definitions can be declared in the first line, and not on every line. Is there an...

why can i import this type from a xsd schema?

In the schema below, the line <xs:element type="cmn:AddressType" name="ResidentialAddress" minOccurs="1" maxOccurs="1" /> gives an error Type 'http://company.com/Common:AddressType' is not declared. Does anyone know why? It shows in the Visual Studio 2008 editor, and also if I try validate an XML file with XDocument. Schema Student.xsd...

XSD Schema for XML with multiple structures

I am attempting to write an XML Schema to cover a number of XML conditions which I may encounter. I have the same root element (serviceRequest) with different child elements. I was trying to use the xs:extension element to define multiple versions, but it is complaining about unexpected element orderInclusionCriteria etc. Am I going a...

Is it possible to have multiple substitutiongroups per element type?

Say you have the following in a schema: <xsd:complexType name="shape"/> <xsd:complexType name="circle"> <xsd:complexContent> <xsd:extension base="shape"> <xsd:attribute name="radius" type="xsd:double"/> </xsd:extension> </xsd:complexContent> </xsd:c...

xml schema construction

in xml can any concept inhert the attribute of the main concept as an example: <Books> <TITLE datatype="string"> </TITLE> <author datatype="string"> </author> <binding datatype="string"> </binding> <ISBN datatype="Nmtoken"></ISBN> <Publisher datatype="token"></Publisher> <TextBooks> </TextBooks> <...

Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?

I've some XML being returned from various sources and rather than update each of the sources so that they return date-specific data as attributes in either xs:date or xs:dateTime format I'd like for the XML Schema to be liberal and accept either. Is it possible to use an OR operator somehow? What are the options? ...

How define several elements with same name, but different type in xsd:choice element?

Is it possible in some way, to define an xsd scheme which could validate such xml: <item_list> <item ItemType="SimpleMessage" Caption="Simplest message"/> <item ItemType="ComplexMessage" SomeAttr="value"> <item_data>some text</item_data> </item> </item_list> Problem is that i havn't find any possibility to define smth like: ...

XML Attributes or Element Nodes?

Example XML using element nodes: <?xml version="1.0" encoding="utf-8"?> <users> <user> <name>David Smith</name> <phone>0441 234443</phone> <email>[email protected]</email> <addresses> <address> <street>1 Some Street</street> <town>Toy Town</town> <country>UK</country> </address> ...

Do you know an XML binding toolkit that is able to process XSD using keyref?

Given an XML schema (XSD) and arbitrarily many sample files (XML) based on that schema, I need to create an XML parser/binder to load those files. The parser must be available from within a C++ program. All open source or commercial tools I looked at do not support keyrefs, which are heavily used in the XSD at hand. Do you know any too...

How to select the value of the xsi:type attribute in SQL Server?

Considering this xml document: DECLARE @X XML (DOCUMENT search.SearchParameters) = '<parameters xmlns="http://www.educations.com/Search/Parameters.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; <parameter xsi:type="category" categoryID="38" /> </parameters>'; I'd like to access the value of the attribute "type". Ac...

Problem designing xsd schema - because of a variable element name

Hi everyone, i'm not the best at creating XSD schema as this is actually my first one, i would like to validate an xml that must look like this : <?xml version="1.0"?> <Data> <FIELD name='toto'> <META mono='false' dynamic='false'> <COLUMN1> <REFTABLE>table</REFTABLE> <REFCOLUMN>key_column</REFCOLUMN> ...

XML validation error when using multiple schema files/namespaces

Hi, I've been reading a ton about xml and learning a lot but I am stuck on one error. I have a schema defined in multiple files and I can't get it to work. Here is an example ================================== libraryBooks.xsd <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns...

JAXB - Beans to XSD or XSD to beans?

I have an existing data model. I would like to express this data model in terms of XML. It looks like I have two options if I'm to use JAXB: Create an XSD that mirrors my data model, and use xjc to create binding objects. Marshalling and unmarshalling will involve creating a "mapping" class that would take my existing data objects a...

can the length of two xml lists be defined as being required to be equal?

Assuming you have two lists defined in an xml schema, call them A and B, is there a way to say A must be one or more items and B must be the same length as A? ...

Create an XML file using Datasets Using info from XML Schema

Hello there, I have been thinking about the optimal way to create an XML file using data from a Dataset AND according to the rules of an XML schema. I've been searching around for a bit, and I failed to find a way in which I only take the data from the Dataset and put it inside a XML tags, with the tags being defined by an already-exist...

XSD schema for recursive XML

I'm having trouble creating an XSD for some xml. A bit of background might help. The xml is for messaging. In particular, the message is designed to be simple, and designed to be cross referenced easily. At its heart is a recursive key value set up. Simple Key values are like this. <key name="quantity">5</key> <key name="pric...

XML Schema for a .NET type that inherits and implements

Hi, Please consider the following three .NET types: I have an interface, an abstract class, and a concrete class. My question is how to write the XML Schema to include the properties from the interface and from the abstract class. public interface IStartable { bool RequiresKey { get; set; } void Start(object key); } public a...