You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Roman Kashitsyn <ro...@gmail.com> on 2011/05/10 17:46:56 UTC

How to add standalone attribute

How can I add standalone="yes" attribute to "xml" processing instruction when
saving xmlbean? Suppose I had an xmlbean and I want to save it in the
following way:


XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setSaveOuter();
xmlOptions.setSaveSyntheticDocumentElement(new QName(NAMESPACE_URI,
TAG_NAME, PREFIX));

/* some magic happens here */

bean.save(anOutputStream, xmlOptions)


Now I get the following result:

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- perfectly well xml file --&gt;


How can I get the following result:

&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;!-- perfectly well xml file --&gt;

???
-- 
View this message in context: http://old.nabble.com/How-to-add-standalone-attribute-tp31586761p31586761.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.

Re: How to add standalone attribute

Posted by Kevin Krouse <kk...@apache.org>.
Here is a rough patch.  I haven't tested it extensively.  There is a bug in
loading a document the standalone decl as can be seen in the output from
running test.java:


Original xml:
<hello/>

Default:
<?xml version="1.0" encoding="UTF-8"?>
<hello/>

set standalone=true:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hello/>

set standalone=false:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hello/>

remove standalone
<?xml version="1.0" encoding="UTF-8"?>
<hello/>


Original xml:
<?xml version='1.0' standalone='yes'?>
<hello/>

Default:
<?xml version="1.0" encoding="UTF-8"?>
<hello/>

set standalone=true:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hello/>

set standalone=false:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hello/>

remove standalone
<?xml version="1.0" encoding="UTF-8"?>
<hello/>




On Thu, May 12, 2011 at 5:12 AM, pgillen <pa...@gmail.com> wrote:

> I tried that without effect. Be interested to hear others experience.
> -paul-
>
> ---------
> Paul Gillen
> ------------------------------
> *From: * Jacob Danner <ja...@gmail.com>
> *Date: *Wed, 11 May 2011 18:24:34 -0700
> *To: *<us...@xmlbeans.apache.org>
> *ReplyTo: * user@xmlbeans.apache.org
> *Subject: *Re: How to add standalone attribute
>
> Take a look at XmlDocumentProperties.setstandalone(...)
> -jacobd
> On May 10, 2011 11:47 AM, "Roman Kashitsyn" <ro...@gmail.com>
> wrote:
> >
> > How can I add standalone="yes" attribute to "xml" processing instruction
> when
> > saving xmlbean? Suppose I had an xmlbean and I want to save it in the
> > following way:
> >
> >
> > XmlOptions xmlOptions = new XmlOptions();
> > xmlOptions.setSaveOuter();
> > xmlOptions.setSaveSyntheticDocumentElement(new QName(NAMESPACE_URI,
> > TAG_NAME, PREFIX));
> >
> > /* some magic happens here */
> >
> > bean.save(anOutputStream, xmlOptions)
> >
> >
> > Now I get the following result:
> >
> > &lt;?xml version="1.0" encoding="utf-8"?&gt;
> > &lt;!-- perfectly well xml file --&gt;
> >
> >
> > How can I get the following result:
> >
> > &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
> > &lt;!-- perfectly well xml file --&gt;
> >
> > ???
> > --
> > View this message in context:
> http://old.nabble.com/How-to-add-standalone-attribute-tp31586761p31586761.html
> > Sent from the Xml Beans - User mailing list archive at Nabble.com.
>

Re: How to add standalone attribute

Posted by pgillen <pa...@gmail.com>.
I tried that without effect. Be interested to hear others experience. -paul-
---------
Paul Gillen

-----Original Message-----
From: Jacob Danner <ja...@gmail.com>
Date: Wed, 11 May 2011 18:24:34 
To: <us...@xmlbeans.apache.org>
Reply-To: user@xmlbeans.apache.org
Subject: Re: How to add standalone attribute

Take a look at XmlDocumentProperties.setstandalone(...)
-jacobd
On May 10, 2011 11:47 AM, "Roman Kashitsyn" <ro...@gmail.com> wrote:
>
> How can I add standalone="yes" attribute to "xml" processing instruction
when
> saving xmlbean? Suppose I had an xmlbean and I want to save it in the
> following way:
>
>
> XmlOptions xmlOptions = new XmlOptions();
> xmlOptions.setSaveOuter();
> xmlOptions.setSaveSyntheticDocumentElement(new QName(NAMESPACE_URI,
> TAG_NAME, PREFIX));
>
> /* some magic happens here */
>
> bean.save(anOutputStream, xmlOptions)
>
>
> Now I get the following result:
>
> &lt;?xml version="1.0" encoding="utf-8"?&gt;
> &lt;!-- perfectly well xml file --&gt;
>
>
> How can I get the following result:
>
> &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
> &lt;!-- perfectly well xml file --&gt;
>
> ???
> --
> View this message in context:
http://old.nabble.com/How-to-add-standalone-attribute-tp31586761p31586761.html
> Sent from the Xml Beans - User mailing list archive at Nabble.com.


Re: How to add standalone attribute

Posted by Jacob Danner <ja...@gmail.com>.
Take a look at XmlDocumentProperties.setstandalone(...)
-jacobd
On May 10, 2011 11:47 AM, "Roman Kashitsyn" <ro...@gmail.com> wrote:
>
> How can I add standalone="yes" attribute to "xml" processing instruction
when
> saving xmlbean? Suppose I had an xmlbean and I want to save it in the
> following way:
>
>
> XmlOptions xmlOptions = new XmlOptions();
> xmlOptions.setSaveOuter();
> xmlOptions.setSaveSyntheticDocumentElement(new QName(NAMESPACE_URI,
> TAG_NAME, PREFIX));
>
> /* some magic happens here */
>
> bean.save(anOutputStream, xmlOptions)
>
>
> Now I get the following result:
>
> &lt;?xml version="1.0" encoding="utf-8"?&gt;
> &lt;!-- perfectly well xml file --&gt;
>
>
> How can I get the following result:
>
> &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
> &lt;!-- perfectly well xml file --&gt;
>
> ???
> --
> View this message in context:
http://old.nabble.com/How-to-add-standalone-attribute-tp31586761p31586761.html
> Sent from the Xml Beans - User mailing list archive at Nabble.com.