Re: [xslt] transformation removes DOCTYPE declaration form original document - Yes it does!



OK - I tried this with Perl - and the same things happens!

I am sure this cannot be 'correct' behaviour - unless there is a note in the documentation I have missed that says XML::LibXSLT will change your SOURCE document?

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use XML::LibXML;
5 use XML::LibXSLT;
6
7 my $doc = '<?xml version="1.0" encoding="UTF-8"?>
8 <!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://pyxml.sourceforge.net/topics/dtds/xbel-1.0.dtd";>
9 <xbel>
10 </xbel>
11 ';
12
13 my $xsl = '<?xml version="1.0" encoding="ISO-8859-2"?>
14 <xsl:stylesheet version="1.0"
15 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
16
17 <xsl:output method="xml" indent="yes" encoding="iso-8859-2"/>
18
19 <xsl:template match="/">
20 <xsl:apply-templates/>
21 </xsl:template>
22
23 <xsl:template match="/xbel">
24 <z/>
25 </xsl:template>
26
27 </xsl:stylesheet>
28 ';
29
30 my $parser=XML::LibXML->new();
31 my $XDOC = $parser->parse_string($doc);
32 my $XDOC_DUP = $parser->parse_string($doc);
33 $XDOC->setEncoding('UTF8');
34
35 print "Source DOC Before Transform:\n\n";
36 print $XDOC->toString(1);
37
38 my $xslt=XML::LibXSLT->new();
39 my $xxsl = $parser->parse_string($xsl);
40 $xxsl = $xslt->parse_stylesheet($xxsl);
41 my $result=$xxsl->transform($XDOC);
42
43 print "\nSource DOC After Transform:\n\n";
44 print $XDOC->toString(1);
45 print "\n\nWhereas I was expecting:\n\n";
46 print $XDOC_DUP->toString(1);




[root www Examples]# perl t1.pl
Source DOC Before Transform:

<?xml version="1.0" encoding="UTF8"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://pyxml.sourceforge.net/topics/dtds/xbel-1.0.dtd";>
<xbel>
</xbel>


Source DOC After Transform:

<?xml version="1.0" encoding="UTF8"?>
<xbel>
</xbel>


Whereas I was expecting:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://pyxml.sourceforge.net/topics/dtds/xbel-1.0.dtd";>
<xbel>
</xbel>
[root www Examples]#


SO it looks like the XSLT process does change the source document!

Glad you pointed that out


Mike Trotman wrote:

I'm not sure of the python libxslt syntax - but assume it is like the Perl XML::LibXML

$stylesheet->transform($doc, foo => "value);

which 'throws away' the XSLT output.

So - in the example code RadosÅaw doesn't use the output of the XSLT transformation.
He just prints the INPUT document twice.
So it looks like the code HAS changed the input document.
Which surely has nothing to do with any XSLT / XPATH concerns.


I will try this in Perl tomorrow and see if the same things happens.

Mike

Vincent Lefevre wrote:

On 2005-04-14 11:24:49 +0200, RadosÅaw Kintzi wrote:


I don't care about DT declaration in target document. I just care
about one in original (source) document. It has such declaration,
which was removed by processor during transformation.
In other words: the processor change source document. It is right behavior or it is a bug?



This doesn't have much sense. An XSLT processor takes a source document and outputs a target document. Do you mean that your source file is modified, in addition to the output of the target file? I've never seen such a thing...




------------------------------------------------------------------------

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.9 - Release Date: 13/04/2005


------------------------------------------------------------------------

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt gnome org
http://mail.gnome.org/mailman/listinfo/xslt





-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.18 - Release Date: 19/04/2005



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]