xml-schema

Comparing two XML Schemas

Are there any tools to effectively compare two XML schema's? I have seen some generic XML diff tools, but I was wondering if there is anything that knows more about schemas. ...

XML attribute vs XML element

At work we are being asked to create XML files to pass data to another offline application that will then create a second XML file to pass back in order to update some of our data. During the process we have been discussing with the team of the other application about the structure of the XML file. The sample I came up with is essentia...

Is it possible in W3C's XML Schema language (XSD) to allow a series of elements to be in any order but still limit occurrences?

I know about all and choice, but they don't account for a case where I do want some elements to be able to occur more than once, such as: <Root> <ThingA/> <ThingB/> <ThingC/> <ThingC/> <ThingC/> </Root> I could use sequence, but I'd prefer to allow these children to be in any order. I could use any, but then I coul...

What XML do I send for a field thats declared as nillable?

I have an application with a REST style inerface that takes XML documents via POST from clients. This application is written in Java and uses XML beans to process the posted message. Now, the XML schema definition for a field in the message looks like this: <xs:element name="value" type="xs:string" nillable="true" / > How do I send a...

Validate an incoming SOAP request to the WSDL in PHP

The built-in PHP extension for SOAP doesn't validate everything in the incoming SOAP request against the XML Schema in the WSDL. It does check for the existence of basic entities, but when you have something complicated like simpleType restrictions the extension pretty much ignores their existence. What is the best way to validate the S...

Can you use key/keyref instead of restriction/enumeration in XML schema?

Suppose we have a stylesheet which pulls in metadata using the key() function. In other words we have instance documents like this: <items> <item type="some_type"/> <item type="another_type"/> </items> and a table of additional data we would like to associate with items during processing: <item-meta> <item type="some_type" meta=...

Is there a difference between 'valid xml' and 'well formed xml'?

I wasnt aware of a difference, but a coworker says there is, although he can't back it up. What's the difference if any? ...

What are the advantages and disadvantages of using XML schemas?

We are utilizing the XML data type in Microsoft SQL Server 2005 for a project. Some members of the team and I feel that we should also use XSDs while members of the other camp feel that we should keep the XMLs ad hoc and not treat them as "types". The XMLs are an effort to bring structure and centrality to a number of text configuration...

Recursion in XSD Schemas

I need to create an XSD schema that validates a tree structure of an XML document. I don't know exactly the ocurrences or depth level of the tree. XML example: <?xml version="1.0" encoding="utf-8"?> <node> <attribute/> <node> <attribute/> <node> </node> </node> </node> Which is the best way to validate...

What do you use for validation against XML schema?

When I want to validate my XML docuemnts against a schema in my server-side Java, I use the built-in JRE Xerces implementation and javax.xml.validation.Schema. It works fine, but when validation fails, Xerces gives error messages that are very close to useless, for example: cvc-minLength-valid: Value '' with length = '0' is not facet-v...

Validating and reparing xml

Is there a way to get more useful information on validation error? XmlSchemaException provides the line number and position of the error which makes little sense to me. Xml document after all is not about its transient textual representation. I'd like to get an enumerated error (or an error code) specifying what when wrong, node name (or...

How to define multiple elements in XML Schema with the same name and different attribute value allowed?

I would like to create XML Schema for this chunk of xml, I would like to restrict the values of "name" attribute, so that in output document on and only one instance of day is allowed for each week day: <a> <day name="monday" /> <day name="tuesday" /> <day name="wednesday" /> </a> I have tried to use this: <xs:complexType name...

Refactoring XSD Schemas

I'm working in a project which needs to clean up some third party XSD Schemas and I want to do some refactoring of common elements in them. There is any suitable tool to automate this? I tried by sfactor from XMLBeans but it doesn't work (it throws a weird exception which even Google can't answer!). ...

How can you validate Elements based on an attribute Value using a Schema?

The XML I'm trying to validate is as follows: <root> <element attribute="foo"> <bar/> </element> <element attribute="hello"> <world/> </element> </root> How can this be validated using a Schema? Note: element can only contain bar when attribute="foo". element can only contain world when attribute="he...

How to set "xml:lang" attribute?

Hi, I need to add a "xml:lang" attribute on the root xml node in the outbound doument from Biztalk. This is a fixed value, so it may be set in the schema or something. This is what I want to get out: <Catalog xml:lang="NB-NO"> ... </Catalog> I've tried to define the attribute "xml:lang", but it doesn't allow me to use ":" in the sch...

XML schema for elements with same name but different sub-structure depending on context

I try to define a schema for XML documents I receive. The documents look like: <root> <items> <group name="G-1"> <item name="I-1"/> <item name="I-2"/> <item name="I-3"/> <item name="I-4"/> </group> </items> <data> <group name="G-1" place="here"> ...

How do I create a reusable "US State" type in an XML schema?

I have an XML schema that includes multiple addresses: <xs:element name="personal_address" maxOccurs="1"> <!-- address fields go here --> </xs:element> <xs:element name="business_address" maxOccurs="1"> <!-- address fields go here --> </xs:element> Within each address element, I include a "US State" enumeration: <xs:simpleType na...

What are best practices for designing XML schemas?

As an amateur software developer (I'm still in academia) I've written a few schemas for XML documents. I routinely run into design flubs that cause ugly-looking XML documents because I'm not entirely certain what the semantics of XML exactly are. My assumptions: <property> value </property> property = value <property attribute="attv...

Guidelines for formatting XML Namespace

I have not developed web services applications that publicly faced the Internet. As I begin to consider the issues of exposing schema definitions to a wide audience, I believe a certain amount of consideration should be spent on properly formatting the schema namespaces. Has anybody come across a guideline document that advises how to g...

How to get my Web Service response XML to validate in Liquid XML Studio?

Hello. A simple question on how to get the response from a Web Service that can be validated using Liquid XML Studio. Web Service code (ASP.NET 2.0): [WebMethod] [return: XmlElement("TestMe")] public string TestMe(int value) { return value.ToString(); } The will result in this response: <?xml version="1.0" encoding="utf-8"?> <soa...