xsd

How to extract leaf nodes and path of parent elements from an XSD

I'm trying to transform an XML Schema document and extract a list of all leaf element names and the path of their parent elements, i.e. the names of each element that ref's the current element, and the element that ref's that one, on up to only element that's not referred to by another ref attribute. I'm not getting anywhere, so I don't ...

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# ...

Java XML validation against XSD Schema

private void validateXML(DOMSource source) throws Exception { URL schemaFile = new URL("http://www.csc.liv.ac.uk/~valli/modules.xsd"); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.new...

Restricting empty elements in xsd

Is there a way to prevent empty elements of the form <myElement/> being used in your xml? In other words, can you specify in your xsd that <myElement/> is invalid? Using nillable="false" doesn't work, nor does minOccurs="1" - both of those allow <myElement/>. ...

xml invalid character in the given encoding

I am trying to validate my xml against it's xsd and getting the error invalid character in given encoding. The code I use to validate is below: private static void ValidatingProcess(string XSDPath, string xml) { MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xml)); using (StreamRea...

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...

AutoMapper and is*Specified properties

Hi, I have a bunch of XSD.exe-generated data contract classes which for all optional elements have a pair of C# properties like int Amount {get; set;} bool isAmountSpecified {get; set;} On the other side of mapping arena I have a nullable int like int? Amount {get; set;} Ideally I'd like for AutoMapper to be able to recognize such...

Creating an XSD schema

I have an xml tag: <ROW field1="value 1" field2="value 2" ... /> fieldi has a string value, and number of attributes fieldi is variable, but not less than 1. Is it possible to create an xsd schema for this tag? possible xml document <ROWDATA> <ROW field1="dfgdf" field2="ddfg"></ROW> <ROW field1="dfedf" field2="djkfg" field3="c...

Ignoring container elements through JAXB customization.

Hi all I am struggling with a simple JAXB customization issue. I have an schema like this. (its actually a snippet of Bing Maps Web Services schema) <xs:complexType name="GeocodeOptions"> <xs:sequence> <xs:element minOccurs="0" name="Count" nillable="true" type="xs:int" /> <xs:element minOccurs="0" name="Filters" nillable="tr...

xsd.exe to C# - any way to get an ArrayList instead of an Array?

This issue is somewhat related: http://stackoverflow.com/questions/1165999/problem-with-code-generated-by-xsd-exe-sequence-of-elements-is-generated-as-an-a Basically, I would rather work with an ArrayList in C# code then an array. I have a collection of errors, and I'm writing code to send back additional errors to the already existin...

Client no longer getting data from Web Service after introducing targetNamespace in XSD

Sorry if there is way too much info in this post – there’s a load of story before I get to the actual problem. I thought I‘d include everything that might be relevant as I don’t have much clue what is wrong. I had a working web service and client (both written with VS 2008 in C#) for passing product data to an e-commerce site. The XSD s...

how can I validate XML on firefox?

Firefox does not read an external DTD and it does not provide schema evaluation even when an external schema definition is included in the XML file. If I want to validate the XML against a DTD or an XSD at the Firefox browser directly or by using JavaScript, what should I do? ...

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...

JAVA: How to use the xerces SAXParser using multiple schemas with identical targetNamespaces

Hi all, I have a requirement to perform some validation on an incoming piece of XML using a group of schemas. All these schemas share the same targetNamespace but are separated into different .xsd files. My java program is loading each xsd file into an InputSource[] array and passing them into the SAX Parser (SCHEMA_SOURCE property). ...

Nice wrappers around XSD-generated C# classes

I have some class definitions which are somewhat subject to change and which are generated by a third-party tool (xsd, supplied with Visual Studio). For example, suppose it's something like this: public class THIRD_PARTY_Fruit { public string Name { get; set; } } public class THIRD_PARTY_Apple : THIRD_PARTY_Fruit { public int Calor...

Problem validating XSD with 'choice' and 'extension' elements

I will post two examples, one that validates and one that doesn't. I am interested in learning why the second one doesn't work since they are very similar. Example 1 (validates) xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root" type="BBB"/> <xsd:complexType name="AAA"> <xsd:choice ma...

Define keyref selector based on element type in XPath

Let's say I have an XML file that will look like this: <a> <b d="value1"/> <c d="value2"/> </a> In the XSD file that defines the structure of this XML file I defined the elements by name 'b' and 'c' to be of the same type (and the type requires attribute 'd'). Let's say that I want to make a keyReference of all elements of th...

xml validity with xsd with xsi:nillable element

My XML file <tns:SampleInfoResponse xsi:schemaLocation="sampleNS test.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="sampleNS"> <tns:SampleInfo> <tns:firstName>String</tns:firstName> <tns:lastName>String</tns:lastName> <tns:lbn>String</tns:lbn> <tns:LSampleDetails> <tns:SampleState>String</tns:Sam...

How to create XSD schema from XML with this kind of structure (in .net)?

Here's the problem: my input is XML file that looks something like: <BaseEntityClassInfo> <item> <key>BaseEntityClassInfo.SomeField</key> <value>valueData1</value> </item> <item> <key>BaseEntityClassInfo.AdditionalDataClass.SomeOtherField</key> <value>valueData2</value> </item> <item> <key>BaseEntityClassInfo.AdditionalDataCla...

Is there any easy way to merge multiple XSDs into a single one?

To be more specific, I have a few (quite big) XSDs that are follow some common structure, but generally quite different. I also have to make a single XSD for merged XML files that should combine their respective XSDs. Example: <Container> <File id="id1_that_use_xsd1" /> <File id="id2_that_use_xsd2" /> <File id="id3_that_use...