Return-Path: Delivered-To: apmail-xml-xerces-j-user-archive@xml.apache.org Received: (qmail 8555 invoked by uid 500); 14 Nov 2002 06:07:25 -0000 Mailing-List: contact xerces-j-user-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: xerces-j-user@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list xerces-j-user@xml.apache.org Received: (qmail 8546 invoked from network); 14 Nov 2002 06:07:24 -0000 Subject: Re: Transforming XML document From: Simon Kitching To: xerces-j-user@xml.apache.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 14 Nov 2002 19:05:53 +1300 Message-Id: <1037253953.13035.218.camel@PCSIMON.ecnnz.ecnetwork.co.nz> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, Unfortunately, you're out of luck. XML parsing just doesn't work that way. XML parsers are required to respect the contents of text nodes within an xml document, but in every other place whitespace is not significant according to the spec. You can either treat the input file as a plain text file (eg use perl to modify it), or you can treat it as XML in which case the XML parser will guaruntee to preserve the *meaning* of your XML document, but not necessarily its layout. For example, (two spaces) in xml means *exactly* the same thing as (one space). You do get to choose the "style" in which the output is generated (indented or not, how much indenting, etc) but you cannot ask for "the same as the input", because no existing XML parser bothers to keep that information around. Regards, Simon On Thu, 2002-11-14 at 18:36, Wai-Yip Tung wrote: > I am trying to make simple transformation on a XML document. Let say just > changing one attribute value. I want to keep everything else the same, > including white spaces. > > My first task is to parse and output a document identical to the input > document. It seems the sample code sax.Writer is a good example. > Unfortunately it altered the document in several ways > > - white space in an element is changed, e.g. > becomes > > - The empty element becomes two tags, e.g. > becomes > > Anyone can give me some direction? > > Wai yip > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org > For additional commands, e-mail: xerces-j-user-help@xml.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org For additional commands, e-mail: xerces-j-user-help@xml.apache.org