Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Stuart Newsgroups: comp.lang.java.programmer Subject: Re: How to convert Map to xml based on Schema. Date: Tue, 20 Nov 2012 20:52:16 +0100 Organization: A noiseless patient Spider Lines: 49 Message-ID: References: <7e1a4b59-0c97-40ca-af6e-22277f62b469@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 20 Nov 2012 19:52:17 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="21aac22f8896a48c2c25e23bfecada7e"; logging-data="15037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+h8MbWWGtPgX8ciOVQQSLJ37T1zPKH1Ls=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: <7e1a4b59-0c97-40ca-af6e-22277f62b469@googlegroups.com> Cancel-Lock: sha1:gw2OHP61BQuutvtGZI16esfzuBQ= Xref: csiph.com comp.lang.java.programmer:19829 Am 11/17/12 7:52 AM, schrieb Mausam: > Hello, > > I have a Map (it can be nested map, containing of maps) and a schema. Keys in Map represent element/attribute name of the schema and an entry in Map will be at same depth as an element defined in schema > > I need help in generating xml from the map as per the schema provided, without generating new files (as e.g Jaxb would require) Sample schema/map provided below > > e.g Map = [dept=[deptno="10",dname="ABC",loc="XYZ",emps=[[empno=1000,ename="Albert"],[empno=2000,ename="John"]]]] and schema will be > > e.g Schema > > > > > > > > > > > > > > > > > > > > > > > > > > > -Many thanks > Try this: http://codeviewer.org/view/code:2c08 (sorry, but code posted on usenet looks really ugly). Note that this code can only handle a schema that looks like the one you have provided (no support for xsd:choice, schema must be in Russian Doll format, no proper quoting of special characters like <>" which are not allowed in XML string). Regards, Stuart