1

Topic: Output formatting

I use XSLTProcessor and a method transformToDoc (). After that I deduce through saveXML () or saveHtml (). On an output at me already a template without a formation. How it is possible to disconnect it?

2

Re: Output formatting

On idea, this question already concerns not to XSLTProcessor , and to DOMDocumen t to object which turned out as a result transformToDoc () .
Try to use in XSL

<xsl:output indent = "no"/>

And to appropriate explicitly appropriate property to the document

$dom = $proc-> transformToDoc ($xml);
$dom-> formatOutput = false;

3

Re: Output formatting

Did not help:nea

4

Re: Output formatting

Try that at you produces such example
test.xml

<? xml version = "1.0" encoding = "iso-8859-1"?>
<greeting> Hello, world! </greeting>

test.xsl

<? xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0">
<xsl:output method = "html" version = "4.0" encoding = "UTF-8" indent = "no" doctype-public = "-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system = "http://www.w3.org/TR/html4/loose.dtd"/>
<xsl:strip-space elements = "*"/>
<xsl:template match = "/">
<html>
<head>
<title> Today's greeting </title>
</head>
<body>
<p> <xsl:value-of select = "greeting"/> </p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

test.php

<? php
$xml = domdocument:: load (' test.xml ');
$xsl = domdocument:: load (' test.xsl ');
$proc = new XsltProcessor ();
$xsl = $proc-> importStylesheet ($xsl);
$dom = $proc-> transformToDoc ($xml);
$dom-> formatOutput = false;
echo $dom-> saveXML ();
?>

Can specify explicitly also

echo $dom-> saveXML (null, LIBXML_NOBLANKS);

And is even easier if to use not transformToDoc (), and transformToXML (). Then there are enough instructions in XSL, any additional adjustments it is not necessary

5

Re: Output formatting

Instead of you could give pair of links to the information on the processor? And that I cannot find the convenient tool:search in any way

6

Re: Output formatting

http://www.php.net/manual/en/ref.xsl.php :smile

7

Re: Output formatting

Thanks, I will try to understand:smile
[mergetime] 1186983810 [/mergetime]
, not that. But all the same thanks:biggrin

8

Re: Output formatting

Through a floor  I will try.

9

Re: Output formatting

Did not help. Can  to deliver that and under it to chop? Not  at me problems  a hosting?

10

Re: Output formatting

What exactly did not help? You tried a variant:
In <xsl:output> indent = "no"
<xsl:strip-space elements = "*"/>
In php

echo $proc-> transformToXML$xml);

?
My example from  a post produces xml with superfluous whitespaces or without?
[mergetime] 1187001363 [/mergetime]
I did not try to put sablotron with PHP5. I assume that there can be problems as zend suggests to use XSLTProcessor and does not support PHP5 + sablotron. C even if straight lines  will not be, operation there not so well is debugged

11

Re: Output formatting

Without
All aforesaid tried

12

Re: Output formatting

And, well means, I simply misunderstood that you want. I thought, you need to receive an output without superfluous whitespaces, and you want to save formatting just. I am sorry that tangled business. Then all just what isn't needed.
In <xsl:output> indent = "yes"
If gaps in tags have to be saved, instead of
<xsl:strip-space> - remove, and if for the majority of tags it is used, for where it is necessary to save <xsl:preserve-space>. For transformToXML () - everything, and for transformToDoc () for turned out DOMDocument it is specified
$dom-> formatOutput = true;
I hope, this time I correctly understood your idea

13

Re: Output formatting

Hurrah-and-and-and-a-a:yahoo
Thanks.
As that even ridiculously turned out smile Make so, and is not present so, quitted? Well now on the contrary all:biggrin
From me a plus, it is deserved

14

Re: Output formatting

On health:smile
Happens and so. Once again I am sorry for confusion, well all is good that well comes to an end

15

Re: Output formatting

Yes you excuse. At me  problem Russian. If not Google check I in such still minuses gets (look my turnip:crazy). But  English at me is even worse.

16

Re: Output formatting

The new post did not begin to create kind time of days decided to write in it as a problem similar smile
I write a site I transform xml with the help xsl and I process all it in php

 <?
$xml_text = ' <? xml version = "1.0" encoding = "utf-8"?>
<docs>
<doc>
<name> lex </name>
</doc>
<doc>
<name> wqewqe </name>
</doc>
</docs>
';
$xml = new DOMDocument ();
$xml-> loadXML ($xml_text);
$xml-> formatOutput = true;
$xml-> preserveWhiteSpace = false;
if (isset ($ _GET ["q"])) {
header (' Content-Type: application/xml; charset=utf-8 ');
echo $xml-> saveXML ();
die ();
}else {
$xsl = new DOMDocument ();
$xsl-> load (' quotes.xsl ');
$xslt = new XsltProcessor ();
$xslt-> importStylesheet ($xsl);
$result = $xslt-> transformToDoc ($xml);
$result-> formatOutput = true;
$result-> preserveWhiteSpace = false;
header ("Content-Type: text/html; charset=utf-8");
?>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8"/>
<title> the Document without a title </title>
</head>
<body>
<? = $result-> saveXML ();?>
</body>
</html>
<?}?>

quotes.xsl Contains

 <? xml version = "1.0" encoding = "utf-8"?>
<! DOCTYPE xsl:stylesheet>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns = "http://www.w3.org/TR/xhtml1/strict" doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN" encoding = "utf-8" indent = "yes" method = "html" omit-xml-declaration = "no" version = "1.0" media-type = "text/xml"/>
<xsl:template match = "/docs">
<xsl:apply-templates select = "doc"/>
</xsl:template>
<xsl:template match = "doc">
<p style = "padding:15px; border:1px solid #424242"> <xsl:value-of select = "name"/> </p>
</xsl:template>
</xsl:stylesheet>

But on an output I receive where at me goes echo $result-> saveXML ();
The superfluous

 <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8"/>
<title> the Document without a title </title>
</head>
<body>
<? xml version = "1.0" encoding = "utf-8" standalone = "yes"?>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<p style = "padding:15px; border:1px solid #424242"> lex </p>
<p style = "padding:15px; border:1px solid #424242"> wqewqe </p>
</body>
</html>

How to remove <? xml version = "1.0" encoding = "utf-8" standalone = "yes"?>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
??????

17

Re: Output formatting

leshafirs, 4/13/2011, 17:18, post2330215 wrote:

the new post did not begin to create decided to write in it as a problem similar smile

That is remaining are obliged to read the whole page in the end to learn, what the problem consists in other?