Re: Embed XHTML code using PHP's XSLT processor

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

 



Hi ,

this happens because a xml-parser (your browser,...) has to remove all
spaces, etc.which are not nessesary.

hope that helps

bb

Am $date schrieb $from:

>This'll be a rather long post because of the code snippets, so please
>bear
>with me.
>
>I'm trying to embed XHTML code from a XML file and I'm wondering why
>PHP's
>XSLT doesn't indent it correctly.
>
>So, this stylesheet:
>
>
><?xml version="1.0" encoding="iso-8859-1" ?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
><xsl:output method="xml" indent="yes" encoding="iso-8859-1"
>doctype-public="-//W3C//DTD XHTML 1.1//EN"
>doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
>media-type="application/xhtml+xml"
>omit-xml-declaration="yes" />
>
><xsl:template match="/">
><html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
><body>
><xsl:apply-templates select="*/content/text" />
></body>
></html>
></xsl:template>
>
>
><xsl:template match="*/content/text">
><xsl:apply-templates />
></xsl:template>
>
><xsl:template match="*/content/text//*">
><xsl:element name="{local-name()}">
><xsl:for-each select="@*">
><xsl:attribute name="{name(.)}">
><xsl:value-of select="." />
></xsl:attribute>
></xsl:for-each>
><xsl:apply-templates select="node()" />
></xsl:element>
></xsl:template>
>
></xsl:stylesheet>
>
>applied to this document:
>
>
><?xml version="1.0" encoding="iso-8859-1" ?>
><?xml-stylesheet type="text/xsl" href="stylesheet.xsl" ?>
>
><root>
><content>
><text><xhtml:form action="" method="post"><xhtml:input type="text"
>id="foo" name="bar" /><input type="submit" name="submit"
>/></xhtml:form></text>
></content>
><content>
><text>
><xhtml:form action="" method="post">
><xhtml:input type="text" id="foo" name="bar" />
><xhtml:input type="submit" name="submit" />
></xhtml:form>
></text>
></content>
></root>
>
>produces this output:
>
>
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
><html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
><body><form action="" method="post"><input type="text" id="foo"
>name="bar"/><input type="submit" name="submit"/></form>
><form action="" method="post">
><input type="text" id="foo" name="bar"/>
><input type="submit" name="submit"/>
></form>
></body>
></html>
>
>If I set "indent" to "no", then it produces this output:
>
>
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
><html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en"
>lang="en"><body><form action="" method="post"><input type="text"
>id="foo"
>name="bar"/><input type="submit" name="submit"/></form>
><form action="" method="post">
><input type="text" id="foo" name="bar"/>
><input type="submit" name="submit"/>
></form>
></body></html>
>
>
>- Is it possible to indent the XHTML code from the XML file so that it
>fits
>the rest of the (XHTML) document, and if so, how?
>- Is it a namespace or white-space/CR/LF problem?
>
>Any help appreciated!
>
>Markus
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Björn Bartels
-Development/IT-Services-

----------------------------------------------
dbusiness.de gmbh
digital business & printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
info@xxxxxxxxxxxx
ftp://dbusiness.dyndns.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux