You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Mihai Matei <mi...@yahoo.com> on 2007/09/27 17:47:16 UTC

xml output - left justified?

Hi,

    We are using Xerces-C 2.7 to generate various xml files, but some parsers that consume our files cannot consume them. In order to modify our files (they are XML compliant, but the other parsers are not), do you know if:

1. - can we left-justify the ouput? I looked at the options of the DOMWriter and there isn't any about it. Essentially we'd like a 'pretty print' output but with no whitespace at the beginning of the line.

and, if 1. cannot be achieved:

2. - can we save the xml stream to a string, so we can update it before saving to a file?

Thanks.


      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 

RE: xml output - left justified?

Posted by Jesse Pelton <js...@PKC.com>.
Option 1: Since the source code is readily available, you can adapt the
DOMWriter to your needs (or write your own variant).  The code is
DOM/impl/DOMWriterImpl.cpp.  You might go so far as to add an additional
feature flag and offer the updated code back to the project.

Option 2: serialize to a MemBufFormatTarget rather than (I assume)
LocalFileFormatTarget.

Personally, I'd go for the first option.  (In fact, I have made similar
modifications, because DOMWriter injects too many newlines for my
taste.)  The second is inefficient and works around a problem rather
than solving it.

-----Original Message-----
From: Mihai Matei [mailto:mihaimilk@yahoo.com] 
Sent: Thursday, September 27, 2007 11:47 AM
To: c-users@xerces.apache.org
Subject: xml output - left justified?

Hi,

    We are using Xerces-C 2.7 to generate various xml files, but some
parsers that consume our files cannot consume them. In order to modify
our files (they are XML compliant, but the other parsers are not), do
you know if:

1. - can we left-justify the ouput? I looked at the options of the
DOMWriter and there isn't any about it. Essentially we'd like a 'pretty
print' output but with no whitespace at the beginning of the line.

and, if 1. cannot be achieved:

2. - can we save the xml stream to a string, so we can update it before
saving to a file?

Thanks.


 
________________________________________________________________________
____________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user
panel and lay it on us.
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 

Re: xml output - left justified?

Posted by David Bertoni <db...@apache.org>.
Mihai Matei wrote:
> Hi,
> 
>     We are using Xerces-C 2.7 to generate various xml files, but some parsers that consume our files cannot consume them. In order to modify our files (they are XML compliant, but the other parsers are not), do you know if:

The first thing to do is to fix or replace your non-compliant tools.  XML 
has been around long enough that you shouldn't tolerate something like that.

> 
> 1. - can we left-justify the ouput? I looked at the options of the DOMWriter and there isn't any about it. Essentially we'd like a 'pretty print' output but with no whitespace at the beginning of the line.

There is no notion of "left-justify" in XML, so I'm not sure what that 
means.  Arbitrarily stripping whitespace from a document can change its 
content, so you should be careful about doing that.

> 
> and, if 1. cannot be achieved:
> 
> 2. - can we save the xml stream to a string, so we can update it before saving to a file?
MemBufFormatTarget is your friend...

Dave