|
List Info
Thread: RE: Schema 2 Instance Generation
|
|
| RE: Schema 2 Instance Generation |

|
2007-06-26 01:26:11 |
Hi Guys,
Still I have problem.Let me just clarify if I understood you
guys correctly.
Assume I have the following XML :
<cust:city xmlns:cust="http://customer">
a>
"<cust:name>anyType</cust:name>
"<cust:population>anyType</cust:population>
;
</cust:city>
Now what I want is I wan't to provide my own prefix ( mycust
in place of cust).So the result xml I am looking for is :
<mycust:city xmlns:mycust="http://customer">
a>
"<mycust:name>anyType</mycust:name>
"<mycust:population>anyType</mycust:populatio
n>
</mycust:city>
I used the following code for the same.I could not get the
expected output.i got the same xml without any change.
private static void m1()
{
String xml = "<cust:city xmlns:cust="http://customer">"
+
"<cust:name>anyType</cust:name>"
+
"<cust:population>anyType</cust:populati
on>" +
"</cust:city>";
try
{
XmlOptions opts = new XmlOptions();
opts.setUseDefaultNamespace();
opts.setSavePrettyPrint();
Map ns = new Hashtable();
ns.put("http://customer",
"mycust");
opts.setSaveSuggestedPrefixes(ns);
XmlObject xobj = XmlObject.Factory.parse(xml);
System.out.println(xobj.xmlText(opts));
}
catch (Exception e) {
e.printStackTrace();
}
}
Regards,
Siddhath
-----Original Message-----
From: Jacob Danner [mailto:jacob.danner gmail.com]
Sent: Monday, June 25, 2007 10:22 PM
To: user xmlbeans.apache.org
Subject: Re: Schema 2 Instance Generation
Hi Siddharth,
It looks like you want the
SampleXmlUtil.createSampleForTypes() method
to allow you to specify a prefix. Unfortunately for you this
is a not
a feature of the class, however there are other options you
can use to
specify the prefix.
String genDoc = SampleXmlUtil.createSampleForType(target)
XmlOptions opts = new XmlOptions();
opts.setUseDefaultNamespace();
opts.setSavePrettyPrint();
Map ns = new Hashtable();
// YOUR NAMESPACE AND PREFIX
ns.put("Namespace", "prefix");
opts.setSaveSuggestedPrefixes(ns);
...
System.out.println(target);
System.out.println("n n Result : " +
genDoc.xmlText(opts));
Hope this helps,
-Jacobd
On 6/25/07, alioum web.de <alioum web.de> wrote:
>
>
> Hi Siddharth,
>
> I looked at your programm, but I couldn't find the
problem.
> Unfortunately I have no experience with XML schemas
passed
> as Strings and with the programmatic compilation af
XSD.
> Therefore, try to put your schema in a file first
(.xsd) and write a minimum
> code to make it work. When it works you can try to
migrate step by
> step to your solution and you'll find out where the
problem comes from.
>
> Good luck,
>
> Alioum
>
>
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: user xmlbeans.apache.org
> > Gesendet: 25.06.07 14:58:00
> > An: <alioum web.de>
> > CC: "Adisesha Rao R" <radisesha cordys.com>
> > Betreff: RE: Schema 2 Instance Generation
>
>
> >
> > HI ,
> > Thanks a lot for u'r quick reply.Unfortunately the
suggestion did not work for me.May be I am missing
something.Can u provide some more information on this please
?
> > I am attaching the test program that I used to
test.
> >
> >
> > Regards,
> > Siddharth
> >
> > -----Original Message-----
> > From: Boudigué Alioum [mailto:alioum web.de]
> > Sent: Monday, June 25, 2007 4:05 PM
> > To: user xmlbeans.apache.org
> > Subject: Re: Schema 2 Instance Generation
> >
> >
> >
> > Hi Siddhath,
> >
> > please try this:
> >
> > XmlOptions opts = new
XmlOptions();
> > opts.setUseDefaultNamespace();
> > opts.setSavePrettyPrint();
> >
> > Map ns = new Hashtable();
> >
ns.put("urn:iso:std:iso:20022:tech sd:SC
LSCTpacs.004.001.01", "sw4");
> >
ns.put("urn:iso:std:iso:20022:tech sd:SC
LSCTpacs.008.001.01", "sw8");
> >
> > opts.setSaveSuggestedPrefixes(ns);
> >
> > //standard output
> >
System.out.println(doc.xmlText(opts));
> >
> > // output to test.xml
> > doc.save(new
File("test.xml"),opts);
> >
> >
> > I had the same problem and I solved it that way.
> > hope it will help you
> > best regards,
> >
> > Alioum
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: user xmlbeans.apache.org
> > > Gesendet: 25.06.07 11:52:15
> > > An: <user xmlbeans.apache.org>
> > > CC: "Siddharth Ranjan Patnaik"
<spatnaik cordys.com>
> > > Betreff: Schema 2 Instance Generation
> >
> >
> > >
> > >
> > > HI
> > > All,
> > >
> > >
> > > I am
> > > using Schema to Instance generation
functionality of XMLBeans.While doing so ,
> > > the prefix used in the instance is decided by
the framework.(it picks the first
> > > 3 or 4 letters of the last token from the
URL).
> > >
> > >
> > > Example
> > > :
> > >
> > >
> > >
> > >
> > >
> > > "<schema
> > > xmlns="http://www.w3.org/20
01/XMLSchema"
> > > targetNamespace="http://mycomp/city">&
quot; +
> > >
> > >
> > >
> > > "<element
name="city">" +
> > >
> > >
> > >
> > > "<complexType>" +
> > >
> > >
> > > "<all>"
> > > +
> > >
> > >
> > >
> > > "<element
name="name"/>" +
> > >
> > >
> > >
> > > "<element
name="population"/>" +
> > >
> > >
> > > "</all>"
> > > +
> > >
> > >
> > >
> > > "</complexType>" +
> > >
> > >
> > >
> > > "</element>" +
> > >
> > >
> > > "</schema>
> > >
> > >
> > >
> > >
> > >
> > > The
> > > instance generated for this Schema is as
below :
> > >
> > >
> > >
> > >
> > >
> > > <city:city xmlns:city="http://mycomp/city"
>
> > >
> > >
> > > <name>anyType</name>
> > >
> > >
> > >
<population>anyType</population>
> > >
> > >
> > > </city:city>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > My question
> > > is "Is it possible to specify the
prefix while generating the
> > > instance from the schema" ? For example
as a user I want mycity to be
> > > used as the prefix iso city .
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Regards,
> > >
> > >
> > > Siddhath
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
************************************************************
***********
> > > The information in this message is
confidential and may be legally
> > > privileged. It is intended solely for the
addressee. Access to this
> > > message by anyone else is unauthorized. If
you are not the
> > > intended recipient, any disclosure, copying,
or distribution of the
> > > message, or any action or omission taken by
you in reliance on
> > > it is prohibited and may be unlawful. Please
immediately contact
> > >
> > >
> > > the sender if you have received this message
in error. This email
> > > does not constitute any commitment from
Cordys Holding BV or
> > > any of its subsidiaries except when expressly
agreed in a written
> > > agreement between the intended recipient and
> > > Cordys Holding BV or its subsidiaries.
> > >
************************************************************
***********
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
____________________________________________________________
_________
> > Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer
Onlinekosten zu sparen!
> > http://smartsurfer.web.de/?mc=100071&dis
tributionid=000000000066
> >
> >
> >
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> > For additional commands, e-mail: user-help xmlbeans.apache.org
> >
> >
> >
> > <hr>
> >
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> > For additional commands, e-mail: user-help xmlbeans.apache.org
> >
>
>
>
____________________________________________________________
______________
> Erweitern Sie FreeMail zu einem noch leistungsstärkeren
E-Mail-Postfach!
> Mehr Infos unter http://produkt
e.web.de/club/?mc=021131
>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> For additional commands, e-mail: user-help xmlbeans.apache.org
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
|
|
| RE: Schema 2 Instance Generation |

|
2007-06-27 03:26:22 |
Hi,
Can anyone please help me in this regard?
Its very very critical for my current project.
Thanks in advance.
Regards,
Siddharth
-----Original Message-----
From: Siddharth Ranjan Patnaik [mailto:spatnaik cordys.com]
Sent: Tuesday, June 26, 2007 11:56 AM
To: jacob.danner gmail.com; alioum web.de
Cc: user xmlbeans.apache.org
Subject: RE: Schema 2 Instance Generation
Hi Guys,
Still I have problem.Let me just clarify if I understood you
guys correctly.
Assume I have the following XML :
<cust:city xmlns:cust="http://customer">
a>
"<cust:name>anyType</cust:name>
"<cust:population>anyType</cust:population>
;
</cust:city>
Now what I want is I wan't to provide my own prefix ( mycust
in place of cust).So the result xml I am looking for is :
<mycust:city xmlns:mycust="http://customer">
a>
"<mycust:name>anyType</mycust:name>
"<mycust:population>anyType</mycust:populatio
n>
</mycust:city>
I used the following code for the same.I could not get the
expected output.i got the same xml without any change.
private static void m1()
{
String xml = "<cust:city xmlns:cust="http://customer">"
+
"<cust:name>anyType</cust:name>"
+
"<cust:population>anyType</cust:populati
on>" +
"</cust:city>";
try
{
XmlOptions opts = new XmlOptions();
opts.setUseDefaultNamespace();
opts.setSavePrettyPrint();
Map ns = new Hashtable();
ns.put("http://customer",
"mycust");
opts.setSaveSuggestedPrefixes(ns);
XmlObject xobj = XmlObject.Factory.parse(xml);
System.out.println(xobj.xmlText(opts));
}
catch (Exception e) {
e.printStackTrace();
}
}
Regards,
Siddhath
-----Original Message-----
From: Jacob Danner [mailto:jacob.danner gmail.com]
Sent: Monday, June 25, 2007 10:22 PM
To: user xmlbeans.apache.org
Subject: Re: Schema 2 Instance Generation
Hi Siddharth,
It looks like you want the
SampleXmlUtil.createSampleForTypes() method
to allow you to specify a prefix. Unfortunately for you this
is a not
a feature of the class, however there are other options you
can use to
specify the prefix.
String genDoc = SampleXmlUtil.createSampleForType(target)
XmlOptions opts = new XmlOptions();
opts.setUseDefaultNamespace();
opts.setSavePrettyPrint();
Map ns = new Hashtable();
// YOUR NAMESPACE AND PREFIX
ns.put("Namespace", "prefix");
opts.setSaveSuggestedPrefixes(ns);
...
System.out.println(target);
System.out.println("n n Result : " +
genDoc.xmlText(opts));
Hope this helps,
-Jacobd
On 6/25/07, alioum web.de <alioum web.de> wrote:
>
>
> Hi Siddharth,
>
> I looked at your programm, but I couldn't find the
problem.
> Unfortunately I have no experience with XML schemas
passed
> as Strings and with the programmatic compilation af
XSD.
> Therefore, try to put your schema in a file first
(.xsd) and write a minimum
> code to make it work. When it works you can try to
migrate step by
> step to your solution and you'll find out where the
problem comes from.
>
> Good luck,
>
> Alioum
>
>
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: user xmlbeans.apache.org
> > Gesendet: 25.06.07 14:58:00
> > An: <alioum web.de>
> > CC: "Adisesha Rao R" <radisesha cordys.com>
> > Betreff: RE: Schema 2 Instance Generation
>
>
> >
> > HI ,
> > Thanks a lot for u'r quick reply.Unfortunately the
suggestion did not work for me.May be I am missing
something.Can u provide some more information on this please
?
> > I am attaching the test program that I used to
test.
> >
> >
> > Regards,
> > Siddharth
> >
> > -----Original Message-----
> > From: Boudigué Alioum [mailto:alioum web.de]
> > Sent: Monday, June 25, 2007 4:05 PM
> > To: user xmlbeans.apache.org
> > Subject: Re: Schema 2 Instance Generation
> >
> >
> >
> > Hi Siddhath,
> >
> > please try this:
> >
> > XmlOptions opts = new
XmlOptions();
> > opts.setUseDefaultNamespace();
> > opts.setSavePrettyPrint();
> >
> > Map ns = new Hashtable();
> >
ns.put("urn:iso:std:iso:20022:tech sd:SC
LSCTpacs.004.001.01", "sw4");
> >
ns.put("urn:iso:std:iso:20022:tech sd:SC
LSCTpacs.008.001.01", "sw8");
> >
> > opts.setSaveSuggestedPrefixes(ns);
> >
> > //standard output
> >
System.out.println(doc.xmlText(opts));
> >
> > // output to test.xml
> > doc.save(new
File("test.xml"),opts);
> >
> >
> > I had the same problem and I solved it that way.
> > hope it will help you
> > best regards,
> >
> > Alioum
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: user xmlbeans.apache.org
> > > Gesendet: 25.06.07 11:52:15
> > > An: <user xmlbeans.apache.org>
> > > CC: "Siddharth Ranjan Patnaik"
<spatnaik cordys.com>
> > > Betreff: Schema 2 Instance Generation
> >
> >
> > >
> > >
> > > HI
> > > All,
> > >
> > >
> > > I am
> > > using Schema to Instance generation
functionality of XMLBeans.While doing so ,
> > > the prefix used in the instance is decided by
the framework.(it picks the first
> > > 3 or 4 letters of the last token from the
URL).
> > >
> > >
> > > Example
> > > :
> > >
> > >
> > >
> > >
> > >
> > > "<schema
> > > xmlns="http://www.w3.org/20
01/XMLSchema"
> > > targetNamespace="http://mycomp/city">&
quot; +
> > >
> > >
> > >
> > > "<element
name="city">" +
> > >
> > >
> > >
> > > "<complexType>" +
> > >
> > >
> > > "<all>"
> > > +
> > >
> > >
> > >
> > > "<element
name="name"/>" +
> > >
> > >
> > >
> > > "<element
name="population"/>" +
> > >
> > >
> > > "</all>"
> > > +
> > >
> > >
> > >
> > > "</complexType>" +
> > >
> > >
> > >
> > > "</element>" +
> > >
> > >
> > > "</schema>
> > >
> > >
> > >
> > >
> > >
> > > The
> > > instance generated for this Schema is as
below :
> > >
> > >
> > >
> > >
> > >
> > > <city:city xmlns:city="http://mycomp/city"
>
> > >
> > >
> > > <name>anyType</name>
> > >
> > >
> > >
<population>anyType</population>
> > >
> > >
> > > </city:city>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > My question
> > > is "Is it possible to specify the
prefix while generating the
> > > instance from the schema" ? For example
as a user I want mycity to be
> > > used as the prefix iso city .
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Regards,
> > >
> > >
> > > Siddhath
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
************************************************************
***********
> > > The information in this message is
confidential and may be legally
> > > privileged. It is intended solely for the
addressee. Access to this
> > > message by anyone else is unauthorized. If
you are not the
> > > intended recipient, any disclosure, copying,
or distribution of the
> > > message, or any action or omission taken by
you in reliance on
> > > it is prohibited and may be unlawful. Please
immediately contact
> > >
> > >
> > > the sender if you have received this message
in error. This email
> > > does not constitute any commitment from
Cordys Holding BV or
> > > any of its subsidiaries except when expressly
agreed in a written
> > > agreement between the intended recipient and
> > > Cordys Holding BV or its subsidiaries.
> > >
************************************************************
***********
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
____________________________________________________________
_________
> > Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer
Onlinekosten zu sparen!
> > http://smartsurfer.web.de/?mc=100071&dis
tributionid=000000000066
> >
> >
> >
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> > For additional commands, e-mail: user-help xmlbeans.apache.org
> >
> >
> >
> > <hr>
> >
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> > For additional commands, e-mail: user-help xmlbeans.apache.org
> >
>
>
>
____________________________________________________________
______________
> Erweitern Sie FreeMail zu einem noch leistungsstärkeren
E-Mail-Postfach!
> Mehr Infos unter http://produkt
e.web.de/club/?mc=021131
>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> For additional commands, e-mail: user-help xmlbeans.apache.org
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
|
|
[1-2]
|
|