XML Namespace PHP forces attribute

J

Jeff.M

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?
 
T

TOUDIdel

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.
 
P

Pavel Lepin

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top