You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Stefan Offermann <of...@uni-muenster.de> on 2007/04/24 11:36:02 UTC
Saving a file without prefix
Hallo,
how can I remove the prefix when saving a xml-document?
My current output looks like this:
<xid:rss xmlns:xid="http://lehre.ifgi.de/xidisplays2">
<xid:channel>
<xid:title>iDisplays2 RSS Feed</xid:title>
<xid:link>http://www.idisplays.info</xid:link>
[...]
as you can see I am creating an rss-feed. My desired output would look
like this:
<rss xmlns="http://lehre.ifgi.de/xidisplays2">
<channel>
<title>iDisplays2 RSS Feed</title>
<link>http://www.idisplays.info</link>
[...]
Is this possible with xmlbeans? Do I have to change something in the
xml-schema or in the code (when saving the document)?
Best regards, Stefan Offermann
--
Stefan Offermann
Institut für Geoinformatik
Westfälische Wilhelms-Universität
Robert-Koch-Str. 26-28
D-48149 Münster
Fon: +49 (0)251 83-31961
Mail: offermann@uni-muenster.de
Web: http://www.ifgi.de
http://ifgi.uni-muenster.de/~offermann/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Saving a file without prefix
Posted by Jacob Danner <ja...@gmail.com>.
Hi Stefan,
I'm not seeing any issues with v2.1 or 2.0.
-Jacob Danner
On 4/24/07, Stefan Offermann <of...@uni-muenster.de> wrote:
> Jacob Danner schrieb:
> > Please let me know if you are still having troubles,
> > -Jacob Danner
>
> Hi Jakob,
>
> I just checked versionnumbers, I used xmlbeans 2.1.0, upgraded to 2.2.0
> and now it works fine for me :) thanks for your help and you pointer to
> XmlOptions and the two methods.
>
> Anyway, was it a known bug in 2.1.0?
>
> Best regards, Stefan Offermann
>
>
> --
> Stefan Offermann
> Institut für Geoinformatik
> Westfälische Wilhelms-Universität
> Robert-Koch-Str. 26-28
> D-48149 Münster
>
> Fon: +49 (0)251 83-31961
> Mail: offermann@uni-muenster.de
> Web: http://www.ifgi.de
> http://ifgi.uni-muenster.de/~offermann/
>
> ---------------------------------------------------------------------
> 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: Saving a file without prefix
Posted by Stefan Offermann <of...@uni-muenster.de>.
Jacob Danner schrieb:
> Please let me know if you are still having troubles,
> -Jacob Danner
Hi Jakob,
I just checked versionnumbers, I used xmlbeans 2.1.0, upgraded to 2.2.0
and now it works fine for me :) thanks for your help and you pointer to
XmlOptions and the two methods.
Anyway, was it a known bug in 2.1.0?
Best regards, Stefan Offermann
--
Stefan Offermann
Institut für Geoinformatik
Westfälische Wilhelms-Universität
Robert-Koch-Str. 26-28
D-48149 Münster
Fon: +49 (0)251 83-31961
Mail: offermann@uni-muenster.de
Web: http://www.ifgi.de
http://ifgi.uni-muenster.de/~offermann/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Saving a file without prefix
Posted by Jacob Danner <ja...@gmail.com>.
Hi Stefan,
I was able to get this to work using the following declaration:
XmlOptions xo = new XmlOptions().setSavePrettyPrint();
ArrayList errors = new ArrayList();
xo.setErrorListener(errors);
xo = xo.setSaveAggressiveNamespaces();
xo = xo.setUseDefaultNamespace();
Then:
System.out.println("\nEMS w/ XO: " + emsDemographicDataSet.xmlText(xo));
System.out.println("\nEMS w/out XO: " + emsDemographicDataSet.xmlText());
Produces:
EMS w/ XO: <D09 Status="A" Date="2007-04-24-07:00" xmlns="http://www.nemsis.org"
>
<D09_04>Stuff</D09_04>
</D09>
EMS w/out XO: <nem:D09 Status="A" Date="2007-04-24-07:00" xmlns:nem="http://www.
nemsis.org"><nem:D09_04>Stuff</nem:D09_04></nem:D09>
And in your case to save out the file, this worked for me:
emsDemographicDataSet.save(new File("EMSOUT.xml"), xo);
to create a file like that produced by the output of EMS w/ XO
Please let me know if you are still having troubles,
-Jacob Danner
On 4/24/07, Stefan Offermann <of...@uni-muenster.de> wrote:
> Jacob Danner schrieb:
> > XmlOptions setUseDefaultNamespace()
> > If this option is set, the saver will try to use the default
> > namespace for the most commonly used URI.
> >
> > XmlOptions setSaveAggressiveNamespaces()
> > Causes the saver to reduce the number of namespace prefix
> > declarations.
>
> I gave both a try, but none of them worked for me :(
>
> Here is the code how I save the file:
>
> ---------------------
>
> XmlOptions opts = new XmlOptions();
> opts.setUseDefaultNamespace();
> opts.setSaveAggressiveNamespaces();
> RssDocument rssDocument = RssDocument.Factory.newInstance(opts);
>
> /* adding the content ... */
>
> rssDocument.save(new File(filename)); // exceptionhandling removed
>
> ---------------------
>
> I also tried setSaveSuggestedPrefixes, but this method doesn't work, I
> also would like to say that the whole XmlOptions-Object doesn't work in
> my case, it changes nothing :(
>
> Best regards, Stefan Offermann
>
>
> --
> Stefan Offermann
> Institut für Geoinformatik
> Westfälische Wilhelms-Universität
> Robert-Koch-Str. 26-28
> D-48149 Münster
>
> Fon: +49 (0)251 83-31961
> Mail: offermann@uni-muenster.de
> Web: http://www.ifgi.de
> http://ifgi.uni-muenster.de/~offermann/
>
> ---------------------------------------------------------------------
> 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: Saving a file without prefix
Posted by Stefan Offermann <of...@uni-muenster.de>.
Jacob Danner schrieb:
> XmlOptions setUseDefaultNamespace()
> If this option is set, the saver will try to use the default
> namespace for the most commonly used URI.
>
> XmlOptions setSaveAggressiveNamespaces()
> Causes the saver to reduce the number of namespace prefix
> declarations.
I gave both a try, but none of them worked for me :(
Here is the code how I save the file:
---------------------
XmlOptions opts = new XmlOptions();
opts.setUseDefaultNamespace();
opts.setSaveAggressiveNamespaces();
RssDocument rssDocument = RssDocument.Factory.newInstance(opts);
/* adding the content ... */
rssDocument.save(new File(filename)); // exceptionhandling removed
---------------------
I also tried setSaveSuggestedPrefixes, but this method doesn't work, I
also would like to say that the whole XmlOptions-Object doesn't work in
my case, it changes nothing :(
Best regards, Stefan Offermann
--
Stefan Offermann
Institut für Geoinformatik
Westfälische Wilhelms-Universität
Robert-Koch-Str. 26-28
D-48149 Münster
Fon: +49 (0)251 83-31961
Mail: offermann@uni-muenster.de
Web: http://www.ifgi.de
http://ifgi.uni-muenster.de/~offermann/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Saving a file without prefix
Posted by Jacob Danner <ja...@gmail.com>.
Hi Stefan,
Have you tried using the
XmlOptions API to set this. I believe the following methods are relevant.
XmlOptions setUseDefaultNamespace()
If this option is set, the saver will try to use the default
namespace for the most commonly used URI.
XmlOptions setSaveAggressiveNamespaces()
Causes the saver to reduce the number of namespace prefix
declarations.
Hope this helps,
-Jacob Danner
On 4/24/07, Stefan Offermann <of...@uni-muenster.de> wrote:
> Hallo,
>
> how can I remove the prefix when saving a xml-document?
>
> My current output looks like this:
>
> <xid:rss xmlns:xid="http://lehre.ifgi.de/xidisplays2">
> <xid:channel>
> <xid:title>iDisplays2 RSS Feed</xid:title>
> <xid:link>http://www.idisplays.info</xid:link>
> [...]
>
> as you can see I am creating an rss-feed. My desired output would look
> like this:
>
> <rss xmlns="http://lehre.ifgi.de/xidisplays2">
> <channel>
> <title>iDisplays2 RSS Feed</title>
> <link>http://www.idisplays.info</link>
> [...]
>
> Is this possible with xmlbeans? Do I have to change something in the
> xml-schema or in the code (when saving the document)?
>
> Best regards, Stefan Offermann
>
>
> --
> Stefan Offermann
> Institut für Geoinformatik
> Westfälische Wilhelms-Universität
> Robert-Koch-Str. 26-28
> D-48149 Münster
>
> Fon: +49 (0)251 83-31961
> Mail: offermann@uni-muenster.de
> Web: http://www.ifgi.de
> http://ifgi.uni-muenster.de/~offermann/
>
> ---------------------------------------------------------------------
> 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