Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19825

Re: How to convert Map to xml based on Schema.

Newsgroups comp.lang.java.programmer
Date 2012-11-19 22:26 -0800
References <7e1a4b59-0c97-40ca-af6e-22277f62b469@googlegroups.com> <7ioqs.49297$c16.19500@newsfe10.iad>
Message-ID <d477c24f-6167-4704-854a-e4004acd374d@googlegroups.com> (permalink)
Subject Re: How to convert Map to xml based on Schema.
From Mausam <mausamhere@gmail.com>

Show all headers | View raw


On Monday, November 19, 2012 4:29:15 PM UTC+5:30, Arved Sandstrom wrote:
> On 11/17/2012 02:52 AM, Mausam wrote:
> 
> > 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
> 
> > <?xml version="1.0" encoding="windows-1252" ?>
> 
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 
> >    <xsd:element name="depts">
> 
> >      <xsd:complexType>
> 
> >        <xsd:sequence>
> 
> >          <xsd:element name="dept" maxOccurs="unbounded">
> 
> >            <xsd:complexType>
> 
> >              <xsd:sequence>
> 
> >                <xsd:element name="deptno" type="xsd:string"/><!-- This simple element e.g can be attribute in some schema-->
> 
> >                <xsd:element name="dname" type="xsd:string"/>
> 
> >                <xsd:element name="emps" maxOccurs="unbounded" minOccurs="0">
> 
> >                  <xsd:complexType>
> 
> >                    <xsd:sequence>
> 
> >                      <xsd:element name="empno" type="xsd:string"/>
> 
> >                      <xsd:element name="ename" type="xsd:string"/>
> 
> >                    </xsd:sequence>
> 
> >                  </xsd:complexType>
> 
> >                </xsd:element>
> 
> >              </xsd:sequence>
> 
> >            </xsd:complexType>
> 
> >          </xsd:element>
> 
> >        </xsd:sequence>
> 
> >      </xsd:complexType>
> 
> >    </xsd:element>
> 
> > </xsd:schema>
> 
> >
> 
> > -Many thanks
> 
> >
> 
> One question I have is, how and when is the generation supposed to occur?
> 
> 
> 
> IOW, what is the environment?
> 
> 
> 
> And where did the Map come from? If, as you replied to Arne, your schema 
> 
> can change, what process is responsible for creating new Maps that are 
> 
> relevant for updated schemas?

There is an upstream process that does that. 

 Such a map, after all, should be a Java 
> 
> analog of an XML instance for the target schema,

You are correct. The map is Java analog of an XML Instance of the target schema. And I don't need a schema at this point but for two reasons:

1) Map does not tell me if an single Entry is either an attribute in XML or Simple element.

2) Map does not tell me the order of siblings (e.g sequence)

 you don't need the 
> 
> schema at that point to generate a valid XML.
> 
> 
> 
> AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to convert Map to xml based on Schema. Mausam <mausamhere@gmail.com> - 2012-11-16 22:52 -0800
  Re: How to convert Map to xml based on Schema. Roedy Green <see_website@mindprod.com.invalid> - 2012-11-17 00:48 -0800
    Re: How to convert Map to xml based on Schema. Mausam <mausamhere@gmail.com> - 2012-11-17 20:14 -0800
      Re: How to convert Map to xml based on Schema. Roedy Green <see_website@mindprod.com.invalid> - 2012-11-18 07:02 -0800
  Re: How to convert Map to xml based on Schema. Arne Vajhøj <arne@vajhoej.dk> - 2012-11-18 16:15 -0500
    Re: How to convert Map to xml based on Schema. Arne Vajhøj <arne@vajhoej.dk> - 2012-11-18 21:42 -0500
      Re: How to convert Map to xml based on Schema. Mausam <mausamhere@gmail.com> - 2012-11-19 02:22 -0800
        Re: How to convert Map to xml based on Schema. Arne Vajhøj <arne@vajhoej.dk> - 2012-11-19 09:37 -0500
  Re: How to convert Map to xml based on Schema. Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-11-19 06:59 -0400
    Re: How to convert Map to xml based on Schema. Mausam <mausamhere@gmail.com> - 2012-11-19 22:26 -0800
  Re: How to convert Map to xml based on Schema. Stuart <DerTopper@web.de> - 2012-11-20 20:52 +0100

csiph-web