Re: [xsl] <param> tag in input document breaks <xsl:copy-of select="." />

Subject: Re: [xsl] <param> tag in input document breaks <xsl:copy-of select="." />
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 3 Jul 2013 10:10:40 +0100
How are you viewing the output?

If this is the serialized output of the XSLT processor, then it's wrong and
clearly a bug in the XSLT processor. On the other hand, if it is the result of
loading the (invalid) HTML into a browser and then viewing the resulting DOM,
then it might well be legitimate - browsers do strange things with invalid
HTML.

Either way, one has to ask why you are using the HTML output method when your
stylesheet result is not HTML.

Michael Kay
Saxonica


On 3 Jul 2013, at 09:44, Evgeny Turnaev wrote:

> Hello.
>  Dear All, i have searched the web and this mail list and found
> nothing related to my question.
>  Sorry if this is something obvious and mentioned in xml standard but
> this really looks strange to me.
>
> The Question:
>
> Given this input document:
> <?xml version="1.0" encoding="UTF-8" ?>
> <param>
> <sometag>Hello world</sometag>
> </param>
>
> And this simple stylesheet:
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
> <xsl:output method="html"/>
>
> <xsl:template match="/">
>    <xsl:copy-of select="." />
> </xsl:template>
>
> </xsl:stylesheet>
>
> The output is:
> <param>
>
> While i expect output:
> <param>
> <sometag>Hello world</sometag>
> </param>
>
> However changing <param> tag in input document to some other tag fixes
> problem and output match expectations.
> Also changing <xsl:output method="html"/> to <xsl:output
> method="xml"/> fixes problem, but i really want to keep <xsl:output
> method="html"/>.
> I have stumbled this while making transform on xml-rpc output: it
> starts with <methodResponse><params><param> and all the contents of
> <param> tag is missing in output.
> Is there something special about <param> tag in input document? I
> suppose input document tags should not anyhow change result of
> <xsl:copy-of select="." />, is'nt it?
>
> Some technical info:
> Transformation code was taken literally as copy of example from page:
> http://xmlsoft.org/XSLT/tutorial/libxslttutorial.html
> (
> and then
> gcc ./libxslt_tutorial.c -o ./test_xslt -I/usr/include/libxml2 -lxml2
-lxslt
> ./test_xslt output.xsl xml_rpc.xml
> )
> System: ubuntu 12.04
> Linux mtnp 3.2.0-36-generic #57-Ubuntu SMP Tue Jan 8 21:44:52 UTC 2013
> x86_64 x86_64 x86_64 GNU/Linux
>
> libxml & libxslt installed via apt-get
> Package: libxml2
> Priority: standard
> Section: libs
> Installed-Size: 1745
> Maintainer: Ubuntu Developers <ubuntu-devel-discuss@xxxxxxxxxxxxxxxx>
> Original-Maintainer: Debian XML/SGML Group
> <debian-xml-sgml-pkgs@xxxxxxxxxxxxxxxxxxxxxxx>
> Architecture: amd64
> Version: 2.7.8.dfsg-5.1ubuntu4
> Depends: libc6 (>= 2.15), zlib1g (>= 1:1.2.3.3.dfsg)
>
>
> Package: libxslt1.1
> Priority: optional
> Section: libs
> Installed-Size: 468
> Maintainer: Ubuntu Developers <ubuntu-devel-discuss@xxxxxxxxxxxxxxxx>
> Original-Maintainer: Debian XML/SGML Group
> <debian-xml-sgml-pkgs@xxxxxxxxxxxxxxxxxxxxxxx>
> Architecture: amd64
> Source: libxslt
> Version: 1.1.26-8ubuntu1
> Depends: libc6 (>= 2.4), libgcrypt11 (>= 1.4.5), libxml2 (>= 2.7.4)
>
>
> Any thoughts or suggestions?

Current Thread