You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by "Nacho G. Mac Dowell" <ig...@informa.es> on 2004/08/23 14:25:04 UTC

xmlDeclaration

Shouldn't xmlDeclaration from org.apache.ws.jaxme.impl.JMMarshallerImpl be
turned on by default? I think this should be true specially if the encoding
has been set. If this is the case...:

@@ -110,7 +110,7 @@
   private boolean indentation = true;
   private String indentationString = DEFAULT_JAXME_INDENTATION_STRING;
   private String indentationSeparator =
DEFAULT_JAXME_INDENTATION_SEPARATOR;
-  private boolean xmlDeclaration;
+  private boolean xmlDeclaration = true;
   private Class xmlWriterClass;
   /** <p>Sets the controllers encoding; to be used in
    * marshalling. Defaults to {@link #DEFAULT_JAXB_ENCODING}.</p>


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: xmlDeclaration

Posted by Jochen Wiedmann <jo...@freenet.de>.
Nacho G. Mac Dowell wrote:
> JAXBContext c;
> StringWriter sw = new StringWriter();
> c.createMarshaller().marshal(o, sw);
> 
> The first line of sw.toString() would be (in RI):
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Ok, I changed the default in HEAD. I'll leave it as it is in the 0.3 
branch, though.


Jochen


-- 
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


RE: xmlDeclaration

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
JAXBContext c;
StringWriter sw = new StringWriter();
c.createMarshaller().marshal(o, sw);

The first line of sw.toString() would be (in RI):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

RI uses com.sun.xml.bind.marshaller.XMLWriter for marshalling. It does have
a get/setXmlDecl but it is turned on by default (in its constructor).

Surprisingly enough, the Marshaller generated classes have a few
undocumented properties you can change (XMLDECLARATION for this purpose).
These are:

INDENT_STRING
PREFIX_MAPPER
ENCODING_HANDLER
XMLDECLARATION
XML_HEADERS



-----Mensaje original-----
De: Jochen Wiedmann [mailto:jochen.wiedmann@freenet.de]
Enviado el: miercoles, 25 de agosto de 2004 11:30
Para: Nacho G. Mac Dowell
CC: jaxme-dev@ws.apache.org
Asunto: Re: xmlDeclaration


Nacho G. Mac Dowell wrote:

> It doesn't specify anything about xml declaration. The thing is that xml
> "best practice" suggests it (portability issues). Anyhow, when marshalling
> we are actually using some encoding, so why not specify? BTW, JAXB RI does
> use xml declaration. If you like I can provide the examples I used with RI
> to check this.

What's the JAXB RI behaviour for

     JAXBContext c;
     StringWriter sw = new StringWriter();
     c.createMarshaller().marshal(o, sw);

Does it create an XML declaration in that case? In either case, I'd vote
to follow and make this the default, for portability reasons.


Jochen

--
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: xmlDeclaration

Posted by Jochen Wiedmann <jo...@freenet.de>.
Nacho G. Mac Dowell wrote:

> It doesn't specify anything about xml declaration. The thing is that xml
> "best practice" suggests it (portability issues). Anyhow, when marshalling
> we are actually using some encoding, so why not specify? BTW, JAXB RI does
> use xml declaration. If you like I can provide the examples I used with RI
> to check this.

What's the JAXB RI behaviour for

     JAXBContext c;
     StringWriter sw = new StringWriter();
     c.createMarshaller().marshal(o, sw);

Does it create an XML declaration in that case? In either case, I'd vote 
to follow and make this the default, for portability reasons.


Jochen

-- 
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


RE: xmlDeclaration

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
All the JAXB specification says about encoding is the following:

 By default, the Marshaller will use UTF-8 encoding when generating XML data
to a java.io.OutputStream, or a java.io.Writer. Use the setProperty API to
change the ouput encoding used during these marshal operations. Client
applications are expected to supply a valid character encoding name as
defined in the W3C XML 1.0 Recommendation and supported by your  Java
Platform.

It doesn't specify anything about xml declaration. The thing is that xml
"best practice" suggests it (portability issues). Anyhow, when marshalling
we are actually using some encoding, so why not specify? BTW, JAXB RI does
use xml declaration. If you like I can provide the examples I used with RI
to check this.


-----Mensaje original-----
De: Jochen Wiedmann [mailto:jochen.wiedmann@freenet.de]
Enviado el: lunes, 23 de agosto de 2004 14:43
Para: Nacho G. Mac Dowell
CC: jaxme-dev@ws.apache.org
Asunto: Re: xmlDeclaration


Nacho G. Mac Dowell wrote:
> Shouldn't xmlDeclaration from org.apache.ws.jaxme.impl.JMMarshallerImpl be
> turned on by default?

Why do you think so?

If the JAXB SPEC mandates, you are obviously right. If the JAXB RI does
so, I'd be +1, for compatibility reasons. Otherwise, I'd be -0: If the
user requires, it is easy to add. And, if the user doesn't require, it
is more difficult to remove.


Jochen

--
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: xmlDeclaration

Posted by Jochen Wiedmann <jo...@freenet.de>.
Nacho G. Mac Dowell wrote:
> Shouldn't xmlDeclaration from org.apache.ws.jaxme.impl.JMMarshallerImpl be
> turned on by default?

Why do you think so?

If the JAXB SPEC mandates, you are obviously right. If the JAXB RI does 
so, I'd be +1, for compatibility reasons. Otherwise, I'd be -0: If the 
user requires, it is easy to add. And, if the user doesn't require, it 
is more difficult to remove.


Jochen

-- 
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org