Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Schema for simple XML-based scripting language

From: "Chris Lieb" <chris.lieb@-----.--->
To: NULL
Date: 6/2/2006 9:01:00 AM

J Hendrich wrote:
> "Chris Lieb" wrote:
>
> > I am new to XML Schema and am running into a bit of a snag.  I have
> > defined an XML-based scripting language for an updater program that I
> > am working on.  I would like to make a schema for this language since
> > malformed XML documents break the updater.  (I did not have time to add
> > good error-handling code, so run-time errors can abound if the document
> > is malformed.)
> >
> > A sample doc might look something like this:
> >
> > <manifest>
> >   <version major="1" minor="0" revision="1" base="1.0.1\files\"
> > doprevious="true">
> >     <file action="copy" name="text.doc"/>
> >     <folder action="create" name="temp"/>
> >     <updater>
> >       <file name="update.exe"/>
> >       <file name="updaterlib.dll"/>
> >     </updater>
> >   </version>
> >   <version major="1" minor="0" revision="0" base="1.0.0\files\"
> > doprevious="false">
> >     <dll action="register" name="updaterlib.dll"/>
> >     <cmd location="server" command="patch.bat">
> >       <file name="patch.dat"/>
> >       <file name="patch.bat"/>
> >     </cmd>
> >   </version>
> > </manifest>
> >
> > Problem is that the second version element in the document, the updater
> > element, the dll element, and the cmd element all get flagged as
> > invalid.  I guess that this stems from using a sequence in the complex
> > type.  What should I use to allow all children elements of version
> > (file, folder, dll, msi, cmd, updater) to appear in any order and in
> > whatever quantity (except updater, which can only appear once)?
> >
> > 'all' looks like it comes close since it allows you to use elements in
> > any order, except my reading tells me that it only allows each element
> > to be used once and forces you to use all elements.  'choice' also
> > appears to come close since it allows you to choose which element you
> > want, but it only lets you choose one element from the set.
> >
>
> Are you certain you need to allow for all possible combinations of all
> elements in any order...if you can whittle down the possible combinations to
> only those combinations that should be allowed to occur you can use
> xs:sequence embedded inside of xs:choice, like:
>
>       <xs:choice>
>         <xs:sequence>
>           <xs:element ref="dll"/>
>           <xs:element ref="cmd"/>
>         </xs:sequence>
>         <xs:sequence>
>           <xs:element ref="file"/>
>           <xs:element ref="folder"/>
>           <xs:element ref="updater"/>
>         </xs:sequence>
>       </xs:choice>
>
> If indeed all possible combinations are possible, then the above is not a
> very attractive solution.
>
> > Also, one last thing: How do you set the max occurrence of an element
> > to be infinite?
> >
>
> maxOccurs="unbounded"
>
>
> > PS
> > I'm not posting the XSD right now.  If you want it, I would be more
> > than happy to provide it.  I am a little embarassed that I am designing
> > the XSD in Visual Studio 2005 instead of hand-coding it.  I have no
> > idea if the XSD generated by VS2005 is considered to be of good
> > quality.
> >
>
> I've used a few different xsd generators...I'd suggest getting familiar
> enough with XML Schema to know whether or not you like what it is generating.
>  Each generator makes its own assumptions about certain things, and you won't
> always like what it assumes.  I have only tried the XSD in VS 2003, and I
> don't know if it applies to the one in 2005, but the 2003 version cannot
> generate schemas for a broad class of XML files (whereas other generators
> don't have a problem).  I found that to be an annoying limitation and have
> stayed away since.

I would like to allow items in any order in any quantity.  I feel that
it might restrict thing in the future if I force you to always define
folders before files and so forth.  The only restriction that I want to
place on the order is to force the <updater> node (max of 1, min of 0)
to always be the last item for a version.

I guess that I might not actually need a schema for the manifest files
since I am making a GUI to allow others to easily edit the manifest
file without needing to know all of the rules that I have or even XML.
Even if they did know XML, I am not currently validating it in the
updater using XML Schema, but rather by manually checking values.

I could make a change to the updater to force validation against a
schema, but I don't know if MSXML4 supports this, or how to access it
through VB6.  Any ideas?

Do you think that a schema would actually be useful in this case?

Chris



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent