The serializer is the software that converts a tree representation of XML
into the lexical angle-bracket representation. If you ask your XSLT
processor to write the result to a tree (for example a DOM tree) then the
XSLT processor doesn't serialize and therefore doesn't use xsl:output; if
you've got lexical output then you probably got it by calling a method such
as toXML() on your DOM object. That would invoke a serializer that's part of
your DOM implementation, which doesn't know anything about the xsl:output
declaration in your stylesheet.
There's no point, incidentally, in constructing a DOM tree to hold the
result of your transformation if the only thing you are going to do is to
serialize it.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mike Stroud [mailto:stroudmw(_at_)gmail(_dot_)com]
Sent: 25 February 2009 06:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Re: encoding error when using cdata
I'm sorry to have to admit that I have no idea how to check
what kind of serializer I'm using. I don't even know what a
serializer is. That gives me one more thing to read up on today.
Mike.
Date: Tue, 24 Feb 2009 09:20:09 -0000
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] Re: encoding error when using cdata
Message-ID: <28527BCDF9D247048A274FEA963E47CE(_at_)Sealion>
I strongly suspect that you are using the DOM serializer
rather than
the XSLT serializer. Check the code used to run the
transformation: if
you are sending the result to a DOM destination, then the XSLT
processor is not doing the serialization, and everything
you say in xsl:output is ignored.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mike Stroud [mailto:stroudmw(_at_)gmail(_dot_)com]
Sent: 24 February 2009 06:23
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Re: encoding error when using cdata
Hello Michael & all,
Many thanks for your reply. What I don't understand is why the
resultant XML file is encoded like this: <?xml version="1.0"
encoding="UTF-16"?>. I can't seem to change it! What I want is
WINDOWS-1252, but I end up with UTF-16 no matter what I do (The
source XML document is UTF-8). My XSL looks like this:
<?xml version="1.0" encoding="Windows-1252"?> <xsl:stylesheet
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"
cdata-section-elements="Name LongDesc"/> <xsl:template match="/"
xmlns:wc="http://www.ptc.com/infoengine/1.0">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Thanks again,
Mike.
Date: Mon, 23 Feb 2009 09:35:00 -0000
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] encoding error when using cdata
Message-ID: <F96EBBFDBCD64FF788886401A4C8328C(_at_)Sealion>
The error is Microsoft-specific, see for example
http://support.microsoft.com/kb/275883
Incidentally, your code shows inconsistencies in the spelling of
"description" and "longDesc". XML is case-sensitive.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mike Stroud [mailto:stroudmw(_at_)gmail(_dot_)com]
Sent: 23 February 2009 09:13
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] encoding error when using cdata
Hello all,
I've been experimenting with cdata because I've got some funny
characters in my XML files. I've got something like this:
<?xml version="1.0" encoding="UTF-8"?> <wc:COLLECTION
xmlns:wc="http://www.ptc.com/infoengine/1.0">
<ChangedParts NAME="ChangedParts" TYPE="Unknown"
STATUS="0"> <Part>
<Name>446RLi SMD ASSY</Name> <description></description>
<LongDesc></LongDesc>
etc...
The XSL looks like this:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"
cdata-section-elements="Name Description Longdesc"/>
<xsl:template
match="/" xmlns:wc="http://www.ptc.com/infoengine/1.0">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
And the resultant XML turns out like this...
<?xml version="1.0" encoding="UTF-16"?> <wc:COLLECTION
xmlns:wc="http://www.ptc.com/infoengine/1.0">
etc...
I now get the following error: Switch from current encoding to
specified encoding not supported. Line: 1. <?xml version="1.0"
encoding="UTF-16"?>
Does anyone know how I can fix this? I've tried
different encoding
methods in the XSL file, but they appear to be ignored.
Thanks,
Mike.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--