[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: ISO-8859-1 encoding and XmlDecl omision (was Re: [xsl] Looking up keys in a separate xml file)

Subject: RE: ISO-8859-1 encoding and XmlDecl omision (was Re: [xsl] Looking up keys in a separate xml file)
From: "John Meyer" <jmeyer@xxxxxxxxxxx>
Date: Wed, 7 Jan 2004 10:25:19 -0500

This is exactly the case I was concerned about when the processor
ignores the omit-xml-declaration. I understand the rationale behind
forcing the processor to ignore the directive due to the fact the
document may become invalid if care is not taken to preserve the
encoding information elsewhere. On the other hand, there are cases where
outputting a declaration is troublesome, even though these cases are
technically a misuse of resulting XML since they do allow proper use of
entity references.

As David pointed out, the correct way to combine fragments like this is
via external entity references. Unfortunately, I don't believe this is
an option within JSP/HTML. You're best bet is to manually strip out the
XML declaration after the transformation. Most likely, you can do this
by simply removing the first line of result. It's by no means elegant,
but it should work.

Also, you may want to consider changing the output method to html if
this is an option. HTML output will never contain an XML declaration.

John Meyer
Senior Software Engineer
Clinician Support Technology
1 Wells Avenue, Suite 201
Newton, MA 02459

-----Original Message-----
From: Andrew Welch [mailto:AWelch@xxxxxxxxxxxxxxx] 
Sent: Wednesday, January 07, 2004 9:41 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: ISO-8859-1 encoding and XmlDecl omision (was Re: [xsl]
Looking up keys in a separate xml file)

> I wrote
> > It has to either ignore the omit-xml-declaration, or ignore the 
> > requested encoding, and to output using an encoding that doesn't 
> > require a text declaration (utf8 or utf16)
> Actually although this is my experience of XSLT1 
> implementations, the XSLT1 spec is not so explicit on the 
> behaviour in this case.
> However the XSLT2 drafts (which I've read more recently) are explicit:
>   The omit-xml-declaration parameter should be ignored if the
>   standalone parameter is present, or if the encoding parameter
>   specifies a value other than UTF-8 or UTF-16. 

I currently have the situation where the result of my transform is
included as part of a html page using jsp.  

I use encoding="ascii" to ensure all of my character refs remain as
character refs through to the output, but for this reason (as Ive just
found out) the omit-xml-declaration="yes" is ignored - which means in
the middle of my output I have the xml declaration.

HTML being as forgiving as it is, this isnt a problem, but I would like
it gone - whats the solution here?

I would have thought that as ascii is a subset of utf-8, the processor
could happily leave the declartion out knowing that any future parsing
of the document would use utf-8 (by default) and could correctly read
the file.  


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread