XML Namespace PHP forces attribute

Jeff.M

Usenet Archive
Joined
Dec 25, 2007
Messages
10
Reaction score
0
Consider the following XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:php="http://php.net/xsl"> <xsl:eek:utput method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" /> <xsl:template match="/"> <html> <head> <title>Hello</title> </head> <body> <p>fubar</p> </body> </html> </xsl:template>

</xsl:stylesheet>

The presence of the xmlns:php="http://php.net/xsl" XML attribute causes the same to appear as an attribute of the HTML element in my output, like so:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html xmlns:php="http://php.net/xsl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Hello</title> </head> <body><p>fubar</p></body> </html>

The problem is this isn't valid HTML. Without sacrificing using PHP functions as XSLT functions, how do I get this attribute out of my output?
 

TOUDIdel

Usenet Archive
Joined
Aug 25, 2005
Messages
36
Reaction score
0
Uzytkownik "Jeff.M said:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:php="http://php.net/xsl"> <xsl:eek:utput method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" /> <xsl:template match="/"> <html> <head> <title>Hello</title> </head> <body> <p>fubar</p> </body> </html> </xsl:template> </xsl:stylesheet>

if you don't need php prefix in transformation, remove that namespace declaration. if you need it in xsl, add exclude-result-prefixes (.. exclude-result-prefixes="php") attribute in xsl:stylesheet.
 

Pavel Lepin

Usenet Archive
Joined
Apr 20, 2007
Messages
263
Reaction score
0
Jeff.M said:
The presence of the xmlns:php="http://php.net/xsl" XML attribute causes the same to appear as an attribute of the HTML element in my output, like so:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/ TR/html4/strict.dtd">
<html xmlns:php="http://php.net/xsl">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"> <title>Hello</title>
</head>
<body><p>fubar</p></body>
</html>

The problem is this isn't valid HTML. Without sacrificing using PHP functions as XSLT functions, how do I get this attribute out of my output?

Use exclude-result-prefixes attribute on xsl:stylesheet element.

Why do you need PHP functions in your transformation anyway?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,050
Messages
3,104,249
Members
248,133
Latest member
DujonT

Latest Threads

Top