Hi, > -----Original Message----- > From: Milan Andric [mailto:[EMAIL PROTECTED] > > Kasimier, > > Many thanks for the reply - this is info I've been looking for. > I'm a beginner in X Schema, trying to find a way to describe > a function > parameters in a way that would be satisfying for both Win/Linux. > > Suppose there is a function foo(int i, char *j) > > And call to function is like: > > Foo(1, "hello") > > I've thought of something like: > > <Function Name=foo> > <Param ### cross platform type info comes here ###>1</Param> > <Param Type="string">hello</Param> > </Function > > > I'm trying to find a way to describe all my function params > in a way that > is cross portable, and that would be understood by XML parsers on both > Windows and Linux. > > Then, when above XML is programmatically (via DOM) parsed by > XML parser, > it needs to be able to figure out actual param type, such > that first param > is of type int, and assign such to int variable in program, that the > second param is of type string and make assigment to a > variable in code, > etc. > > So far I've been able to acomplish above with MSXML, but, as > you've noted, > these are proprietary MS XML data types, and they wouldn't > work for cross > platform purposes. > > I'm wondering if there is a way to describe above params in such way - > what do you think?
[...] The xsi:type attribute is intended for such purposes (e.g. used heavily by SOAP). A schema could look like: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:test:milan" xmlns:m="urn:test:milan"> <xs:simpleType name="myIntType"> <xs:restriction base="xs:int"> <xs:maxInclusive value="10"/> </xs:restriction> </xs:simpleType> <xs:element name="param" type="xs:anySimpleType"/> <xs:element name="function"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="m:param"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> And the corresponding instance: <?xml version="1.0"?> <m:function xmlns:m="urn:test:milan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:test:milan milan-functions.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <m:param xsi:type="xs:string">value-1</m:param> <m:param xsi:type="m:myIntType">10</m:param> </m:function> I recommend using the following mailing lists for general W3C XML Schema questions (i.e., non Libxml2 related): [EMAIL PROTECTED] or [EMAIL PROTECTED] ... or reading some tutorials: http://www.w3schools.com/schema/default.asp ... or reading book about W3C XML Schema. Regards, Kasimier _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
