XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Royce FicklingSubject: "Free format" schema
Author: Royce Fickling
Date: 07 Nov 2005 07:03 PM
I have a XML schema in which I have defined three main data nodes, TimeDomain, Spectrum, & Tachometer. They will be children of the Machine node. These may occur in any order, number, and combination without regard as to the existence of the others. I generate my schema from an existing, known good XML file. When I use this schema to validate another known good XML file which has a different combination of these data nodes, the SS validator considers the second file invalid. My three main data elements may occur in any order and in any combination. There is no specific order or number of the three element types. How can I correctly define this schema? My attached SAMPLE.XML was used to generate my DataImport.xsd. My attached file GBSCIATD.XML file is valid, i.e., satisfies my requirements, but is considered invalid by StylusStudio. Please explain.


UnknownSample.zip
Two XML files & an XSD file

Postnext
(Deleted User) Subject: No Topic
Author: (Deleted User)
Date: 08 Nov 2005 09:59 AM
Royce,
I can suggest 2 solutions to your problem. I recommend solution number 1. Read on.

The fundamental problem is that given a single .xml file, there are many possible .xsd files which MIGHT match your intent. In your case, you might have wanted the 3 elements in a specific order, or in any order, or any number of variations of order and repetition.

FIRST SOLUTION:
The Stylus Studio xsd generator saw the 3 elements in your sample .xml file, and generated a .xsd which requires them to appear in the same order. The critical piece in your .xsd is:
<xs:sequence>
<xs:element ref="TimeDomain"/>
<xs:element maxOccurs="unbounded" ref="Spectrum"/>
<xs:element ref="Tachometer"/>
</xs:sequence>

Modify it as follows:
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
<xs:element ref="TimeDomain"/>
<xs:element ref="Spectrum"/>
<xs:element ref="Tachometer"/>
</xs:choice>
</xs:sequence>

This will permit any number of the 3 elements, in any order.

SECOND SOLUTION:
StylusStudio bundles a 3rd-party tool "Trang" which can read several .xml files at once, and generate a schema which works with all the .xml files. You could run this:
java -jar C:\program files\stylus studio...\bin\trang\trang.jar Sample.xml GBSCIATD.xml output.xsd
That will look at both of the .xml files and generate an .xsd which works with both of them. If you do this, and look at the output.xsd, you will see that it still doesn't satisfy your intent. You will need to provide a larger set of sample .xml files to get the desired result.
For more information on Trang, see http://www.thaiopensource.com/relaxng/trang.html

Posttop
Royce FicklingSubject: No Topic
Author: Royce Fickling
Date: 08 Nov 2005 10:20 AM
Thanks, Clyde. The #1 solution works find & helps me tremendously.

Royce

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.